mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 23:25:28 +01: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
3
changelogs/fragments/124_acl.yml
Normal file
3
changelogs/fragments/124_acl.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- acl - add new alias ``recurse`` for ``recursive`` parameter (https://github.com/ansible-collections/ansible.posix/issues/124).
|
||||||
3
changelogs/fragments/175_synchronize.yml
Normal file
3
changelogs/fragments/175_synchronize.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
trivial:
|
||||||
|
- synchronize - fix typo in ``delete`` parameter (https://github.com/ansible-collections/ansible.posix/issues/175).
|
||||||
3
changelogs/fragments/179_firewalld.yml
Normal file
3
changelogs/fragments/179_firewalld.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- firewalld - ensure idempotency with firewalld 0.9.3 (https://github.com/ansible-collections/ansible.posix/issues/179).
|
||||||
3
changelogs/fragments/193_firewalld.yml
Normal file
3
changelogs/fragments/193_firewalld.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
trivial:
|
||||||
|
- firewalld - specify unit for ``timeout`` parameter in docs (https://github.com/ansible-collections/ansible.posix/issues/193).
|
||||||
4
changelogs/fragments/196_boot_opt_for_linux.yml
Normal file
4
changelogs/fragments/196_boot_opt_for_linux.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- mount - Change behavior of ``boot`` option to set ``noauto`` on Linux nodes
|
||||||
|
(https://github.com/ansible-collections/ansible.posix/issues/28).
|
||||||
4
changelogs/fragments/203_boot_opt_for_bsd.yml
Normal file
4
changelogs/fragments/203_boot_opt_for_bsd.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- mount - Change behavior of ``boot`` option to set ``noauto`` on BSD nodes
|
||||||
|
(https://github.com/ansible-collections/ansible.posix/issues/28).
|
||||||
3
changelogs/fragments/204_csh_shell.yml
Normal file
3
changelogs/fragments/204_csh_shell.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- csh - define ``ECHO`` and ``COMMAND_SEP`` (https://github.com/ansible-collections/ansible.posix/issues/204).
|
||||||
3
changelogs/fragments/207-mount_tests.yml
Normal file
3
changelogs/fragments/207-mount_tests.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
trivial:
|
||||||
|
- Make the mount module integration tests more human readable.
|
||||||
|
|
@ -67,8 +67,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- Recursively sets the specified ACL.
|
- Recursively sets the specified ACL.
|
||||||
- Incompatible with C(state=query).
|
- Incompatible with C(state=query).
|
||||||
|
- Alias C(recurse) added in version 1.3.0.
|
||||||
type: bool
|
type: bool
|
||||||
default: no
|
default: no
|
||||||
|
aliases: [ recurse ]
|
||||||
use_nfsv4_acls:
|
use_nfsv4_acls:
|
||||||
description:
|
description:
|
||||||
- Use NFSv4 ACLs instead of POSIX ACLs.
|
- Use NFSv4 ACLs instead of POSIX ACLs.
|
||||||
|
|
@ -273,7 +275,7 @@ def main():
|
||||||
),
|
),
|
||||||
follow=dict(type='bool', default=True),
|
follow=dict(type='bool', default=True),
|
||||||
default=dict(type='bool', default=False),
|
default=dict(type='bool', default=False),
|
||||||
recursive=dict(type='bool', default=False),
|
recursive=dict(type='bool', default=False, aliases=['recurse']),
|
||||||
recalculate_mask=dict(
|
recalculate_mask=dict(
|
||||||
type='str',
|
type='str',
|
||||||
default='default',
|
default='default',
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ options:
|
||||||
choices: [ absent, disabled, enabled, present ]
|
choices: [ absent, disabled, enabled, present ]
|
||||||
timeout:
|
timeout:
|
||||||
description:
|
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
|
type: int
|
||||||
default: 0
|
default: 0
|
||||||
masquerade:
|
masquerade:
|
||||||
|
|
@ -393,26 +393,14 @@ class PortTransaction(FirewallTransaction):
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_enabled_immediate(self, port, protocol, timeout):
|
def get_enabled_immediate(self, port, protocol, timeout):
|
||||||
port_proto = [port, protocol]
|
|
||||||
if self.fw_offline:
|
if self.fw_offline:
|
||||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
dummy, fw_settings = self.get_fw_zone_settings()
|
||||||
ports_list = fw_settings.getPorts()
|
return fw_settings.queryPort(port=port, protocol=protocol)
|
||||||
else:
|
return self.fw.queryPort(zone=self.zone, port=port, protocol=protocol)
|
||||||
ports_list = self.fw.getPorts(self.zone)
|
|
||||||
|
|
||||||
if port_proto in ports_list:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_enabled_permanent(self, port, protocol, timeout):
|
def get_enabled_permanent(self, port, protocol, timeout):
|
||||||
port_proto = (port, protocol)
|
dummy, fw_settings = self.get_fw_zone_settings()
|
||||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
return fw_settings.queryPort(port=port, protocol=protocol)
|
||||||
|
|
||||||
if port_proto in fw_settings.getPorts():
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def set_enabled_immediate(self, port, protocol, timeout):
|
def set_enabled_immediate(self, port, protocol, timeout):
|
||||||
self.fw.addPort(self.zone, 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):
|
def get_enabled_immediate(self, port, proto, toport, toaddr, timeout):
|
||||||
forward_port = [port, proto, toport, toaddr]
|
|
||||||
if self.fw_offline:
|
if self.fw_offline:
|
||||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
dummy, fw_settings = self.get_fw_zone_settings()
|
||||||
forward_list = fw_settings.getForwardPorts()
|
return fw_settings.queryForwardPort(port=port, protocol=proto, to_port=toport, to_addr=toaddr)
|
||||||
else:
|
return self.fw.queryForwardPort(port=port, protocol=proto, to_port=toport, to_addr=toaddr)
|
||||||
forward_list = self.fw.getForwardPorts(self.zone)
|
|
||||||
|
|
||||||
if forward_port in forward_list:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_enabled_permanent(self, port, proto, toport, toaddr, timeout):
|
def get_enabled_permanent(self, port, proto, toport, toaddr, timeout):
|
||||||
forward_port = (port, proto, toport, toaddr)
|
dummy, fw_settings = self.get_fw_zone_settings()
|
||||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
return fw_settings.queryForwardPort(port=port, protocol=proto, to_port=toport, to_addr=toaddr)
|
||||||
|
|
||||||
if forward_port in fw_settings.getForwardPorts():
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def set_enabled_immediate(self, port, proto, toport, toaddr, timeout):
|
def set_enabled_immediate(self, port, proto, toport, toaddr, timeout):
|
||||||
self.fw.addForwardPort(self.zone, port, proto, toport, toaddr, timeout)
|
self.fw.addForwardPort(self.zone, port, proto, toport, toaddr, timeout)
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,13 @@ options:
|
||||||
boot:
|
boot:
|
||||||
description:
|
description:
|
||||||
- Determines if the filesystem should be mounted on boot.
|
- 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
|
type: bool
|
||||||
default: yes
|
default: yes
|
||||||
backup:
|
backup:
|
||||||
|
|
@ -169,6 +175,15 @@ EXAMPLES = r'''
|
||||||
opts: rw,sync,hard,intr
|
opts: rw,sync,hard,intr
|
||||||
state: mounted
|
state: mounted
|
||||||
fstype: nfs
|
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
|
import errno
|
||||||
|
|
@ -231,7 +246,7 @@ def _set_mount_save_old(module, args):
|
||||||
old_lines = []
|
old_lines = []
|
||||||
exists = False
|
exists = False
|
||||||
changed = 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'
|
new_line = '%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s\n'
|
||||||
|
|
||||||
if platform.system() == 'SunOS':
|
if platform.system() == 'SunOS':
|
||||||
|
|
@ -677,7 +692,8 @@ def main():
|
||||||
opts='-',
|
opts='-',
|
||||||
passno='-',
|
passno='-',
|
||||||
fstab=module.params['fstab'],
|
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:
|
if args['fstab'] is None:
|
||||||
args['fstab'] = '/etc/vfstab'
|
args['fstab'] = '/etc/vfstab'
|
||||||
|
|
@ -687,7 +703,9 @@ def main():
|
||||||
opts='defaults',
|
opts='defaults',
|
||||||
dump='0',
|
dump='0',
|
||||||
passno='0',
|
passno='0',
|
||||||
fstab=module.params['fstab']
|
fstab=module.params['fstab'],
|
||||||
|
boot='yes',
|
||||||
|
warnings=[]
|
||||||
)
|
)
|
||||||
if args['fstab'] is None:
|
if args['fstab'] is None:
|
||||||
args['fstab'] = '/etc/fstab'
|
args['fstab'] = '/etc/fstab'
|
||||||
|
|
@ -705,14 +723,27 @@ def main():
|
||||||
linux_mounts = get_linux_mounts(module)
|
linux_mounts = get_linux_mounts(module)
|
||||||
|
|
||||||
if linux_mounts is None:
|
if linux_mounts is None:
|
||||||
args['warnings'] = (
|
args['warnings'].append('Cannot open file /proc/self/mountinfo.'
|
||||||
'Cannot open file /proc/self/mountinfo. '
|
|
||||||
' Bind mounts might be misinterpreted.')
|
' Bind mounts might be misinterpreted.')
|
||||||
|
|
||||||
# Override defaults with user specified params
|
# Override defaults with user specified params
|
||||||
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
|
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
|
||||||
if module.params[key] is not None:
|
if module.params[key] is not None:
|
||||||
args[key] = module.params[key]
|
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
|
# If fstab file does not exist, we first need to create it. This mainly
|
||||||
# happens when fstab option is passed to the module.
|
# happens when fstab option is passed to the module.
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,9 @@ options:
|
||||||
default: no
|
default: no
|
||||||
delete:
|
delete:
|
||||||
description:
|
description:
|
||||||
- Delete files in C(dest) that don't exist (after transfer, not before) in the C(src) path.
|
- Delete files in I(dest) that do not exist (after transfer, not before) in the I(src) path.
|
||||||
- This option requires C(recursive=yes).
|
- This option requires I(recursive=yes).
|
||||||
- This option ignores excluded files and behaves like the rsync opt --delete-excluded.
|
- This option ignores excluded files and behaves like the rsync opt C(--delete-after).
|
||||||
type: bool
|
type: bool
|
||||||
default: no
|
default: no
|
||||||
dirs:
|
dirs:
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@ class ShellModule(ShellBase):
|
||||||
# Family of shells this has. Must match the filename without extension
|
# Family of shells this has. Must match the filename without extension
|
||||||
SHELL_FAMILY = 'csh'
|
SHELL_FAMILY = 'csh'
|
||||||
|
|
||||||
|
# commonly used
|
||||||
|
ECHO = 'echo'
|
||||||
|
COMMAND_SEP = ';'
|
||||||
|
|
||||||
# How to end lines in a python script one-liner
|
# How to end lines in a python script one-liner
|
||||||
_SHELL_EMBEDDED_PY_EOL = '\\\n'
|
_SHELL_EMBEDDED_PY_EOL = '\\\n'
|
||||||
_SHELL_REDIRECT_ALLNULL = '>& /dev/null'
|
_SHELL_REDIRECT_ALLNULL = '>& /dev/null'
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,6 @@
|
||||||
# Test playbook for the firewalld module
|
# Test playbook for the firewalld module
|
||||||
# (c) 2017, Adam Miller <admiller@redhat.com>
|
# (c) 2017, Adam Miller <admiller@redhat.com>
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
- name: Run firewalld tests
|
- name: Run firewalld tests
|
||||||
block:
|
block:
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,6 @@
|
||||||
# Test playbook for the firewalld module - port operations
|
# Test playbook for the firewalld module - port operations
|
||||||
# (c) 2017, Adam Miller <admiller@redhat.com>
|
# (c) 2017, Adam Miller <admiller@redhat.com>
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
- name: firewalld port forward test permanent enabled
|
- name: firewalld port forward test permanent enabled
|
||||||
firewalld:
|
firewalld:
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,63 @@
|
||||||
# Test playbook for the firewalld module - port operations
|
# Test playbook for the firewalld module - port operations
|
||||||
# (c) 2017, Adam Miller <admiller@redhat.com>
|
# (c) 2017, Adam Miller <admiller@redhat.com>
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
# This file is part of Ansible
|
- name: firewalld port range test permanent enabled
|
||||||
#
|
firewalld:
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
port: 5500-6950/tcp
|
||||||
# it under the terms of the GNU General Public License as published by
|
permanent: true
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
state: enabled
|
||||||
# (at your option) any later version.
|
register: result
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
- name: assert firewalld port range test permanent enabled worked
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
assert:
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
that:
|
||||||
# GNU General Public License for more details.
|
- result is changed
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
- name: firewalld port range test permanent enabled rerun (verify not changed)
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
firewalld:
|
||||||
|
port: 5500-6950/tcp
|
||||||
|
permanent: true
|
||||||
|
state: enabled
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: assert firewalld port range test permanent enabled rerun worked (verify not changed)
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is not changed
|
||||||
|
|
||||||
|
- name: firewalld port test permanent enabled
|
||||||
|
firewalld:
|
||||||
|
port: 6900/tcp
|
||||||
|
permanent: true
|
||||||
|
state: enabled
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: assert firewalld port test permanent enabled worked
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is changed
|
||||||
|
|
||||||
|
- name: firewalld port test permanent enabled
|
||||||
|
firewalld:
|
||||||
|
port: 6900/tcp
|
||||||
|
permanent: true
|
||||||
|
state: enabled
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: assert firewalld port test permanent enabled worked
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- result is not changed
|
||||||
|
|
||||||
|
- name: firewalld port test disabled
|
||||||
|
firewalld:
|
||||||
|
port: "{{ item }}"
|
||||||
|
permanent: true
|
||||||
|
state: disabled
|
||||||
|
loop:
|
||||||
|
- 6900/tcp
|
||||||
|
- 5500-6950/tcp
|
||||||
|
|
||||||
- name: firewalld port test permanent enabled
|
- name: firewalld port test permanent enabled
|
||||||
firewalld:
|
firewalld:
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,6 @@
|
||||||
# Test playbook for the firewalld module
|
# Test playbook for the firewalld module
|
||||||
# (c) 2017, Adam Miller <admiller@redhat.com>
|
# (c) 2017, Adam Miller <admiller@redhat.com>
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
# This file is part of Ansible
|
|
||||||
#
|
|
||||||
# Ansible is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# Ansible is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
- name: Ensure /run/firewalld exists
|
- name: Ensure /run/firewalld exists
|
||||||
file:
|
file:
|
||||||
|
|
@ -28,8 +14,6 @@
|
||||||
|
|
||||||
# firewalld port operation test cases
|
# firewalld port operation test cases
|
||||||
- include_tasks: port_test_cases.yml
|
- include_tasks: port_test_cases.yml
|
||||||
# Skipping on CentOS 8 due to https://github.com/ansible/ansible/issues/64750
|
|
||||||
when: not (ansible_facts.distribution == "CentOS" and ansible_distribution_major_version is version('8', '=='))
|
|
||||||
|
|
||||||
# firewalld source operation test cases
|
# firewalld source operation test cases
|
||||||
- import_tasks: source_test_cases.yml
|
- import_tasks: source_test_cases.yml
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,12 @@
|
||||||
file:
|
file:
|
||||||
state: directory
|
state: directory
|
||||||
path: '{{ output_dir }}/mount_dest'
|
path: '{{ output_dir }}/mount_dest'
|
||||||
|
|
||||||
- name: Create a directory to bind mount
|
- name: Create a directory to bind mount
|
||||||
file:
|
file:
|
||||||
state: directory
|
state: directory
|
||||||
path: '{{ output_dir }}/mount_source'
|
path: '{{ output_dir }}/mount_source'
|
||||||
|
|
||||||
- name: Put something in the directory so we see that it worked
|
- name: Put something in the directory so we see that it worked
|
||||||
copy:
|
copy:
|
||||||
content: 'Testing
|
content: 'Testing
|
||||||
|
|
@ -13,6 +15,7 @@
|
||||||
'
|
'
|
||||||
dest: '{{ output_dir }}/mount_source/test_file'
|
dest: '{{ output_dir }}/mount_source/test_file'
|
||||||
register: orig_info
|
register: orig_info
|
||||||
|
|
||||||
- name: Bind mount a filesystem (Linux)
|
- name: Bind mount a filesystem (Linux)
|
||||||
mount:
|
mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
|
|
@ -22,6 +25,7 @@
|
||||||
opts: bind
|
opts: bind
|
||||||
when: ansible_system == 'Linux'
|
when: ansible_system == 'Linux'
|
||||||
register: bind_result_linux
|
register: bind_result_linux
|
||||||
|
|
||||||
- name: Bind mount a filesystem (FreeBSD)
|
- name: Bind mount a filesystem (FreeBSD)
|
||||||
mount:
|
mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
|
|
@ -30,11 +34,13 @@
|
||||||
fstype: nullfs
|
fstype: nullfs
|
||||||
when: ansible_system == 'FreeBSD'
|
when: ansible_system == 'FreeBSD'
|
||||||
register: bind_result_freebsd
|
register: bind_result_freebsd
|
||||||
|
|
||||||
- name: get checksum for bind mounted file
|
- name: get checksum for bind mounted file
|
||||||
stat:
|
stat:
|
||||||
path: '{{ output_dir }}/mount_dest/test_file'
|
path: '{{ output_dir }}/mount_dest/test_file'
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
register: dest_stat
|
register: dest_stat
|
||||||
|
|
||||||
- name: assert the bind mount was successful
|
- name: assert the bind mount was successful
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
|
@ -42,6 +48,7 @@
|
||||||
- dest_stat['stat']['exists']
|
- dest_stat['stat']['exists']
|
||||||
- orig_info['checksum'] == dest_stat['stat']['checksum']
|
- orig_info['checksum'] == dest_stat['stat']['checksum']
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
|
|
||||||
- name: Bind mount a filesystem (Linux)
|
- name: Bind mount a filesystem (Linux)
|
||||||
mount:
|
mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
|
|
@ -51,6 +58,7 @@
|
||||||
opts: bind
|
opts: bind
|
||||||
when: ansible_system == 'Linux'
|
when: ansible_system == 'Linux'
|
||||||
register: bind_result_linux
|
register: bind_result_linux
|
||||||
|
|
||||||
- name: Bind mount a filesystem (FreeBSD)
|
- name: Bind mount a filesystem (FreeBSD)
|
||||||
mount:
|
mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
|
|
@ -59,11 +67,13 @@
|
||||||
fstype: nullfs
|
fstype: nullfs
|
||||||
when: ansible_system == 'FreeBSD'
|
when: ansible_system == 'FreeBSD'
|
||||||
register: bind_result_freebsd
|
register: bind_result_freebsd
|
||||||
|
|
||||||
- name: Make sure we didn't mount a second time
|
- name: Make sure we didn't mount a second time
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- (ansible_system == 'Linux' and not bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and not bind_result_freebsd['changed'])
|
- (ansible_system == 'Linux' and not bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and not bind_result_freebsd['changed'])
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
|
|
||||||
- name: Remount filesystem with different opts (Linux)
|
- name: Remount filesystem with different opts (Linux)
|
||||||
mount:
|
mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
|
|
@ -73,6 +83,7 @@
|
||||||
opts: bind,ro
|
opts: bind,ro
|
||||||
when: ansible_system == 'Linux'
|
when: ansible_system == 'Linux'
|
||||||
register: bind_result_linux
|
register: bind_result_linux
|
||||||
|
|
||||||
- name: Remount filesystem with different opts (FreeBSD)
|
- name: Remount filesystem with different opts (FreeBSD)
|
||||||
mount:
|
mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
|
|
@ -82,9 +93,11 @@
|
||||||
opts: ro
|
opts: ro
|
||||||
when: ansible_system == 'FreeBSD'
|
when: ansible_system == 'FreeBSD'
|
||||||
register: bind_result_freebsd
|
register: bind_result_freebsd
|
||||||
|
|
||||||
- name: Get mount options
|
- name: Get mount options
|
||||||
shell: mount | grep mount_dest | grep -E -w '(ro|read-only)' | wc -l
|
shell: mount | grep mount_dest | grep -E -w '(ro|read-only)' | wc -l
|
||||||
register: remount_options
|
register: remount_options
|
||||||
|
|
||||||
- name: Make sure the filesystem now has the new opts
|
- name: Make sure the filesystem now has the new opts
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
|
@ -92,17 +105,20 @@
|
||||||
- '''1'' in remount_options.stdout'
|
- '''1'' in remount_options.stdout'
|
||||||
- 1 == remount_options.stdout_lines | length
|
- 1 == remount_options.stdout_lines | length
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
|
|
||||||
- name: Unmount the bind mount
|
- name: Unmount the bind mount
|
||||||
mount:
|
mount:
|
||||||
name: '{{ output_dir }}/mount_dest'
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: absent
|
state: absent
|
||||||
when: ansible_system in ('Linux', 'FreeBSD')
|
when: ansible_system in ('Linux', 'FreeBSD')
|
||||||
register: unmount_result
|
register: unmount_result
|
||||||
|
|
||||||
- name: Make sure the file no longer exists in dest
|
- name: Make sure the file no longer exists in dest
|
||||||
stat:
|
stat:
|
||||||
path: '{{ output_dir }}/mount_dest/test_file'
|
path: '{{ output_dir }}/mount_dest/test_file'
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
register: dest_stat
|
register: dest_stat
|
||||||
|
|
||||||
- name: Check that we unmounted
|
- name: Check that we unmounted
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
|
@ -216,6 +232,7 @@
|
||||||
community.general.system.filesystem:
|
community.general.system.filesystem:
|
||||||
fstype: ext3
|
fstype: ext3
|
||||||
dev: /tmp/myfs.img
|
dev: /tmp/myfs.img
|
||||||
|
|
||||||
- name: Mount the FS for the first time
|
- name: Mount the FS for the first time
|
||||||
mount:
|
mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
|
|
@ -279,3 +296,44 @@
|
||||||
- /tmp/myfs.img
|
- /tmp/myfs.img
|
||||||
- /tmp/myfs
|
- /tmp/myfs
|
||||||
when: ansible_system in ('Linux')
|
when: ansible_system in ('Linux')
|
||||||
|
|
||||||
|
- name: Block to test boot option for Linux
|
||||||
|
block:
|
||||||
|
- name: Create empty file
|
||||||
|
community.general.filesize:
|
||||||
|
path: /tmp/myfs.img
|
||||||
|
size: 20M
|
||||||
|
|
||||||
|
- name: Format FS
|
||||||
|
community.general.filesystem:
|
||||||
|
fstype: ext3
|
||||||
|
dev: /tmp/myfs.img
|
||||||
|
|
||||||
|
- name: Mount the FS with noauto option
|
||||||
|
mount:
|
||||||
|
path: /tmp/myfs
|
||||||
|
src: /tmp/myfs.img
|
||||||
|
fstype: ext3
|
||||||
|
state: mounted
|
||||||
|
boot: no
|
||||||
|
opts: rw,user,async
|
||||||
|
register: mount_info
|
||||||
|
|
||||||
|
- name: assert the mount without noauto was successful
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- mount_info['opts'] == 'rw,user,async,noauto'
|
||||||
|
|
||||||
|
- name: Unmount FS
|
||||||
|
mount:
|
||||||
|
path: /tmp/myfs
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Remove the test FS
|
||||||
|
file:
|
||||||
|
path: '{{ item }}'
|
||||||
|
state: absent
|
||||||
|
loop:
|
||||||
|
- /tmp/myfs.img
|
||||||
|
- /tmp/myfs
|
||||||
|
when: ansible_system in ('Linux')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue