mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-12 07:35:31 +01:00
Add mode option for mount module
This commit is contained in:
parent
7417d857f1
commit
52d040c689
1 changed files with 17 additions and 0 deletions
|
|
@ -105,6 +105,17 @@ options:
|
||||||
the original file back if you somehow clobbered it incorrectly.
|
the original file back if you somehow clobbered it incorrectly.
|
||||||
type: bool
|
type: bool
|
||||||
default: no
|
default: no
|
||||||
|
mode:
|
||||||
|
description:
|
||||||
|
- The permission applied to create a new directory for mount point.
|
||||||
|
If the mount point already exists, this parameter is not used.
|
||||||
|
- This parameter only affects to the mount point itself.
|
||||||
|
If this module creates multiple directories recursively,
|
||||||
|
other directories follow the system's default umask.
|
||||||
|
- Note that after running this task and device being successfuly mounted,
|
||||||
|
the mode of the original directory will be hidden by the target device.
|
||||||
|
type: raw
|
||||||
|
required: false
|
||||||
notes:
|
notes:
|
||||||
- As of Ansible 2.3, the I(name) option has been changed to I(path) as
|
- As of Ansible 2.3, the I(name) option has been changed to I(path) as
|
||||||
default, but I(name) still works as well.
|
default, but I(name) still works as well.
|
||||||
|
|
@ -122,6 +133,7 @@ EXAMPLES = r'''
|
||||||
fstype: iso9660
|
fstype: iso9660
|
||||||
opts: ro,noauto
|
opts: ro,noauto
|
||||||
state: present
|
state: present
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
- name: Mount up device by label
|
- name: Mount up device by label
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
|
|
@ -665,6 +677,7 @@ def main():
|
||||||
src=dict(type='path'),
|
src=dict(type='path'),
|
||||||
backup=dict(type='bool', default=False),
|
backup=dict(type='bool', default=False),
|
||||||
state=dict(type='str', required=True, choices=['absent', 'mounted', 'present', 'unmounted', 'remounted']),
|
state=dict(type='str', required=True, choices=['absent', 'mounted', 'present', 'unmounted', 'remounted']),
|
||||||
|
mode=dict(type='raw'),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
required_if=(
|
required_if=(
|
||||||
|
|
@ -761,6 +774,7 @@ def main():
|
||||||
|
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
name = module.params['path']
|
name = module.params['path']
|
||||||
|
mode = module.params['mode']
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
|
|
@ -813,6 +827,9 @@ def main():
|
||||||
if not (ex.errno == errno.EEXIST and os.path.isdir(b_curpath)):
|
if not (ex.errno == errno.EEXIST and os.path.isdir(b_curpath)):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
if mode is not None:
|
||||||
|
os.chmod(name, int(mode))
|
||||||
|
|
||||||
except (OSError, IOError) as e:
|
except (OSError, IOError) as e:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg="Error making dir %s: %s" % (name, to_native(e)))
|
msg="Error making dir %s: %s" % (name, to_native(e)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue