mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-02-04 08:01:49 +00:00
Merge https://github.com/ansible-collections/ansible.posix into issues/126/mount-return-backup-file
This commit is contained in:
commit
b740bdaf3a
18 changed files with 203 additions and 107 deletions
|
|
@ -67,8 +67,10 @@ options:
|
|||
description:
|
||||
- Recursively sets the specified ACL.
|
||||
- Incompatible with C(state=query).
|
||||
- Alias C(recurse) added in version 1.3.0.
|
||||
type: bool
|
||||
default: no
|
||||
aliases: [ recurse ]
|
||||
use_nfsv4_acls:
|
||||
description:
|
||||
- Use NFSv4 ACLs instead of POSIX ACLs.
|
||||
|
|
@ -273,7 +275,7 @@ def main():
|
|||
),
|
||||
follow=dict(type='bool', default=True),
|
||||
default=dict(type='bool', default=False),
|
||||
recursive=dict(type='bool', default=False),
|
||||
recursive=dict(type='bool', default=False, aliases=['recurse']),
|
||||
recalculate_mask=dict(
|
||||
type='str',
|
||||
default='default',
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ options:
|
|||
choices: [ absent, disabled, enabled, present ]
|
||||
timeout:
|
||||
description:
|
||||
- The amount of time the rule should be in effect for when non-permanent.
|
||||
- The amount of time in seconds the rule should be in effect for when non-permanent.
|
||||
type: int
|
||||
default: 0
|
||||
masquerade:
|
||||
|
|
@ -393,26 +393,14 @@ class PortTransaction(FirewallTransaction):
|
|||
)
|
||||
|
||||
def get_enabled_immediate(self, port, protocol, timeout):
|
||||
port_proto = [port, protocol]
|
||||
if self.fw_offline:
|
||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
||||
ports_list = fw_settings.getPorts()
|
||||
else:
|
||||
ports_list = self.fw.getPorts(self.zone)
|
||||
|
||||
if port_proto in ports_list:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
dummy, fw_settings = self.get_fw_zone_settings()
|
||||
return fw_settings.queryPort(port=port, protocol=protocol)
|
||||
return self.fw.queryPort(zone=self.zone, port=port, protocol=protocol)
|
||||
|
||||
def get_enabled_permanent(self, port, protocol, timeout):
|
||||
port_proto = (port, protocol)
|
||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
||||
|
||||
if port_proto in fw_settings.getPorts():
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
dummy, fw_settings = self.get_fw_zone_settings()
|
||||
return fw_settings.queryPort(port=port, protocol=protocol)
|
||||
|
||||
def set_enabled_immediate(self, port, protocol, timeout):
|
||||
self.fw.addPort(self.zone, port, protocol, timeout)
|
||||
|
|
@ -715,26 +703,14 @@ class ForwardPortTransaction(FirewallTransaction):
|
|||
)
|
||||
|
||||
def get_enabled_immediate(self, port, proto, toport, toaddr, timeout):
|
||||
forward_port = [port, proto, toport, toaddr]
|
||||
if self.fw_offline:
|
||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
||||
forward_list = fw_settings.getForwardPorts()
|
||||
else:
|
||||
forward_list = self.fw.getForwardPorts(self.zone)
|
||||
|
||||
if forward_port in forward_list:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
dummy, fw_settings = self.get_fw_zone_settings()
|
||||
return fw_settings.queryForwardPort(port=port, protocol=proto, to_port=toport, to_addr=toaddr)
|
||||
return self.fw.queryForwardPort(port=port, protocol=proto, to_port=toport, to_addr=toaddr)
|
||||
|
||||
def get_enabled_permanent(self, port, proto, toport, toaddr, timeout):
|
||||
forward_port = (port, proto, toport, toaddr)
|
||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
||||
|
||||
if forward_port in fw_settings.getForwardPorts():
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
dummy, fw_settings = self.get_fw_zone_settings()
|
||||
return fw_settings.queryForwardPort(port=port, protocol=proto, to_port=toport, to_addr=toaddr)
|
||||
|
||||
def set_enabled_immediate(self, port, proto, toport, toaddr, timeout):
|
||||
self.fw.addForwardPort(self.zone, port, proto, toport, toaddr, timeout)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,13 @@ options:
|
|||
boot:
|
||||
description:
|
||||
- Determines if the filesystem should be mounted on boot.
|
||||
- Only applies to Solaris systems.
|
||||
- Only applies to Solaris and Linux systems.
|
||||
- For Solaris systems, C(true) will set C(yes) as the value of mount at boot
|
||||
in I(/etc/vfstab).
|
||||
- For Linux, FreeBSD, NetBSD and OpenBSD systems, C(false) will add C(noauto)
|
||||
to mount options in I(/etc/fstab).
|
||||
- To avoid mount option conflicts, if C(noauto) specified in C(opts),
|
||||
mount module will ignore C(boot).
|
||||
type: bool
|
||||
default: yes
|
||||
backup:
|
||||
|
|
@ -169,6 +175,15 @@ EXAMPLES = r'''
|
|||
opts: rw,sync,hard,intr
|
||||
state: mounted
|
||||
fstype: nfs
|
||||
|
||||
- name: Mount NFS volumes with noauto according to boot option
|
||||
ansible.posix.mount:
|
||||
src: 192.168.1.100:/nfs/ssd/shared_data
|
||||
path: /mnt/shared_data
|
||||
opts: rw,sync,hard,intr
|
||||
boot: no
|
||||
state: mounted
|
||||
fstype: nfs
|
||||
'''
|
||||
|
||||
import errno
|
||||
|
|
@ -231,7 +246,7 @@ def _set_mount_save_old(module, args):
|
|||
old_lines = []
|
||||
exists = False
|
||||
changed = False
|
||||
escaped_args = dict([(k, _escape_fstab(v)) for k, v in iteritems(args)])
|
||||
escaped_args = dict([(k, _escape_fstab(v)) for k, v in iteritems(args) if k != 'warnings'])
|
||||
new_line = '%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s\n'
|
||||
|
||||
if platform.system() == 'SunOS':
|
||||
|
|
@ -677,7 +692,8 @@ def main():
|
|||
opts='-',
|
||||
passno='-',
|
||||
fstab=module.params['fstab'],
|
||||
boot='yes' if module.params['boot'] else 'no'
|
||||
boot='yes' if module.params['boot'] else 'no',
|
||||
warnings=[]
|
||||
)
|
||||
if args['fstab'] is None:
|
||||
args['fstab'] = '/etc/vfstab'
|
||||
|
|
@ -687,7 +703,9 @@ def main():
|
|||
opts='defaults',
|
||||
dump='0',
|
||||
passno='0',
|
||||
fstab=module.params['fstab']
|
||||
fstab=module.params['fstab'],
|
||||
boot='yes',
|
||||
warnings=[]
|
||||
)
|
||||
if args['fstab'] is None:
|
||||
args['fstab'] = '/etc/fstab'
|
||||
|
|
@ -705,14 +723,27 @@ def main():
|
|||
linux_mounts = get_linux_mounts(module)
|
||||
|
||||
if linux_mounts is None:
|
||||
args['warnings'] = (
|
||||
'Cannot open file /proc/self/mountinfo. '
|
||||
'Bind mounts might be misinterpreted.')
|
||||
args['warnings'].append('Cannot open file /proc/self/mountinfo.'
|
||||
' Bind mounts might be misinterpreted.')
|
||||
|
||||
# Override defaults with user specified params
|
||||
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
|
||||
if module.params[key] is not None:
|
||||
args[key] = module.params[key]
|
||||
if platform.system().lower() == 'linux' or platform.system().lower().endswith('bsd'):
|
||||
# Linux, FreeBSD, NetBSD and OpenBSD have 'noauto' as mount option to
|
||||
# handle mount on boot. To avoid mount option conflicts, if 'noauto'
|
||||
# specified in 'opts', mount module will ignore 'boot'.
|
||||
opts = args['opts'].split(',')
|
||||
if 'noauto' in opts:
|
||||
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")
|
||||
elif not module.params['boot']:
|
||||
args['boot'] = 'no'
|
||||
if 'defaults' in opts:
|
||||
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'defaults'.")
|
||||
else:
|
||||
opts.append('noauto')
|
||||
args['opts'] = ','.join(opts)
|
||||
|
||||
# If fstab file does not exist, we first need to create it. This mainly
|
||||
# happens when fstab option is passed to the module.
|
||||
|
|
|
|||
|
|
@ -73,9 +73,9 @@ options:
|
|||
default: no
|
||||
delete:
|
||||
description:
|
||||
- Delete files in C(dest) that don't exist (after transfer, not before) in the C(src) path.
|
||||
- This option requires C(recursive=yes).
|
||||
- This option ignores excluded files and behaves like the rsync opt --delete-excluded.
|
||||
- Delete files in I(dest) that do not exist (after transfer, not before) in the I(src) path.
|
||||
- This option requires I(recursive=yes).
|
||||
- This option ignores excluded files and behaves like the rsync opt C(--delete-after).
|
||||
type: bool
|
||||
default: no
|
||||
dirs:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue