mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 07:05:27 +01:00
refactor to comply with current ansible-lint and sanity guidelines
Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
parent
05ee6ebc2a
commit
a85f736f6a
68 changed files with 2640 additions and 2407 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
trigger:
|
trigger:
|
||||||
batch: true
|
batch: true
|
||||||
branches:
|
branches:
|
||||||
|
|
@ -13,7 +14,7 @@ pr:
|
||||||
- stable-*
|
- stable-*
|
||||||
|
|
||||||
schedules:
|
schedules:
|
||||||
- cron: 0 9 * * *
|
- cron: "0 9 * * *"
|
||||||
displayName: Nightly
|
displayName: Nightly
|
||||||
always: true
|
always: true
|
||||||
branches:
|
branches:
|
||||||
|
|
@ -41,7 +42,6 @@ resources:
|
||||||
pool: Standard
|
pool: Standard
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
|
||||||
- stage: Sanity_devel
|
- stage: Sanity_devel
|
||||||
displayName: Ansible devel sanity
|
displayName: Ansible devel sanity
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
|
|
@ -49,14 +49,14 @@ stages:
|
||||||
- template: templates/matrix.yml
|
- template: templates/matrix.yml
|
||||||
parameters:
|
parameters:
|
||||||
nameFormat: "{0}"
|
nameFormat: "{0}"
|
||||||
testFormat: "devel/{0}"
|
testFormat: devel/{0}
|
||||||
targets:
|
targets:
|
||||||
- name: Sanity
|
- name: Sanity
|
||||||
test: sanity
|
test: sanity
|
||||||
- name: Units
|
- name: Units
|
||||||
test: units
|
test: units
|
||||||
# - name: Lint
|
- name: Lint
|
||||||
# test: lint
|
test: lint
|
||||||
- stage: Sanity_2_16
|
- stage: Sanity_2_16
|
||||||
displayName: Ansible 2.16 sanity
|
displayName: Ansible 2.16 sanity
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
|
|
@ -64,12 +64,14 @@ stages:
|
||||||
- template: templates/matrix.yml
|
- template: templates/matrix.yml
|
||||||
parameters:
|
parameters:
|
||||||
nameFormat: "{0}"
|
nameFormat: "{0}"
|
||||||
testFormat: "2.16/{0}"
|
testFormat: 2.16/{0}
|
||||||
targets:
|
targets:
|
||||||
- name: Sanity
|
- name: Sanity
|
||||||
test: sanity
|
test: sanity
|
||||||
- name: Units
|
- name: Units
|
||||||
test: units
|
test: units
|
||||||
|
- name: Lint
|
||||||
|
test: lint
|
||||||
- stage: Sanity_2_15
|
- stage: Sanity_2_15
|
||||||
displayName: Ansible 2.15 sanity
|
displayName: Ansible 2.15 sanity
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
|
|
@ -77,7 +79,7 @@ stages:
|
||||||
- template: templates/matrix.yml
|
- template: templates/matrix.yml
|
||||||
parameters:
|
parameters:
|
||||||
nameFormat: "{0}"
|
nameFormat: "{0}"
|
||||||
testFormat: "2.15/{0}"
|
testFormat: 2.15/{0}
|
||||||
targets:
|
targets:
|
||||||
- name: Sanity
|
- name: Sanity
|
||||||
test: sanity
|
test: sanity
|
||||||
|
|
@ -90,20 +92,7 @@ stages:
|
||||||
- template: templates/matrix.yml
|
- template: templates/matrix.yml
|
||||||
parameters:
|
parameters:
|
||||||
nameFormat: "{0}"
|
nameFormat: "{0}"
|
||||||
testFormat: "2.14/{0}"
|
testFormat: 2.14/{0}
|
||||||
targets:
|
|
||||||
- name: Sanity
|
|
||||||
test: sanity
|
|
||||||
- name: Units
|
|
||||||
test: units
|
|
||||||
- stage: Sanity_2_9
|
|
||||||
displayName: Ansible 2.9 sanity
|
|
||||||
dependsOn: []
|
|
||||||
jobs:
|
|
||||||
- template: templates/matrix.yml
|
|
||||||
parameters:
|
|
||||||
nameFormat: "{0}"
|
|
||||||
testFormat: "2.9/{0}"
|
|
||||||
targets:
|
targets:
|
||||||
- name: Sanity
|
- name: Sanity
|
||||||
test: sanity
|
test: sanity
|
||||||
|
|
@ -177,26 +166,6 @@ stages:
|
||||||
test: ubuntu2004
|
test: ubuntu2004
|
||||||
- name: Ubuntu 22.04
|
- name: Ubuntu 22.04
|
||||||
test: ubuntu2204
|
test: ubuntu2204
|
||||||
- stage: Docker_2_9
|
|
||||||
displayName: Docker 2.9
|
|
||||||
dependsOn: []
|
|
||||||
jobs:
|
|
||||||
- template: templates/matrix.yml
|
|
||||||
parameters:
|
|
||||||
testFormat: 2.9/linux/{0}/1
|
|
||||||
targets:
|
|
||||||
- name: CentOS 6
|
|
||||||
test: centos6
|
|
||||||
- name: CentOS 7
|
|
||||||
test: centos7
|
|
||||||
- name: openSUSE 15 py2
|
|
||||||
test: opensuse15py2
|
|
||||||
- name: openSUSE 15 py3
|
|
||||||
test: opensuse15
|
|
||||||
- name: Ubuntu 16.04
|
|
||||||
test: ubuntu1604
|
|
||||||
- name: Ubuntu 18.04
|
|
||||||
test: ubuntu1804
|
|
||||||
|
|
||||||
## Remote
|
## Remote
|
||||||
- stage: Remote_devel
|
- stage: Remote_devel
|
||||||
|
|
@ -260,27 +229,12 @@ stages:
|
||||||
test: freebsd/13.1
|
test: freebsd/13.1
|
||||||
- name: FreeBSD 12.4
|
- name: FreeBSD 12.4
|
||||||
test: freebsd/12.4
|
test: freebsd/12.4
|
||||||
- stage: Remote_2_9
|
|
||||||
displayName: Remote 2.9
|
|
||||||
dependsOn: []
|
|
||||||
jobs:
|
|
||||||
- template: templates/matrix.yml
|
|
||||||
parameters:
|
|
||||||
testFormat: 2.9/{0}/1
|
|
||||||
targets:
|
|
||||||
- name: RHEL 7.9
|
|
||||||
test: rhel/7.9
|
|
||||||
- name: RHEL 8.1
|
|
||||||
test: rhel/8.1
|
|
||||||
|
|
||||||
## Finally
|
## Finally
|
||||||
|
|
||||||
- stage: Summary
|
- stage: Summary
|
||||||
condition: succeededOrFailed()
|
condition: succeededOrFailed()
|
||||||
dependsOn:
|
dependsOn:
|
||||||
- Sanity_2_9
|
|
||||||
- Remote_2_9
|
|
||||||
- Docker_2_9
|
|
||||||
- Sanity_2_14
|
- Sanity_2_14
|
||||||
- Remote_2_14
|
- Remote_2_14
|
||||||
- Docker_2_14
|
- Docker_2_14
|
||||||
|
|
|
||||||
1
.github/BOTMETA.yml
vendored
1
.github/BOTMETA.yml
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
automerge: false
|
automerge: false
|
||||||
files:
|
files:
|
||||||
$module_utils/mount.py:
|
$module_utils/mount.py:
|
||||||
|
|
|
||||||
20
README.md
20
README.md
|
|
@ -11,13 +11,7 @@ An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and de
|
||||||
<!--start requires_ansible-->
|
<!--start requires_ansible-->
|
||||||
## Ansible version compatibility
|
## Ansible version compatibility
|
||||||
|
|
||||||
This collection has been tested against following Ansible versions: **>=2.9**.
|
This collection has been tested against following Ansible versions: **>=2.14**.
|
||||||
|
|
||||||
For collections that support Ansible 2.9, please ensure you update your `network_os` to use the
|
|
||||||
fully qualified collection name (for example, `cisco.ios.ios`).
|
|
||||||
Plugins and modules within a collection may be tested with only specific Ansible versions.
|
|
||||||
A collection may contain metadata that identifies these versions.
|
|
||||||
PEP440 is the schema used to describe the versions of Ansible.
|
|
||||||
<!--end requires_ansible-->
|
<!--end requires_ansible-->
|
||||||
|
|
||||||
## Included content
|
## Included content
|
||||||
|
|
@ -63,8 +57,6 @@ collections:
|
||||||
|
|
||||||
See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details.
|
See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details.
|
||||||
|
|
||||||
**NOTE**: For Ansible 2.9, you may not see deprecation warnings when you run your playbooks with this collection. Use this documentation to track when a module is deprecated.
|
|
||||||
|
|
||||||
## Contributing to this collection
|
## Contributing to this collection
|
||||||
|
|
||||||
<!--Describe how the community can contribute to your collection. At a minimum, include how and where users can create issues to report problems or request features for this collection. List contribution requirements, including preferred workflows and necessary testing, so you can benefit from community PRs. If you are following general Ansible contributor guidelines, you can link to - [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html). -->
|
<!--Describe how the community can contribute to your collection. At a minimum, include how and where users can create issues to report problems or request features for this collection. List contribution requirements, including preferred workflows and necessary testing, so you can benefit from community PRs. If you are following general Ansible contributor guidelines, you can link to - [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html). -->
|
||||||
|
|
@ -91,12 +83,10 @@ None
|
||||||
|
|
||||||
<!-- List the versions of Ansible the collection has been tested with. Must match what is in galaxy.yml. -->
|
<!-- List the versions of Ansible the collection has been tested with. Must match what is in galaxy.yml. -->
|
||||||
|
|
||||||
- ansible-core 2.14 (devel)
|
- ansible-core 2.17 (devel)
|
||||||
- ansible-core 2.13 (stable)
|
- ansible-core 2.16 (stable)
|
||||||
- ansible-core 2.12 (stable)
|
- ansible-core 2.15 (stable)
|
||||||
- ansible-core 2.11 (stable)
|
- ansible-core 2.14 (stable)
|
||||||
- ansible-base 2.10 (stable)
|
|
||||||
- ansible 2.9 (stable)
|
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
|
|
|
||||||
2
changelogs/fragments/dropping-ansible29.yml
Normal file
2
changelogs/fragments/dropping-ansible29.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
major_changes:
|
||||||
|
- "Dropping support for Ansible 2.9, ansible-core 2.14 will be minimum required version for this release"
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
---
|
||||||
comment: false
|
comment: false
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
namespace: ansible
|
namespace: ansible
|
||||||
name: posix
|
name: posix
|
||||||
version: 1.5.4
|
version: 1.5.4
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
---
|
---
|
||||||
requires_ansible: '>=2.9'
|
requires_ansible: ">=2.14.0"
|
||||||
plugin_routing:
|
plugin_routing:
|
||||||
callback:
|
callback:
|
||||||
skippy:
|
skippy:
|
||||||
deprecation:
|
deprecation:
|
||||||
removal_date: '2022-06-01'
|
removal_date: "2022-06-01"
|
||||||
warning_text: See the plugin documentation for more details
|
warning_text: See the plugin documentation for more details
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ class ActionModule(ActionBase):
|
||||||
|
|
||||||
# Store remote connection type
|
# Store remote connection type
|
||||||
self._remote_transport = self._connection.transport
|
self._remote_transport = self._connection.transport
|
||||||
use_ssh_args = _tmp_args.pop('use_ssh_args', None)
|
use_ssh_args = _tmp_args.pop('use_ssh_args', False)
|
||||||
|
|
||||||
if use_ssh_args and self._connection.transport == 'ssh':
|
if use_ssh_args and self._connection.transport == 'ssh':
|
||||||
ssh_args = [
|
ssh_args = [
|
||||||
|
|
@ -185,7 +185,7 @@ class ActionModule(ActionBase):
|
||||||
self._connection.get_option('ssh_common_args'),
|
self._connection.get_option('ssh_common_args'),
|
||||||
self._connection.get_option('ssh_extra_args'),
|
self._connection.get_option('ssh_extra_args'),
|
||||||
]
|
]
|
||||||
_tmp_args['ssh_args'] = ' '.join([a for a in ssh_args if a])
|
_tmp_args['_ssh_args'] = ' '.join([a for a in ssh_args if a])
|
||||||
|
|
||||||
# Handle docker connection options
|
# Handle docker connection options
|
||||||
if self._remote_transport in DOCKER:
|
if self._remote_transport in DOCKER:
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ options:
|
||||||
description:
|
description:
|
||||||
- Path on the source host that will be synchronized to the destination.
|
- Path on the source host that will be synchronized to the destination.
|
||||||
- The path can be absolute or relative.
|
- The path can be absolute or relative.
|
||||||
type: str
|
type: path
|
||||||
required: true
|
required: true
|
||||||
dest:
|
dest:
|
||||||
description:
|
description:
|
||||||
- Path on the destination host that will be synchronized from the source.
|
- Path on the destination host that will be synchronized from the source.
|
||||||
- The path can be absolute or relative.
|
- The path can be absolute or relative.
|
||||||
type: str
|
type: path
|
||||||
required: true
|
required: true
|
||||||
dest_port:
|
dest_port:
|
||||||
description:
|
description:
|
||||||
|
|
@ -135,13 +135,6 @@ options:
|
||||||
that does not match the inventory user, you should set this parameter to C(false).
|
that does not match the inventory user, you should set this parameter to C(false).
|
||||||
type: bool
|
type: bool
|
||||||
default: true
|
default: true
|
||||||
use_ssh_args:
|
|
||||||
description:
|
|
||||||
- In Ansible 2.10 and lower, it uses the ssh_args specified in C(ansible.cfg).
|
|
||||||
- In Ansible 2.11 and onwards, when set to C(true), it uses all SSH connection configurations like
|
|
||||||
C(ansible_ssh_args), C(ansible_ssh_common_args), and C(ansible_ssh_extra_args).
|
|
||||||
type: bool
|
|
||||||
default: false
|
|
||||||
ssh_connection_multiplexing:
|
ssh_connection_multiplexing:
|
||||||
description:
|
description:
|
||||||
- SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections.
|
- SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections.
|
||||||
|
|
@ -157,7 +150,7 @@ options:
|
||||||
- Specify additional rsync options by passing in an array.
|
- Specify additional rsync options by passing in an array.
|
||||||
- Note that an empty string in C(rsync_opts) will end up transfer the current working directory.
|
- Note that an empty string in C(rsync_opts) will end up transfer the current working directory.
|
||||||
type: list
|
type: list
|
||||||
default:
|
default: []
|
||||||
elements: str
|
elements: str
|
||||||
partial:
|
partial:
|
||||||
description:
|
description:
|
||||||
|
|
@ -178,7 +171,7 @@ options:
|
||||||
- Add a destination to hard link against during the rsync.
|
- Add a destination to hard link against during the rsync.
|
||||||
type: list
|
type: list
|
||||||
default:
|
default:
|
||||||
elements: str
|
elements: path
|
||||||
delay_updates:
|
delay_updates:
|
||||||
description:
|
description:
|
||||||
- This option puts the temporary file from each updated file into a holding directory until the end of the transfer,
|
- This option puts the temporary file from each updated file into a holding directory until the end of the transfer,
|
||||||
|
|
@ -186,6 +179,30 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
default: true
|
default: true
|
||||||
version_added: '1.3.0'
|
version_added: '1.3.0'
|
||||||
|
use_ssh_args:
|
||||||
|
description:
|
||||||
|
- In Ansible 2.10 and lower, it uses the ssh_args specified in C(ansible.cfg).
|
||||||
|
- In Ansible 2.11 and onwards, when set to C(true), it uses all SSH connection configurations like
|
||||||
|
C(ansible_ssh_args), C(ansible_ssh_common_args), and C(ansible_ssh_extra_args).
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
_local_rsync_path:
|
||||||
|
description: Internal use only.
|
||||||
|
type: path
|
||||||
|
default: 'rsync'
|
||||||
|
required: false
|
||||||
|
_local_rsync_password:
|
||||||
|
description: Internal use only, never logged.
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
_substitute_controller:
|
||||||
|
description: Internal use only.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
_ssh_args:
|
||||||
|
description: Internal use only. See C(use_ssh_args) for ssh arg settings.
|
||||||
|
type: str
|
||||||
|
required: false
|
||||||
|
|
||||||
notes:
|
notes:
|
||||||
- rsync must be installed on both the local and remote host.
|
- rsync must be installed on both the local and remote host.
|
||||||
|
|
@ -362,11 +379,11 @@ def substitute_controller(path):
|
||||||
if not client_addr:
|
if not client_addr:
|
||||||
ssh_env_string = os.environ.get('SSH_CLIENT', None)
|
ssh_env_string = os.environ.get('SSH_CLIENT', None)
|
||||||
try:
|
try:
|
||||||
client_addr, _ = ssh_env_string.split(None, 1)
|
client_addr, _ = ssh_env_string.split(None, 1) # pylint: disable=disallowed-name
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
ssh_env_string = os.environ.get('SSH_CONNECTION', None)
|
ssh_env_string = os.environ.get('SSH_CONNECTION', None)
|
||||||
try:
|
try:
|
||||||
client_addr, _ = ssh_env_string.split(None, 1)
|
client_addr, _ = ssh_env_string.split(None, 1) # pylint: disable=disallowed-name
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
if not client_addr:
|
if not client_addr:
|
||||||
|
|
@ -388,8 +405,8 @@ def is_rsh_needed(source, dest):
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
src=dict(type='str', required=True),
|
src=dict(type='path', required=True),
|
||||||
dest=dict(type='str', required=True),
|
dest=dict(type='path', required=True),
|
||||||
dest_port=dict(type='int'),
|
dest_port=dict(type='int'),
|
||||||
delete=dict(type='bool', default=False),
|
delete=dict(type='bool', default=False),
|
||||||
private_key=dict(type='path'),
|
private_key=dict(type='path'),
|
||||||
|
|
@ -412,13 +429,14 @@ def main():
|
||||||
set_remote_user=dict(type='bool', default=True),
|
set_remote_user=dict(type='bool', default=True),
|
||||||
rsync_timeout=dict(type='int', default=0),
|
rsync_timeout=dict(type='int', default=0),
|
||||||
rsync_opts=dict(type='list', default=[], elements='str'),
|
rsync_opts=dict(type='list', default=[], elements='str'),
|
||||||
ssh_args=dict(type='str'),
|
_ssh_args=dict(type='str'),
|
||||||
|
use_ssh_args=dict(type='bool', default=False),
|
||||||
ssh_connection_multiplexing=dict(type='bool', default=False),
|
ssh_connection_multiplexing=dict(type='bool', default=False),
|
||||||
partial=dict(type='bool', default=False),
|
partial=dict(type='bool', default=False),
|
||||||
verify_host=dict(type='bool', default=False),
|
verify_host=dict(type='bool', default=False),
|
||||||
delay_updates=dict(type='bool', default=True),
|
delay_updates=dict(type='bool', default=True),
|
||||||
mode=dict(type='str', default='push', choices=['pull', 'push']),
|
mode=dict(type='str', default='push', choices=['pull', 'push']),
|
||||||
link_dest=dict(type='list', elements='str'),
|
link_dest=dict(type='list', elements='path'),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
@ -454,7 +472,7 @@ def main():
|
||||||
owner = module.params['owner']
|
owner = module.params['owner']
|
||||||
group = module.params['group']
|
group = module.params['group']
|
||||||
rsync_opts = module.params['rsync_opts']
|
rsync_opts = module.params['rsync_opts']
|
||||||
ssh_args = module.params['ssh_args']
|
ssh_args = module.params['_ssh_args']
|
||||||
ssh_connection_multiplexing = module.params['ssh_connection_multiplexing']
|
ssh_connection_multiplexing = module.params['ssh_connection_multiplexing']
|
||||||
verify_host = module.params['verify_host']
|
verify_host = module.params['verify_host']
|
||||||
link_dest = module.params['link_dest']
|
link_dest = module.params['link_dest']
|
||||||
|
|
@ -572,7 +590,7 @@ def main():
|
||||||
# hardlink is actually a change
|
# hardlink is actually a change
|
||||||
cmd.append('-vv')
|
cmd.append('-vv')
|
||||||
for x in link_dest:
|
for x in link_dest:
|
||||||
link_path = os.path.abspath(os.path.expanduser(x))
|
link_path = os.path.abspath(x)
|
||||||
destination_path = os.path.abspath(os.path.dirname(dest))
|
destination_path = os.path.abspath(os.path.dirname(dest))
|
||||||
if destination_path.find(link_path) == 0:
|
if destination_path.find(link_path) == 0:
|
||||||
module.fail_json(msg='Hardlinking into a subdirectory of the source would cause recursion. %s and %s' % (destination_path, dest))
|
module.fail_json(msg='Hardlinking into a subdirectory of the source would cause recursion. %s and %s' % (destination_path, dest))
|
||||||
|
|
@ -581,12 +599,6 @@ def main():
|
||||||
changed_marker = '<<CHANGED>>'
|
changed_marker = '<<CHANGED>>'
|
||||||
cmd.append('--out-format=%s' % shlex_quote(changed_marker + '%i %n%L'))
|
cmd.append('--out-format=%s' % shlex_quote(changed_marker + '%i %n%L'))
|
||||||
|
|
||||||
# expand the paths
|
|
||||||
if '@' not in source:
|
|
||||||
source = os.path.expanduser(source)
|
|
||||||
if '@' not in dest:
|
|
||||||
dest = os.path.expanduser(dest)
|
|
||||||
|
|
||||||
cmd.append(shlex_quote(source))
|
cmd.append(shlex_quote(source))
|
||||||
cmd.append(shlex_quote(dest))
|
cmd.append(shlex_quote(dest))
|
||||||
cmdstr = ' '.join(cmd)
|
cmdstr = ' '.join(cmd)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
language: python
|
language: python
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|
@ -56,7 +57,7 @@ matrix:
|
||||||
branches:
|
branches:
|
||||||
except:
|
except:
|
||||||
- "*-patch-*"
|
- "*-patch-*"
|
||||||
- "revert-*-*"
|
- revert-*-*
|
||||||
|
|
||||||
build:
|
build:
|
||||||
ci:
|
ci:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
|
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
|
||||||
|
|
||||||
# This file is part of Ansible
|
# This file is part of Ansible
|
||||||
|
|
@ -16,35 +17,38 @@
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: Create ansible user
|
- name: Create ansible user
|
||||||
user:
|
ansible.builtin.user:
|
||||||
name: "{{ test_user }}"
|
name: "{{ test_user }}"
|
||||||
|
|
||||||
- name: Create ansible group
|
- name: Create ansible group
|
||||||
group:
|
ansible.builtin.group:
|
||||||
name: "{{ test_group }}"
|
name: "{{ test_group }}"
|
||||||
|
|
||||||
- name: Clean up working directory and files
|
- name: Clean up working directory and files
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ output_dir }}"
|
path: "{{ output_dir }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create working directory
|
- name: Create working directory
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ output_dir }}"
|
path: "{{ output_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
- name: Create ansible file
|
- name: Create ansible file
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ test_file }}"
|
path: "{{ test_file }}"
|
||||||
state: touch
|
state: touch
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
- name: Create ansible dir
|
- name: Create ansible dir
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ test_dir }}"
|
path: "{{ test_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Grant ansible user read access to a file
|
- name: Grant ansible user read access to a file
|
||||||
acl:
|
ansible.posix.acl:
|
||||||
path: "{{ test_file }}"
|
path: "{{ test_file }}"
|
||||||
entity: "{{ test_user }}"
|
entity: "{{ test_user }}"
|
||||||
etype: user
|
etype: user
|
||||||
|
|
@ -52,12 +56,21 @@
|
||||||
state: present
|
state: present
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: Debug ansible.posix.acl output
|
||||||
shell: "getfacl {{ test_file | quote }}"
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ output }}"
|
||||||
|
|
||||||
|
- name: Get getfacl output
|
||||||
|
ansible.builtin.command: getfacl {{ test_file | quote }}
|
||||||
|
changed_when: false
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: Debug getfacl output
|
||||||
assert:
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ getfacl_output.stdout_lines }}"
|
||||||
|
|
||||||
|
- name: Verify Output
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is changed
|
- output is changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
|
|
@ -65,16 +78,25 @@
|
||||||
- "'user:{{ test_user }}:r--' in getfacl_output.stdout_lines"
|
- "'user:{{ test_user }}:r--' in getfacl_output.stdout_lines"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Obtain the acl for a specific file
|
- name: Obtain the acl for a specific file
|
||||||
acl:
|
ansible.posix.acl:
|
||||||
path: "{{ test_file }}"
|
path: "{{ test_file }}"
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: Debug ansible.posix.acl output
|
||||||
shell: "getfacl {{ test_file | quote }}"
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ output }}"
|
||||||
|
|
||||||
|
- name: Get getfacl output
|
||||||
|
ansible.builtin.command: getfacl {{ test_file | quote }}
|
||||||
|
changed_when: false
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: Debug getfacl output
|
||||||
assert:
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ getfacl_output.stdout_lines }}"
|
||||||
|
|
||||||
|
- name: Verify output
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is not changed
|
- output is not changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
|
|
@ -89,20 +111,22 @@
|
||||||
- "'mask::r--' in getfacl_output.stdout_lines"
|
- "'mask::r--' in getfacl_output.stdout_lines"
|
||||||
- "'other::r--' in getfacl_output.stdout_lines"
|
- "'other::r--' in getfacl_output.stdout_lines"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
#
|
||||||
- name: Removes the acl for ansible user on a specific file
|
- name: Removes the acl for ansible user on a specific file
|
||||||
acl:
|
ansible.posix.acl:
|
||||||
path: "{{ test_file }}"
|
path: "{{ test_file }}"
|
||||||
entity: "{{ test_user }}"
|
entity: "{{ test_user }}"
|
||||||
etype: user
|
etype: user
|
||||||
state: absent
|
state: absent
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: Get getfacl output
|
||||||
shell: "getfacl {{ test_file | quote }}"
|
ansible.builtin.command: getfacl {{ test_file | quote }}
|
||||||
|
changed_when: false
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: Verify output
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is changed
|
- output is changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
|
|
@ -110,21 +134,22 @@
|
||||||
- "'user:{{ test_user }}:r--' not in getfacl_output.stdout_lines"
|
- "'user:{{ test_user }}:r--' not in getfacl_output.stdout_lines"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Sets default acl for ansible user on ansible dir
|
- name: Sets default acl for ansible user on ansible dir
|
||||||
acl:
|
ansible.posix.acl:
|
||||||
path: "{{ test_dir }}"
|
path: "{{ test_dir }}"
|
||||||
entity: "{{ test_user }}"
|
entity: "{{ test_user }}"
|
||||||
etype: user
|
etype: user
|
||||||
permissions: rw
|
permissions: rw
|
||||||
default: yes
|
default: true
|
||||||
state: present
|
state: present
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: Get getfacl output
|
||||||
shell: "getfacl {{ test_dir | quote }}"
|
ansible.builtin.command: getfacl {{ test_dir | quote }}
|
||||||
|
changed_when: false
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: Verify output
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is changed
|
- output is changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
|
|
@ -132,22 +157,24 @@
|
||||||
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
shell: "setfacl -b {{ test_dir | quote }}"
|
ansible.builtin.command: setfacl -b {{ test_dir | quote }}
|
||||||
|
changed_when: false
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Same as previous but using entry shorthand
|
- name: Same as previous but using entry shorthand
|
||||||
acl:
|
ansible.posix.acl:
|
||||||
path: "{{ test_dir }}"
|
path: "{{ test_dir }}"
|
||||||
entry: "user:{{ test_user }}:rw-"
|
entry: user:{{ test_user }}:rw-
|
||||||
default: yes
|
default: true
|
||||||
state: present
|
state: present
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: Get getfacl output
|
||||||
shell: "getfacl {{ test_dir | quote }}"
|
ansible.builtin.command: getfacl {{ test_dir | quote }}
|
||||||
|
changed_when: false
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: Verify output
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is changed
|
- output is changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
|
|
@ -155,19 +182,20 @@
|
||||||
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Same as previous, to test idempotence
|
- name: Same as previous, to test idempotence
|
||||||
acl:
|
ansible.posix.acl:
|
||||||
path: "{{ test_dir }}"
|
path: "{{ test_dir }}"
|
||||||
entry: "user:{{ test_user }}:rw-"
|
entry: user:{{ test_user }}:rw-
|
||||||
default: yes
|
default: true
|
||||||
state: present
|
state: present
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: Get getfacl output
|
||||||
shell: "getfacl {{ test_dir | quote }}"
|
ansible.builtin.command: getfacl {{ test_dir | quote }}
|
||||||
|
changed_when: false
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: Verify output
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is not changed
|
- output is not changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
|
|
@ -175,32 +203,34 @@
|
||||||
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
shell: "setfacl -b {{ test_dir | quote }}"
|
ansible.builtin.command: setfacl -b {{ test_dir | quote }}
|
||||||
|
changed_when: false
|
||||||
##############################################################################
|
##############################################################################
|
||||||
- name: Set default acls
|
- name: Set default acls
|
||||||
acl:
|
ansible.posix.acl:
|
||||||
path: "{{ test_dir }}"
|
path: "{{ test_dir }}"
|
||||||
entry: "{{ item }}"
|
entry: "{{ item }}"
|
||||||
default: yes
|
default: true
|
||||||
state: present
|
state: present
|
||||||
with_items:
|
with_items:
|
||||||
- "user:{{ test_user }}:rw-"
|
- user:{{ test_user }}:rw-
|
||||||
- "group:{{ test_group }}:rw-"
|
- group:{{ test_group }}:rw-
|
||||||
|
|
||||||
- name: Remove default group test_user acl
|
- name: Remove default group test_user acl
|
||||||
acl:
|
ansible.posix.acl:
|
||||||
path: "{{ test_dir }}"
|
path: "{{ test_dir }}"
|
||||||
entry: "group:{{ test_group }}:rw-"
|
entry: group:{{ test_group }}:rw-
|
||||||
default: yes
|
default: true
|
||||||
state: absent
|
state: absent
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getfacl output
|
- name: Get getfacl output
|
||||||
shell: "getfacl {{ test_dir | quote }}"
|
ansible.builtin.command: getfacl {{ test_dir | quote }}
|
||||||
|
changed_when: false
|
||||||
register: getfacl_output
|
register: getfacl_output
|
||||||
|
|
||||||
- name: verify output
|
- name: Verify output
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is changed
|
- output is changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
|
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
|
||||||
|
|
||||||
# This file is part of Ansible
|
# This file is part of Ansible
|
||||||
|
|
@ -15,22 +16,21 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- block:
|
- name: Test ACL
|
||||||
|
|
||||||
- include_tasks: acl.yml
|
|
||||||
when: ansible_system == 'Linux' # TODO enable acls mount option on FreeBSD to test it there too
|
|
||||||
|
|
||||||
always:
|
|
||||||
- name: delete created directory and file
|
|
||||||
file:
|
|
||||||
path: '{{ item }}'
|
|
||||||
state: absent
|
|
||||||
with_items:
|
|
||||||
- '{{ test_dir }}'
|
|
||||||
- '{{ test_file }}'
|
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
test_user: ansible_user
|
test_user: ansible_user
|
||||||
test_group: ansible_group
|
test_group: ansible_group
|
||||||
test_file: '{{ output_dir }}/ansible file'
|
test_file: "{{ output_dir }}/ansible file"
|
||||||
test_dir: "{{ output_dir }}/ansible_dir/with some space"
|
test_dir: "{{ output_dir }}/ansible_dir/with some space"
|
||||||
|
block:
|
||||||
|
- name: Include tests task file
|
||||||
|
ansible.builtin.include_tasks: acl.yml
|
||||||
|
when: ansible_system == 'Linux' # TODO enable acls mount option on FreeBSD to test it there too
|
||||||
|
always:
|
||||||
|
- name: Delete created directory and file
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
with_items:
|
||||||
|
- "{{ test_dir }}"
|
||||||
|
- "{{ test_file }}"
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
---
|
||||||
dependencies:
|
dependencies:
|
||||||
- prepare_tests
|
- prepare_tests
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test code for the at module.
|
# Test code for the at module.
|
||||||
# (c) 2017, James Tanner <tanner.jc@gmail.com>
|
# (c) 2017, James Tanner <tanner.jc@gmail.com>
|
||||||
|
|
||||||
|
|
@ -16,20 +17,27 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- set_fact: output_dir_test={{output_dir}}/at
|
- name: Set output_dir_test fast
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
output_dir_test: "{{ output_dir }}/at"
|
||||||
|
|
||||||
- name: make sure our testing sub-directory does not exist
|
- name: Make sure our testing sub-directory does not exist
|
||||||
file: path="{{ output_dir_test }}" state=absent
|
ansible.builtin.file:
|
||||||
|
path: "{{ output_dir_test }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: create our testing sub-directory
|
- name: Create our testing sub-directory
|
||||||
file: path="{{ output_dir_test }}" state=directory
|
ansible.builtin.file:
|
||||||
|
path: "{{ output_dir_test }}"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
##
|
##
|
||||||
## at
|
## at
|
||||||
##
|
##
|
||||||
|
|
||||||
- name: define distros to attempt installing at on
|
- name: Define distros to attempt installing at on
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
package_distros:
|
package_distros:
|
||||||
- RedHat
|
- RedHat
|
||||||
- CentOS
|
- CentOS
|
||||||
|
|
@ -39,24 +47,26 @@
|
||||||
- Debian
|
- Debian
|
||||||
- openSUSE Leap
|
- openSUSE Leap
|
||||||
|
|
||||||
- name: ensure at is installed
|
- name: Ensure at is installed
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: at
|
name: at
|
||||||
state: present
|
state: present
|
||||||
when: ansible_distribution in package_distros
|
when: ansible_distribution in package_distros
|
||||||
|
|
||||||
- name: run the first example
|
- name: Run the first example
|
||||||
at:
|
ansible.posix.at:
|
||||||
command: "ls -d / > /dev/null"
|
command: ls -d / > /dev/null
|
||||||
count: 20
|
count: 20
|
||||||
units: minutes
|
units: minutes
|
||||||
register: at_test0
|
register: at_test0
|
||||||
- debug: var=at_test0
|
- name: Debug var=at_test0
|
||||||
- name: validate results
|
ansible.builtin.debug:
|
||||||
assert:
|
var: at_test0
|
||||||
|
- name: Validate results
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'at_test0.changed is defined'
|
- at_test0.changed is defined
|
||||||
- 'at_test0.count is defined'
|
- at_test0.count is defined
|
||||||
- 'at_test0.script_file is defined'
|
- at_test0.script_file is defined
|
||||||
- 'at_test0.state is defined'
|
- at_test0.state is defined
|
||||||
- 'at_test0.units is defined'
|
- at_test0.units is defined
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
dss_key_basic: ssh-dss DATA_BASIC root@testing
|
dss_key_basic: ssh-dss DATA_BASIC root@testing
|
||||||
dss_key_unquoted_option: idle-timeout=5m ssh-dss DATA_UNQUOTED_OPTION root@testing
|
dss_key_unquoted_option: idle-timeout=5m ssh-dss DATA_UNQUOTED_OPTION root@testing
|
||||||
dss_key_command: command="/bin/true" ssh-dss DATA_COMMAND root@testing
|
dss_key_command: command="/bin/true" ssh-dss DATA_COMMAND root@testing
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
---
|
||||||
dependencies:
|
dependencies:
|
||||||
- prepare_tests
|
- prepare_tests
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,37 @@
|
||||||
|
---
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# check mode
|
# check mode
|
||||||
|
|
||||||
- name: CHECK MODE | copy an existing file in place with comments
|
- name: CHECK MODE | copy an existing file in place with comments
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: existing_authorized_keys
|
src: existing_authorized_keys
|
||||||
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
|
mode: "0600"
|
||||||
|
|
||||||
- name: CHECK MODE | add key in check mode to validate return codes
|
- name: CHECK MODE | add key in check mode to validate return codes
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ multiple_key_different_order_2 }}"
|
key: "{{ multiple_key_different_order_2 }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
check_mode: True
|
check_mode: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: CHECK MODE | assert that authorized_keys return values are consistent
|
- name: CHECK MODE | assert that authorized_keys return values are consistent
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- '"user" in result'
|
- '"user" in result'
|
||||||
- '"key" in result'
|
- '"key" in result'
|
||||||
|
|
||||||
- name: CHECK MODE | recopy authorized_keys to ensure it was not changed
|
- name: CHECK MODE | recopy authorized_keys to ensure it was not changed
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: existing_authorized_keys
|
src: existing_authorized_keys
|
||||||
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
|
mode: "0600"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: CHECK MODE | assert that the authorized_keys file was not changed
|
- name: CHECK MODE | assert that the authorized_keys file was not changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == False'
|
- result.changed == False
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
|
---
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# comments
|
# comments
|
||||||
|
|
||||||
- name: Add rsa key with existing comment
|
- name: Add rsa key with existing comment
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ rsa_key_basic }}"
|
key: "{{ rsa_key_basic }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
@ -10,7 +11,7 @@
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Change the comment on an existing key
|
- name: Change the comment on an existing key
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ rsa_key_basic }}"
|
key: "{{ rsa_key_basic }}"
|
||||||
comment: user@acme.com
|
comment: user@acme.com
|
||||||
|
|
@ -18,18 +19,18 @@
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: get the file content
|
- name: Get the file content
|
||||||
shell: cat "{{ output_dir | expanduser }}/authorized_keys" | fgrep DATA_BASIC
|
ansible.builtin.command: fgrep DATA_BASIC "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
changed_when: no
|
changed_when: false
|
||||||
register: content
|
register: content
|
||||||
|
|
||||||
- name: Assert that comment on an existing key was changed
|
- name: Assert that comment on an existing key was changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'user@acme.com' in content.stdout"
|
- "'user@acme.com' in content.stdout"
|
||||||
|
|
||||||
- name: Set the same key with comment to ensure no changes are reported
|
- name: Set the same key with comment to ensure no changes are reported
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ rsa_key_basic }}"
|
key: "{{ rsa_key_basic }}"
|
||||||
comment: user@acme.com
|
comment: user@acme.com
|
||||||
|
|
@ -38,11 +39,12 @@
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert that no changes were made when running again
|
- name: Assert that no changes were made when running again
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- not result.changed
|
- not result.changed
|
||||||
|
|
||||||
- debug:
|
- name: Debug the result and content
|
||||||
|
ansible.builtin.debug:
|
||||||
var: "{{ item }}"
|
var: "{{ item }}"
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# test code for the authorized_key module
|
# test code for the authorized_key module
|
||||||
# - (c) 2014, James Cammarata <jcammarata@ansible.com>
|
# - (c) 2014, James Cammarata <jcammarata@ansible.com>
|
||||||
# - (c) 2021, Hideki Saito <saito@fgrep.org>
|
# - (c) 2021, Hideki Saito <saito@fgrep.org>
|
||||||
|
|
@ -17,16 +18,16 @@
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: Setup testing environment
|
- name: Setup testing environment
|
||||||
import_tasks: setup_steps.yml
|
ansible.builtin.import_tasks: setup_steps.yml
|
||||||
|
|
||||||
- name: Test for multiple keys handling
|
- name: Test for multiple keys handling
|
||||||
import_tasks: multiple_keys.yml
|
ansible.builtin.import_tasks: multiple_keys.yml
|
||||||
|
|
||||||
- name: Test for ssh-dss key handling
|
- name: Test for ssh-dss key handling
|
||||||
import_tasks: ssh_dss.yml
|
ansible.builtin.import_tasks: ssh_dss.yml
|
||||||
|
|
||||||
- name: Test for check mode
|
- name: Test for check mode
|
||||||
import_tasks: check_mode.yml
|
ansible.builtin.import_tasks: check_mode.yml
|
||||||
|
|
||||||
- name: Test for the management of comments with key
|
- name: Test for the management of comments with key
|
||||||
import_tasks: comments.yml
|
ansible.builtin.import_tasks: comments.yml
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,39 @@
|
||||||
|
---
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# multiple keys
|
# multiple keys
|
||||||
|
|
||||||
- name: add multiple keys
|
- name: Add multiple keys
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ multiple_key_base }}"
|
key: "{{ multiple_key_base }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == multiple_key_base'
|
- result.key == multiple_key_base
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: add multiple keys different order
|
- name: Add multiple keys different order
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ multiple_key_different_order }}"
|
key: "{{ multiple_key_different_order }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == multiple_key_different_order'
|
- result.key == multiple_key_different_order
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: add multiple keys exclusive
|
- name: Add multiple keys exclusive
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ multiple_key_exclusive }}"
|
key: "{{ multiple_key_exclusive }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
@ -40,42 +41,42 @@
|
||||||
exclusive: true
|
exclusive: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == multiple_key_exclusive'
|
- result.key == multiple_key_exclusive
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: add multiple keys in different calls
|
- name: Add multiple keys in different calls
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "ecdsa-sha2-nistp521 ECDSA_DATA 4@testing"
|
key: ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: add multiple keys in different calls
|
- name: Add multiple keys in different calls
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "ssh-rsa DATA_BASIC 1@testing"
|
key: ssh-rsa DATA_BASIC 1@testing
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: get the file content
|
- name: Get the file content
|
||||||
shell: cat "{{ output_dir | expanduser }}/authorized_keys"
|
ansible.builtin.command: /bin/cat "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
changed_when: no
|
changed_when: false
|
||||||
register: multiple_keys_at_a_time
|
register: multiple_keys_at_a_time
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == false'
|
- result.changed == false
|
||||||
- 'multiple_keys_at_a_time.stdout == multiple_key_exclusive.strip()'
|
- multiple_keys_at_a_time.stdout == multiple_key_exclusive.strip()
|
||||||
|
|
||||||
- name: add multiple keys comment
|
- name: Add multiple keys comment
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ multiple_keys_comments }}"
|
key: "{{ multiple_keys_comments }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
@ -83,14 +84,14 @@
|
||||||
exclusive: true
|
exclusive: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: get the file content
|
- name: Get the file content
|
||||||
shell: cat "{{ output_dir | expanduser }}/authorized_keys"
|
ansible.builtin.command: /bin/cat "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
changed_when: no
|
changed_when: false
|
||||||
register: multiple_keys_comments
|
register: multiple_keys_comments
|
||||||
|
|
||||||
- name: assert that the keys exist and comment only lines were not added
|
- name: Assert that the keys exist and comment only lines were not added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == False'
|
- result.changed == False
|
||||||
- 'multiple_keys_comments.stdout == multiple_key_exclusive.strip()'
|
- multiple_keys_comments.stdout == multiple_key_exclusive.strip()
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,40 @@
|
||||||
|
---
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# Setup steps
|
# Setup steps
|
||||||
- name: Clean up the working directory and files
|
- name: Clean up the working directory and files
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ output_dir }}'
|
path: "{{ output_dir }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create the working directory
|
- name: Create the working directory
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ output_dir }}'
|
path: "{{ output_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
mode: "0744"
|
||||||
|
|
||||||
- name: copy an existing file in place with comments
|
- name: Copy an existing file in place with comments
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: existing_authorized_keys
|
src: existing_authorized_keys
|
||||||
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
dest: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
|
mode: "0600"
|
||||||
|
|
||||||
- name: add multiple keys different order
|
- name: Add multiple keys different order
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ multiple_key_different_order_2 }}"
|
key: "{{ multiple_key_different_order_2 }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: get the file content
|
- name: Get the file content
|
||||||
shell: cat "{{ output_dir | expanduser }}/authorized_keys"
|
ansible.builtin.command: /bin/cat "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
changed_when: no
|
changed_when: false
|
||||||
register: multiple_keys_existing
|
register: multiple_keys_existing
|
||||||
|
|
||||||
- name: assert that the key was added and comments and ordering preserved
|
- name: Assert that the key was added and comments and ordering preserved
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- '"# I like candy" in multiple_keys_existing.stdout'
|
- '"# I like candy" in multiple_keys_existing.stdout'
|
||||||
- '"# I like candy" in multiple_keys_existing.stdout_lines[0]'
|
- '"# I like candy" in multiple_keys_existing.stdout_lines[0]'
|
||||||
- '"ssh-rsa DATA_BASIC 1@testing" in multiple_keys_existing.stdout'
|
- '"ssh-rsa DATA_BASIC 1@testing" in multiple_keys_existing.stdout'
|
||||||
|
|
@ -41,19 +44,20 @@
|
||||||
|
|
||||||
# start afresh
|
# start afresh
|
||||||
|
|
||||||
- name: remove file foo.txt
|
- name: Remove file foo.txt
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: touch the authorized_keys file
|
- name: Touch the authorized_keys file
|
||||||
file:
|
ansible.builtin.file:
|
||||||
dest: "{{ output_dir }}/authorized_keys"
|
dest: "{{ output_dir }}/authorized_keys"
|
||||||
state: touch
|
state: touch
|
||||||
|
mode: "0600"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the authorized_keys file was created
|
- name: Assert that the authorized_keys file was created
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.state == "file"'
|
- result.state == "file"
|
||||||
|
|
|
||||||
|
|
@ -1,241 +1,250 @@
|
||||||
|
---
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# basic ssh-dss key
|
# basic ssh-dss key
|
||||||
|
|
||||||
- name: add basic ssh-dss key
|
- name: Add basic ssh-dss key
|
||||||
authorized_key: user=root key="{{ dss_key_basic }}" state=present path="{{ output_dir | expanduser }}/authorized_keys"
|
ansible.posix.authorized_key:
|
||||||
|
user: root
|
||||||
|
key: "{{ dss_key_basic }}"
|
||||||
|
state: present
|
||||||
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == dss_key_basic'
|
- result.key == dss_key_basic
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: re-add basic ssh-dss key
|
- name: Re-add basic ssh-dss key
|
||||||
authorized_key: user=root key="{{ dss_key_basic }}" state=present path="{{ output_dir | expanduser }}/authorized_keys"
|
ansible.posix.authorized_key:
|
||||||
|
user: root
|
||||||
|
key: "{{ dss_key_basic }}"
|
||||||
|
state: present
|
||||||
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that nothing changed
|
- name: Assert that nothing changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == False'
|
- result.changed == False
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# ssh-dss key with an unquoted option
|
# ssh-dss key with an unquoted option
|
||||||
|
|
||||||
- name: add ssh-dss key with an unquoted option
|
- name: Add ssh-dss key with an unquoted option
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_unquoted_option }}"
|
key: "{{ dss_key_unquoted_option }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == dss_key_unquoted_option'
|
- result.key == dss_key_unquoted_option
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: re-add ssh-dss key with an unquoted option
|
- name: Re-add ssh-dss key with an unquoted option
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_unquoted_option }}"
|
key: "{{ dss_key_unquoted_option }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that nothing changed
|
- name: Assert that nothing changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == False'
|
- result.changed == False
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# ssh-dss key with a leading command="/bin/foo"
|
# ssh-dss key with a leading command="/bin/foo"
|
||||||
|
|
||||||
- name: add ssh-dss key with a leading command
|
- name: Add ssh-dss key with a leading command
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_command }}"
|
key: "{{ dss_key_command }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == dss_key_command'
|
- result.key == dss_key_command
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: re-add ssh-dss key with a leading command
|
- name: Re-add ssh-dss key with a leading command
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_command }}"
|
key: "{{ dss_key_command }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that nothing changed
|
- name: Assert that nothing changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == False'
|
- result.changed == False
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# ssh-dss key with a complex quoted leading command
|
# ssh-dss key with a complex quoted leading command
|
||||||
# ie. command="/bin/echo foo 'bar baz'"
|
# ie. command="/bin/echo foo 'bar baz'"
|
||||||
|
|
||||||
- name: add ssh-dss key with a complex quoted leading command
|
- name: Add ssh-dss key with a complex quoted leading command
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_complex_command }}"
|
key: "{{ dss_key_complex_command }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == dss_key_complex_command'
|
- result.key == dss_key_complex_command
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: re-add ssh-dss key with a complex quoted leading command
|
- name: Re-add ssh-dss key with a complex quoted leading command
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_complex_command }}"
|
key: "{{ dss_key_complex_command }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that nothing changed
|
- name: Assert that nothing changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == False'
|
- result.changed == False
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# ssh-dss key with a command and a single option, which are
|
# ssh-dss key with a command and a single option, which are
|
||||||
# in a comma-separated list
|
# in a comma-separated list
|
||||||
|
|
||||||
- name: add ssh-dss key with a command and a single option
|
- name: Add ssh-dss key with a command and a single option
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_command_single_option }}"
|
key: "{{ dss_key_command_single_option }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == dss_key_command_single_option'
|
- result.key == dss_key_command_single_option
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: re-add ssh-dss key with a command and a single option
|
- name: Re-add ssh-dss key with a command and a single option
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_command_single_option }}"
|
key: "{{ dss_key_command_single_option }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that nothing changed
|
- name: Assert that nothing changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == False'
|
- result.changed == False
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# ssh-dss key with a command and multiple other options
|
# ssh-dss key with a command and multiple other options
|
||||||
|
|
||||||
- name: add ssh-dss key with a command and multiple options
|
- name: Add ssh-dss key with a command and multiple options
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_command_multiple_options }}"
|
key: "{{ dss_key_command_multiple_options }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == dss_key_command_multiple_options'
|
- result.key == dss_key_command_multiple_options
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: re-add ssh-dss key with a command and multiple options
|
- name: Re-add ssh-dss key with a command and multiple options
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_command_multiple_options }}"
|
key: "{{ dss_key_command_multiple_options }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that nothing changed
|
- name: Assert that nothing changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == False'
|
- result.changed == False
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# ssh-dss key with multiple trailing parts, which are space-
|
# ssh-dss key with multiple trailing parts, which are space-
|
||||||
# separated and not quoted in any way
|
# separated and not quoted in any way
|
||||||
|
|
||||||
- name: add ssh-dss key with trailing parts
|
- name: Add ssh-dss key with trailing parts
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_trailing }}"
|
key: "{{ dss_key_trailing }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key was added
|
- name: Assert that the key was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == dss_key_trailing'
|
- result.key == dss_key_trailing
|
||||||
- 'result.key_options == None'
|
- result.key_options == None
|
||||||
|
|
||||||
- name: re-add ssh-dss key with trailing parts
|
- name: Re-add ssh-dss key with trailing parts
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_trailing }}"
|
key: "{{ dss_key_trailing }}"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that nothing changed
|
- name: Assert that nothing changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == False'
|
- result.changed == False
|
||||||
|
|
||||||
# -------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# basic ssh-dss key with mutliple permit-open options
|
# basic ssh-dss key with mutliple permit-open options
|
||||||
# https://github.com/ansible/ansible-modules-core/issues/1715
|
# https://github.com/ansible/ansible-modules-core/issues/1715
|
||||||
|
|
||||||
- name: add basic ssh-dss key with multi-opts
|
- name: Add basic ssh-dss key with multi-opts
|
||||||
authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: root
|
user: root
|
||||||
key: "{{ dss_key_basic }}"
|
key: "{{ dss_key_basic }}"
|
||||||
key_options: 'no-agent-forwarding,no-X11-forwarding,permitopen="10.9.8.1:8080",permitopen="10.9.8.1:9001"'
|
key_options: no-agent-forwarding,no-X11-forwarding,permitopen="10.9.8.1:8080",permitopen="10.9.8.1:9001"
|
||||||
state: present
|
state: present
|
||||||
path: "{{ output_dir | expanduser }}/authorized_keys"
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert that the key with multi-opts was added
|
- name: Assert that the key with multi-opts was added
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == True'
|
- result.changed == True
|
||||||
- 'result.key == dss_key_basic'
|
- result.key == dss_key_basic
|
||||||
- 'result.key_options == "no-agent-forwarding,no-X11-forwarding,permitopen=\"10.9.8.1:8080\",permitopen=\"10.9.8.1:9001\""'
|
- result.key_options == "no-agent-forwarding,no-X11-forwarding,permitopen=\"10.9.8.1:8080\",permitopen=\"10.9.8.1:9001\""
|
||||||
|
|
||||||
- name: get the file content
|
- name: Get the file content
|
||||||
shell: cat "{{ output_dir | expanduser }}/authorized_keys" | fgrep DATA_BASIC
|
ansible.builtin.command: fgrep DATA_BASIC "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
changed_when: no
|
changed_when: false
|
||||||
register: content
|
register: content
|
||||||
|
|
||||||
- name: validate content
|
- name: Validate content
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'content.stdout == "no-agent-forwarding,no-X11-forwarding,permitopen=\"10.9.8.1:8080\",permitopen=\"10.9.8.1:9001\" ssh-dss DATA_BASIC root@testing"'
|
- content.stdout == "no-agent-forwarding,no-X11-forwarding,permitopen=\"10.9.8.1:8080\",permitopen=\"10.9.8.1:9001\" ssh-dss DATA_BASIC root@testing"
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
---
|
||||||
dependencies:
|
dependencies:
|
||||||
- setup_pkg_mgr
|
- setup_pkg_mgr
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld module - icmp block inversion operations
|
# Test playbook for the firewalld module - icmp block inversion operations
|
||||||
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
@ -7,26 +8,26 @@
|
||||||
- name: Testing enable icmp block inversion
|
- name: Testing enable icmp block inversion
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: yes
|
icmp_block_inversion: true
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is enabled
|
- name: Assert icmp block inversion is enabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing enable icmp block inversion (verify not changed)
|
- name: Testing enable icmp block inversion (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: yes
|
icmp_block_inversion: true
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is enabled (verify not changed)
|
- name: Assert icmp block inversion is enabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -35,26 +36,26 @@
|
||||||
- name: Testing disable icmp block inversion
|
- name: Testing disable icmp block inversion
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: no
|
icmp_block_inversion: false
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is disabled
|
- name: Assert icmp block inversion is disabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing disable icmp block inversion (verify not changed)
|
- name: Testing disable icmp block inversion (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: no
|
icmp_block_inversion: false
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is disabled (verify not changed)
|
- name: Assert icmp block inversion is disabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -63,26 +64,26 @@
|
||||||
- name: Testing enable icmp block inversion
|
- name: Testing enable icmp block inversion
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: no
|
icmp_block_inversion: false
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is enabled
|
- name: Assert icmp block inversion is enabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing enable icmp block inversion (verify not changed)
|
- name: Testing enable icmp block inversion (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: no
|
icmp_block_inversion: false
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is enabled (verify not changed)
|
- name: Assert icmp block inversion is enabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -91,26 +92,26 @@
|
||||||
- name: Testing disable icmp block inversion
|
- name: Testing disable icmp block inversion
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: yes
|
icmp_block_inversion: true
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is disabled
|
- name: Assert icmp block inversion is disabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing disable icmp block inversion (verify not changed)
|
- name: Testing disable icmp block inversion (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: yes
|
icmp_block_inversion: true
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is disabled (verify not changed)
|
- name: Assert icmp block inversion is disabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -120,26 +121,26 @@
|
||||||
- name: Testing enable icmp block inversion
|
- name: Testing enable icmp block inversion
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: 'some string'
|
icmp_block_inversion: some string
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is enabled
|
- name: Assert icmp block inversion is enabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing enable icmp block inversion (verify not changed)
|
- name: Testing enable icmp block inversion (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: 'some string'
|
icmp_block_inversion: some string
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is enabled (verify not changed)
|
- name: Assert icmp block inversion is enabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -148,25 +149,25 @@
|
||||||
- name: Testing disable icmp block inversion
|
- name: Testing disable icmp block inversion
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: 'some string'
|
icmp_block_inversion: some string
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is disabled
|
- name: Assert icmp block inversion is disabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing disable icmp block inversion (verify not changed)
|
- name: Testing disable icmp block inversion (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
icmp_block_inversion: 'some string'
|
icmp_block_inversion: some string
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert icmp block inversion is disabled (verify not changed)
|
- name: Assert icmp block inversion is disabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld module - interface operations
|
# Test playbook for the firewalld module - interface operations
|
||||||
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
@ -8,12 +9,12 @@
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
interface: lo
|
interface: lo
|
||||||
zone: trusted
|
zone: trusted
|
||||||
permanent: Yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert lo was added to trusted zone
|
- name: Assert lo was added to trusted zone
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
|
|
@ -21,12 +22,12 @@
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
interface: lo
|
interface: lo
|
||||||
zone: trusted
|
zone: trusted
|
||||||
permanent: Yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert lo was added to trusted zone (verify not changed)
|
- name: Assert lo was added to trusted zone (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -36,12 +37,12 @@
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
interface: lo
|
interface: lo
|
||||||
zone: internal
|
zone: internal
|
||||||
permanent: Yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert lo was moved from trusted zone to internal zone
|
- name: Assert lo was moved from trusted zone to internal zone
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
|
|
@ -49,12 +50,12 @@
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
interface: lo
|
interface: lo
|
||||||
zone: internal
|
zone: internal
|
||||||
permanent: Yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert lo was moved from trusted zone to internal zone (verify not changed)
|
- name: Assert lo was moved from trusted zone to internal zone (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -64,12 +65,12 @@
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
interface: lo
|
interface: lo
|
||||||
zone: internal
|
zone: internal
|
||||||
permanent: Yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert lo interface was removed from internal zone
|
- name: Assert lo interface was removed from internal zone
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
|
|
@ -77,11 +78,11 @@
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
interface: lo
|
interface: lo
|
||||||
zone: internal
|
zone: internal
|
||||||
permanent: Yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert lo interface was removed from internal zone (verify not changed)
|
- name: Assert lo interface was removed from internal zone (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,24 @@
|
||||||
|
---
|
||||||
# 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)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: Run firewalld tests
|
- name: Run firewalld tests
|
||||||
|
when:
|
||||||
|
- ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version('7', '>=')
|
||||||
|
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('14.04', '=='))
|
||||||
|
# Firewalld package on OpenSUSE (15+) require Python 3, so we skip on OpenSUSE running py2 on these newer distros
|
||||||
|
- not (ansible_os_family == "Suse" and ansible_distribution_major_version|int != 42 and ansible_python.version.major != 3)
|
||||||
|
- not (ansible_facts.distribution == "CentOS" and ansible_distribution_major_version is version('7', '==')) # FIXME
|
||||||
block:
|
block:
|
||||||
- name: Ensure firewalld is installed
|
- name: Ensure firewalld is installed
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: firewalld
|
name: firewalld
|
||||||
state: present
|
state: present
|
||||||
# This doesn't work for CentOS 6 because firewalld doesn't exist in CentOS6
|
# This doesn't work for CentOS 6 because firewalld doesn't exist in CentOS6
|
||||||
|
|
||||||
- name: Enable dbus-broker daemon
|
- name: Enable dbus-broker daemon
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: dbus-broker
|
name: dbus-broker
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
|
@ -19,25 +26,20 @@
|
||||||
|
|
||||||
- name: Test Online Operations
|
- name: Test Online Operations
|
||||||
block:
|
block:
|
||||||
- name: start firewalld
|
- name: Start firewalld
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: firewalld
|
name: firewalld
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
- import_tasks: run_all_tests.yml
|
- name: Import test tasks
|
||||||
|
ansible.builtin.import_tasks: run_all_tests.yml
|
||||||
|
|
||||||
- name: Test Offline Operations
|
- name: Test Offline Operations
|
||||||
block:
|
block:
|
||||||
- name: stop firewalld
|
- name: Stop firewalld
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: firewalld
|
name: firewalld
|
||||||
state: stopped
|
state: stopped
|
||||||
|
|
||||||
- import_tasks: run_all_tests.yml
|
- name: Import test tasks
|
||||||
|
ansible.builtin.import_tasks: run_all_tests.yml
|
||||||
when:
|
|
||||||
- ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version('7', '>=')
|
|
||||||
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('14.04', '=='))
|
|
||||||
# Firewalld package on OpenSUSE (15+) require Python 3, so we skip on OpenSUSE running py2 on these newer distros
|
|
||||||
- not (ansible_os_family == "Suse" and ansible_distribution_major_version|int != 42 and ansible_python.version.major != 3)
|
|
||||||
- not (ansible_facts.distribution == "CentOS" and ansible_distribution_major_version is version('7', '==')) # FIXME
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld module - masquerade operations
|
# Test playbook for the firewalld module - masquerade operations
|
||||||
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
@ -7,26 +8,26 @@
|
||||||
- name: Testing enable masquerade
|
- name: Testing enable masquerade
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: yes
|
masquerade: true
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is enabled
|
- name: Assert masquerade is enabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing enable masquerade (verify not changed)
|
- name: Testing enable masquerade (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: yes
|
masquerade: true
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is enabled (verify not changed)
|
- name: Assert masquerade is enabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -35,26 +36,26 @@
|
||||||
- name: Testing disable masquerade
|
- name: Testing disable masquerade
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: no
|
masquerade: false
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is disabled
|
- name: Assert masquerade is disabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing disable masquerade (verify not changed)
|
- name: Testing disable masquerade (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: no
|
masquerade: false
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is disabled (verify not changed)
|
- name: Assert masquerade is disabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -63,26 +64,26 @@
|
||||||
- name: Testing enable masquerade
|
- name: Testing enable masquerade
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: no
|
masquerade: false
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is enabled
|
- name: Assert masquerade is enabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing enable masquerade (verify not changed)
|
- name: Testing enable masquerade (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: no
|
masquerade: false
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is enabled (verify not changed)
|
- name: Assert masquerade is enabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -91,26 +92,26 @@
|
||||||
- name: Testing disable masquerade
|
- name: Testing disable masquerade
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: yes
|
masquerade: true
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is disabled
|
- name: Assert masquerade is disabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing disable masquerade (verify not changed)
|
- name: Testing disable masquerade (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: yes
|
masquerade: true
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is disabled (verify not changed)
|
- name: Assert masquerade is disabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -120,26 +121,26 @@
|
||||||
- name: Testing enable masquerade
|
- name: Testing enable masquerade
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: 'some string'
|
masquerade: some string
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is enabled
|
- name: Assert masquerade is enabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing enable masquerade (verify not changed)
|
- name: Testing enable masquerade (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: 'some string'
|
masquerade: some string
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is enabled (verify not changed)
|
- name: Assert masquerade is enabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
|
|
@ -148,25 +149,25 @@
|
||||||
- name: Testing disable masquerade
|
- name: Testing disable masquerade
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: 'some string'
|
masquerade: some string
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is disabled
|
- name: Assert masquerade is disabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: Testing disable masquerade (verify not changed)
|
- name: Testing disable masquerade (verify not changed)
|
||||||
ansible.posix.firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: trusted
|
zone: trusted
|
||||||
masquerade: 'some string'
|
masquerade: some string
|
||||||
permanent: yes
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert masquerade is disabled (verify not changed)
|
- name: Assert masquerade is disabled (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
|
---
|
||||||
# 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)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: firewalld port forward test permanent enabled
|
- name: Firewalld port forward test permanent enabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port_forward:
|
port_forward:
|
||||||
- port: 8080
|
- port: 8080
|
||||||
proto: tcp
|
proto: tcp
|
||||||
|
|
@ -12,13 +13,13 @@
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent enabled worked
|
- name: Assert firewalld port test permanent enabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld port test permanent enabled rerun (verify not changed)
|
- name: Firewalld port test permanent enabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port_forward:
|
port_forward:
|
||||||
- port: 8080
|
- port: 8080
|
||||||
proto: tcp
|
proto: tcp
|
||||||
|
|
@ -27,13 +28,13 @@
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent enabled rerun worked (verify not changed)
|
- name: Assert firewalld port test permanent enabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld port test permanent disabled
|
- name: Firewalld port test permanent disabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port_forward:
|
port_forward:
|
||||||
- port: 8080
|
- port: 8080
|
||||||
proto: tcp
|
proto: tcp
|
||||||
|
|
@ -42,13 +43,13 @@
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent disabled worked
|
- name: Assert firewalld port test permanent disabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld port test permanent disabled rerun (verify not changed)
|
- name: Firewalld port test permanent disabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port_forward:
|
port_forward:
|
||||||
- port: 8080
|
- port: 8080
|
||||||
proto: tcp
|
proto: tcp
|
||||||
|
|
@ -57,7 +58,7 @@
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent disabled rerun worked (verify not changed)
|
- name: Assert firewalld port test permanent disabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
|
||||||
|
|
@ -1,57 +1,58 @@
|
||||||
|
---
|
||||||
# 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)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: firewalld port range test permanent enabled
|
- name: Firewalld port range test permanent enabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port: 5500-6850/tcp
|
port: 5500-6850/tcp
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port range test permanent enabled worked
|
- name: Assert firewalld port range test permanent enabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld port range test permanent enabled rerun (verify not changed)
|
- name: Firewalld port range test permanent enabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port: 5500-6850/tcp
|
port: 5500-6850/tcp
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port range test permanent enabled rerun worked (verify not changed)
|
- name: Assert firewalld port range test permanent enabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld port test permanent enabled
|
- name: Firewalld port test permanent enabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port: 6900/tcp
|
port: 6900/tcp
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent enabled worked
|
- name: Assert firewalld port test permanent enabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld port test permanent enabled
|
- name: Firewalld port test permanent enabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port: 6900/tcp
|
port: 6900/tcp
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent enabled worked
|
- name: Assert firewalld port test permanent enabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld port test disabled
|
- name: Firewalld port test disabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port: "{{ item }}"
|
port: "{{ item }}"
|
||||||
permanent: true
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
|
|
@ -59,50 +60,50 @@
|
||||||
- 6900/tcp
|
- 6900/tcp
|
||||||
- 5500-6850/tcp
|
- 5500-6850/tcp
|
||||||
|
|
||||||
- name: firewalld port test permanent enabled
|
- name: Firewalld port test permanent enabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port: 8081/tcp
|
port: 8081/tcp
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent enabled worked
|
- name: Assert firewalld port test permanent enabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld port test permanent enabled rerun (verify not changed)
|
- name: Firewalld port test permanent enabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port: 8081/tcp
|
port: 8081/tcp
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent enabled rerun worked (verify not changed)
|
- name: Assert firewalld port test permanent enabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld port test permanent disabled
|
- name: Firewalld port test permanent disabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port: 8081/tcp
|
port: 8081/tcp
|
||||||
permanent: true
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent disabled worked
|
- name: Assert firewalld port test permanent disabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld port test permanent disabled rerun (verify not changed)
|
- name: Firewalld port test permanent disabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
port: 8081/tcp
|
port: 8081/tcp
|
||||||
permanent: true
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld port test permanent disabled rerun worked (verify not changed)
|
- name: Assert firewalld port test permanent disabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld module - protocol operations
|
# Test playbook for the firewalld module - protocol operations
|
||||||
# (c) 2022, Robért S. Guhr <rguhr@cronon.net>
|
# (c) 2022, Robért S. Guhr <rguhr@cronon.net>
|
||||||
|
|
||||||
|
|
@ -16,50 +17,50 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: firewalld protocol test permanent enabled
|
- name: Firewalld protocol test permanent enabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
protocol: ospf
|
protocol: ospf
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld protocol test permanent enabled worked
|
- name: Assert firewalld protocol test permanent enabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld protocol test permanent enabled rerun (verify not changed)
|
- name: Firewalld protocol test permanent enabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
protocol: ospf
|
protocol: ospf
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld protocol test permanent enabled rerun worked (verify not changed)
|
- name: Assert firewalld protocol test permanent enabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld protocol test permanent disabled
|
- name: Firewalld protocol test permanent disabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
protocol: ospf
|
protocol: ospf
|
||||||
permanent: true
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld protocol test permanent disabled worked
|
- name: Assert firewalld protocol test permanent disabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld protocol test permanent disabled rerun (verify not changed)
|
- name: Firewalld protocol test permanent disabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
protocol: ospf
|
protocol: ospf
|
||||||
permanent: true
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld protocol test permanent disabled rerun worked (verify not changed)
|
- name: Assert firewalld protocol test permanent disabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,50 @@
|
||||||
|
---
|
||||||
# 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)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: Ensure /run/firewalld exists
|
- name: Ensure /run/firewalld exists
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: /run/firewalld
|
path: /run/firewalld
|
||||||
state: directory
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
# firewalld service operation test cases
|
# firewalld service operation test cases
|
||||||
- include_tasks: service_test_cases.yml
|
- name: Include service test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: service_test_cases.yml
|
||||||
|
|
||||||
# firewalld protocol operation test cases
|
# firewalld protocol operation test cases
|
||||||
- include_tasks: protocol_test_cases.yml
|
- name: Include protocol test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: protocol_test_cases.yml
|
||||||
|
|
||||||
# firewalld port operation test cases
|
# firewalld port operation test cases
|
||||||
- include_tasks: port_test_cases.yml
|
- name: Include port test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: port_test_cases.yml
|
||||||
|
|
||||||
# firewalld source operation test cases
|
# firewalld source operation test cases
|
||||||
- include_tasks: source_test_cases.yml
|
- name: Include source test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: source_test_cases.yml
|
||||||
|
|
||||||
# firewalld zone operation test cases
|
# firewalld zone operation test cases
|
||||||
- include_tasks: zone_test_cases.yml
|
- name: Include zone test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: zone_test_cases.yml
|
||||||
|
|
||||||
# firewalld zone target operation test cases
|
# firewalld zone target operation test cases
|
||||||
- include_tasks: zone_target_test_cases.yml
|
- name: Include zone target test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: zone_target_test_cases.yml
|
||||||
|
|
||||||
# firewalld port forwarding operation test cases
|
# firewalld port forwarding operation test cases
|
||||||
- include_tasks: port_forward_test_cases.yml
|
- name: Include port forward target test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: port_forward_test_cases.yml
|
||||||
|
|
||||||
# firewalld masquerade operation test cases
|
# firewalld masquerade operation test cases
|
||||||
- include_tasks: masquerade_test_cases.yml
|
- name: Include masquerade target test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: masquerade_test_cases.yml
|
||||||
|
|
||||||
# firewalld icmp block inversion operation test cases
|
# firewalld icmp block inversion operation test cases
|
||||||
- include_tasks: icmp_block_inversion_test_cases.yml
|
- name: Include icmp block inversion target test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: icmp_block_inversion_test_cases.yml
|
||||||
|
|
||||||
# firewalld interface operation test cases
|
# firewalld interface operation test cases
|
||||||
- include_tasks: interface_test_cases.yml
|
- name: Include interface target test cases for firewalld module
|
||||||
|
ansible.builtin.include_tasks: interface_test_cases.yml
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld module - service operations
|
# Test playbook for the firewalld module - service operations
|
||||||
# (c) 2017, Adam Miller <admiller@redhat.com>
|
# (c) 2017, Adam Miller <admiller@redhat.com>
|
||||||
|
|
||||||
|
|
@ -16,50 +17,50 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: firewalld service test permanent enabled
|
- name: Firewalld service test permanent enabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
service: https
|
service: https
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld service test permanent enabled worked
|
- name: Assert firewalld service test permanent enabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld service test permanent enabled rerun (verify not changed)
|
- name: Firewalld service test permanent enabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
service: https
|
service: https
|
||||||
permanent: true
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld service test permanent enabled rerun worked (verify not changed)
|
- name: Assert firewalld service test permanent enabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld service test permanent disabled
|
- name: Firewalld service test permanent disabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
service: https
|
service: https
|
||||||
permanent: true
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld service test permanent disabled worked
|
- name: Assert firewalld service test permanent disabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld service test permanent disabled rerun (verify not changed)
|
- name: Firewalld service test permanent disabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
service: https
|
service: https
|
||||||
permanent: true
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld service test permanent disabled rerun worked (verify not changed)
|
- name: Assert firewalld service test permanent disabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld module - source operations
|
# Test playbook for the firewalld module - source operations
|
||||||
# (c) 2019, Hideki Saito <saito@fgrep.org>
|
# (c) 2019, Hideki Saito <saito@fgrep.org>
|
||||||
|
|
||||||
|
|
@ -16,70 +17,71 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: firewalld source test permanent enabled
|
- name: Firewalld source test permanent enabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
source: 192.0.2.0/24
|
source: 192.0.2.0/24
|
||||||
zone: internal
|
zone: internal
|
||||||
permanent: True
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld source test permanent enabled worked
|
- name: Assert firewalld source test permanent enabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld source test permanent enabled rerun (verify not changed)
|
- name: Firewalld source test permanent enabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
source: 192.0.2.0/24
|
source: 192.0.2.0/24
|
||||||
zone: internal
|
zone: internal
|
||||||
permanent: True
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld source test permanent enabled rerun worked (verify not changed)
|
- name: Assert firewalld source test permanent enabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld source test permanent disabled
|
- name: Firewalld source test permanent disabled
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
source: 192.0.2.0/24
|
source: 192.0.2.0/24
|
||||||
zone: internal
|
zone: internal
|
||||||
permanent: True
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld source test permanent disabled worked
|
- name: Assert firewalld source test permanent disabled worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld source test permanent disabled rerun (verify not changed)
|
- name: Firewalld source test permanent disabled rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
source: 192.0.2.0/24
|
source: 192.0.2.0/24
|
||||||
zone: internal
|
zone: internal
|
||||||
permanent: True
|
permanent: true
|
||||||
state: disabled
|
state: disabled
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld source test permanent disabled rerun worked (verify not changed)
|
- name: Assert firewalld source test permanent disabled rerun worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld source test permanent enabled is exclusive (verify exclusive error)
|
- name: Firewalld source test permanent enabled is exclusive (verify exclusive error)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
source: 192.0.2.0/24
|
source: 192.0.2.0/24
|
||||||
port: 8081/tcp
|
port: 8081/tcp
|
||||||
zone: internal
|
zone: internal
|
||||||
permanent: True
|
permanent: true
|
||||||
state: enabled
|
state: enabled
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: assert firewalld source test permanent enabled is exclusive (verify exclusive error)
|
- name: Assert firewalld source test permanent enabled is exclusive (verify exclusive error)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
- "result.msg == 'parameters are mutually exclusive: icmp_block|icmp_block_inversion|service|protocol|port|port_forward|rich_rule|interface|masquerade|source|target'"
|
- "result.msg ==
|
||||||
|
'parameters are mutually exclusive: icmp_block|icmp_block_inversion|service|protocol|port|port_forward|rich_rule|interface|masquerade|source|target'"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld module - source operations
|
# Test playbook for the firewalld module - source operations
|
||||||
# (c) 2020, Adam Miller <admiller@redhat.com>
|
# (c) 2020, Adam Miller <admiller@redhat.com>
|
||||||
|
|
||||||
|
|
@ -16,106 +17,106 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: firewalld dmz zone target DROP
|
- name: Firewalld dmz zone target DROP
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: dmz
|
zone: dmz
|
||||||
permanent: True
|
permanent: true
|
||||||
state: present
|
state: present
|
||||||
target: DROP
|
target: DROP
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld dmz zone target DROP present worked
|
- name: Assert firewalld dmz zone target DROP present worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld dmz zone target DROP rerun (verify not changed)
|
- name: Firewalld dmz zone target DROP rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: dmz
|
zone: dmz
|
||||||
permanent: True
|
permanent: true
|
||||||
state: present
|
state: present
|
||||||
target: DROP
|
target: DROP
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld dmz zone target DROP present worked (verify not changed)
|
- name: Assert firewalld dmz zone target DROP present worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld dmz zone target DROP absent
|
- name: Firewalld dmz zone target DROP absent
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: dmz
|
zone: dmz
|
||||||
permanent: True
|
permanent: true
|
||||||
state: absent
|
state: absent
|
||||||
target: DROP
|
target: DROP
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld dmz zone target DROP absent worked
|
- name: Assert firewalld dmz zone target DROP absent worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld dmz zone target DROP rerun (verify not changed)
|
- name: Firewalld dmz zone target DROP rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: dmz
|
zone: dmz
|
||||||
permanent: True
|
permanent: true
|
||||||
state: absent
|
state: absent
|
||||||
target: DROP
|
target: DROP
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld dmz zone target DROP present worked (verify not changed)
|
- name: Assert firewalld dmz zone target DROP present worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld dmz zone target %%REJECT%%
|
- name: Firewalld dmz zone target %%REJECT%%
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: dmz
|
zone: dmz
|
||||||
permanent: True
|
permanent: true
|
||||||
state: present
|
state: present
|
||||||
target: '%%REJECT%%'
|
target: "%%REJECT%%"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld dmz zone target %%REJECT%% present worked
|
- name: Assert firewalld dmz zone target %%REJECT%% present worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld dmz zone target %%REJECT%% rerun (verify not changed)
|
- name: Firewalld dmz zone target %%REJECT%% rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: dmz
|
zone: dmz
|
||||||
permanent: True
|
permanent: true
|
||||||
state: present
|
state: present
|
||||||
target: '%%REJECT%%'
|
target: "%%REJECT%%"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld dmz zone target %%REJECT%% present worked (verify not changed)
|
- name: Assert firewalld dmz zone target %%REJECT%% present worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld dmz zone target %%REJECT%% absent
|
- name: Firewalld dmz zone target %%REJECT%% absent
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: dmz
|
zone: dmz
|
||||||
permanent: True
|
permanent: true
|
||||||
state: absent
|
state: absent
|
||||||
target: '%%REJECT%%'
|
target: "%%REJECT%%"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld dmz zone target %%REJECT%% absent worked
|
- name: Assert firewalld dmz zone target %%REJECT%% absent worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld dmz zone target %%REJECT%% rerun (verify not changed)
|
- name: Firewalld dmz zone target %%REJECT%% rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: dmz
|
zone: dmz
|
||||||
permanent: True
|
permanent: true
|
||||||
state: absent
|
state: absent
|
||||||
target: '%%REJECT%%'
|
target: "%%REJECT%%"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld dmz zone target %%REJECT%% present worked (verify not changed)
|
- name: Assert firewalld dmz zone target %%REJECT%% present worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
@ -1,47 +1,48 @@
|
||||||
- name: firewalld create zone custom
|
---
|
||||||
firewalld:
|
- name: Firewalld create zone custom
|
||||||
|
ansible.posix.firewalld:
|
||||||
zone: custom
|
zone: custom
|
||||||
permanent: True
|
permanent: true
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld custom zone created worked
|
- name: Assert firewalld custom zone created worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld create zone custom rerun (verify not changed)
|
- name: Firewalld create zone custom rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: custom
|
zone: custom
|
||||||
permanent: True
|
permanent: true
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld custom zone created worked (verify not changed)
|
- name: Assert firewalld custom zone created worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: firewalld remove zone custom
|
- name: Firewalld remove zone custom
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: custom
|
zone: custom
|
||||||
permanent: True
|
permanent: true
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld custom zone removed worked
|
- name: Assert firewalld custom zone removed worked
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: firewalld remove custom zone rerun (verify not changed)
|
- name: Firewalld remove custom zone rerun (verify not changed)
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
zone: custom
|
zone: custom
|
||||||
permanent: True
|
permanent: true
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: assert firewalld custom zone removed worked (verify not changed)
|
- name: Assert firewalld custom zone removed worked (verify not changed)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,53 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld_info module
|
# Test playbook for the firewalld_info module
|
||||||
# (c) 2021, Hideki Saito <saito@fgrep.org>
|
# (c) 2021, Hideki Saito <saito@fgrep.org>
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
# This test is based on the integration test playbook for firewalld module.
|
# This test is based on the integration test playbook for firewalld module.
|
||||||
- name: Run firewalld tests
|
- name: Run firewalld tests
|
||||||
block:
|
|
||||||
- name: Ensure firewalld is installed
|
|
||||||
package:
|
|
||||||
name: firewalld
|
|
||||||
state: present
|
|
||||||
# This doesn't work for CentOS 6 because firewalld doesn't exist in CentOS6
|
|
||||||
|
|
||||||
- name: Check to make sure the firewalld python module is available.
|
|
||||||
shell: "{{ansible_python.executable}} -c 'import firewall'"
|
|
||||||
register: check_output_firewall
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Check to make sure the dbus python module is available.
|
|
||||||
shell: "{{ansible_python.executable}} -c 'import dbus'"
|
|
||||||
register: check_output_dbus
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: Test Online Operations
|
|
||||||
block:
|
|
||||||
- name: start firewalld
|
|
||||||
service:
|
|
||||||
name: firewalld
|
|
||||||
state: started
|
|
||||||
|
|
||||||
- import_tasks: run_tests_in_started.yml
|
|
||||||
when:
|
|
||||||
- check_output_firewall.rc == 0
|
|
||||||
- check_output_dbus.rc == 0
|
|
||||||
|
|
||||||
- name: Test Offline Operations
|
|
||||||
block:
|
|
||||||
- name: stop firewalld
|
|
||||||
service:
|
|
||||||
name: firewalld
|
|
||||||
state: stopped
|
|
||||||
|
|
||||||
- import_tasks: run_tests_in_stopped.yml
|
|
||||||
when:
|
|
||||||
- check_output_firewall.rc == 0
|
|
||||||
- check_output_dbus.rc == 0
|
|
||||||
|
|
||||||
when:
|
when:
|
||||||
- ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version('7', '>=')
|
- ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version('7', '>=')
|
||||||
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('14.04', '=='))
|
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('14.04', '=='))
|
||||||
# Firewalld package on OpenSUSE (15+) require Python 3, so we skip on OpenSUSE running py2 on these newer distros
|
# Firewalld package on OpenSUSE (15+) require Python 3, so we skip on OpenSUSE running py2 on these newer distros
|
||||||
- not (ansible_os_family == "Suse" and ansible_distribution_major_version|int != 42 and ansible_python.version.major != 3)
|
- not (ansible_os_family == "Suse" and ansible_distribution_major_version|int != 42 and ansible_python.version.major != 3)
|
||||||
|
block:
|
||||||
|
- name: Ensure firewalld is installed
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: firewalld
|
||||||
|
state: present
|
||||||
|
# This doesn't work for CentOS 6 because firewalld doesn't exist in CentOS6
|
||||||
|
|
||||||
|
- name: Check to make sure the firewalld python module is available.
|
||||||
|
ansible.builtin.command: "{{ ansible_python.executable }} -c 'import firewall'"
|
||||||
|
changed_when: false
|
||||||
|
register: check_output_firewall
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Check to make sure the dbus python module is available.
|
||||||
|
ansible.builtin.command: "{{ ansible_python.executable }} -c 'import dbus'"
|
||||||
|
changed_when: false
|
||||||
|
register: check_output_dbus
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Test Online Operations
|
||||||
|
block:
|
||||||
|
- name: Start firewalld
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: firewalld
|
||||||
|
state: started
|
||||||
|
|
||||||
|
- name: Import test tasks from run_tests_in_started.yml
|
||||||
|
ansible.builtin.import_tasks: run_tests_in_started.yml
|
||||||
|
|
||||||
|
- name: Test Offline Operations
|
||||||
|
when:
|
||||||
|
- check_output_firewall.rc == 0
|
||||||
|
- check_output_dbus.rc == 0
|
||||||
|
block:
|
||||||
|
- name: Stop firewalld
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: firewalld
|
||||||
|
state: stopped
|
||||||
|
|
||||||
|
- name: Import test tasks from run_tests_in_stopped.yml
|
||||||
|
ansible.builtin.import_tasks: run_tests_in_stopped.yml
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,33 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld_info module
|
# Test playbook for the firewalld_info module
|
||||||
# (c) 2021, Hideki Saito <saito@fgrep.org>
|
# (c) 2021, Hideki Saito <saito@fgrep.org>
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: Ensure firewalld_info without options
|
- name: Ensure firewalld_info without options
|
||||||
firewalld_info:
|
ansible.posix.firewalld_info:
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert collected_zones and undefined_zones
|
- name: Assert collected_zones and undefined_zones
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- 'result.collected_zones and not result.undefined_zones'
|
- result.collected_zones and not result.undefined_zones
|
||||||
|
|
||||||
- name: Ensure firewalld_info with active_zones
|
- name: Ensure firewalld_info with active_zones
|
||||||
firewalld_info:
|
ansible.posix.firewalld_info:
|
||||||
active_zones: yes
|
active_zones: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert turn active_zones true
|
- name: Assert turn active_zones true
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
|
|
||||||
- name: Ensure firewalld_zones with zone list
|
- name: Ensure firewalld_zones with zone list
|
||||||
firewalld_info:
|
ansible.posix.firewalld_info:
|
||||||
zones:
|
zones:
|
||||||
- public
|
- public
|
||||||
- invalid_zone
|
- invalid_zone
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert specified zones
|
- name: Assert specified zones
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,41 @@
|
||||||
|
---
|
||||||
# Test playbook for the firewalld_info module
|
# Test playbook for the firewalld_info module
|
||||||
# (c) 2021, Hideki Saito <saito@fgrep.org>
|
# (c) 2021, Hideki Saito <saito@fgrep.org>
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: Ensure firewalld_info without options
|
- name: Ensure firewalld_info without options
|
||||||
firewalld_info:
|
ansible.posix.firewalld_info:
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Assert firewalld_info fails if firewalld is not running.
|
- name: Assert firewalld_info fails if firewalld is not running.
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.failed
|
- result.failed
|
||||||
- "'firewalld probably not be running,' in result.msg"
|
- "'firewalld probably not be running,' in result.msg"
|
||||||
|
|
||||||
- name: Ensure firewalld_info with active_zones
|
- name: Ensure firewalld_info with active_zones
|
||||||
firewalld_info:
|
ansible.posix.firewalld_info:
|
||||||
active_zones: yes
|
active_zones: true
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Assert firewalld_info with active_zones fails if firewalld is not running.
|
- name: Assert firewalld_info with active_zones fails if firewalld is not running.
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.failed
|
- result.failed
|
||||||
- "'firewalld probably not be running,' in result.msg"
|
- "'firewalld probably not be running,' in result.msg"
|
||||||
|
|
||||||
- name: Ensure firewalld_zones with zone list
|
- name: Ensure firewalld_zones with zone list
|
||||||
firewalld_info:
|
ansible.posix.firewalld_info:
|
||||||
zones:
|
zones:
|
||||||
- public
|
- public
|
||||||
- invalid_zone
|
- invalid_zone
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Assert firewalld_info with zones list fails if firewalld is not running.
|
- name: Assert firewalld_info with zones list fails if firewalld is not running.
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.failed
|
- result.failed
|
||||||
- "'firewalld probably not be running,' in result.msg"
|
- "'firewalld probably not be running,' in result.msg"
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,117 @@
|
||||||
- name: Install dependencies
|
- name: Install dependencies (Linux)
|
||||||
ansible.builtin.package:
|
ansible.builtin.package:
|
||||||
name: e2fsprogs
|
name: e2fsprogs
|
||||||
state: present
|
state: present
|
||||||
when: ansible_system == 'Linux'
|
when: ansible_system == 'Linux'
|
||||||
|
|
||||||
|
- name: Install dependencies (FreeBSD)
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: bash
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Register facts on Linux
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
shell_executable: /bin/bash
|
||||||
|
ephemeral_device_a: /tmp/myfs_A.img
|
||||||
|
ephemeral_device_b: /tmp/myfs_B.img
|
||||||
|
ephemeral_fstype: ext3
|
||||||
|
ephemeral_fstab: /etc/fstab
|
||||||
|
when: ansible_system == 'Linux'
|
||||||
|
|
||||||
|
- name: Register facts on Solaris/SunOS
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
shell_executable: /usr/bin/bash
|
||||||
|
ephemeral_device_a: /dev/lofi/1
|
||||||
|
ephemeral_device_b: /dev/lofi/2
|
||||||
|
ephemeral_create_loop_dev_cmd: >-
|
||||||
|
lofiadm -a /tmp/myfs_A.img /dev/lofi/1 &&
|
||||||
|
lofiadm -a /tmp/myfs_B.img /dev/lofi/2
|
||||||
|
ephemeral_remove_loop_dev_cmd: >-
|
||||||
|
lofiadm -d /dev/lofi/1 &&
|
||||||
|
lofiadm -d /dev/lofi/2 || true
|
||||||
|
ephemeral_fstype: ufs
|
||||||
|
ephemeral_fstab: /etc/vfstab
|
||||||
|
when: ansible_system == 'SunOS'
|
||||||
|
|
||||||
|
- name: Register facts on FreeBSD
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
shell_executable: /usr/local/bin/bash
|
||||||
|
ephemeral_device_a: /dev/md1
|
||||||
|
ephemeral_device_b: /dev/md2
|
||||||
|
ephemeral_create_loop_dev_cmd: >-
|
||||||
|
mdconfig -a -t vnode -f /tmp/myfs_A.img -u /dev/md1 &&
|
||||||
|
mdconfig -a -t vnode -f /tmp/myfs_B.img -u /dev/md2
|
||||||
|
ephemeral_remove_loop_dev_cmd: >-
|
||||||
|
mdconfig -d -u /dev/md1 &&
|
||||||
|
mdconfig -d -u /dev/md2
|
||||||
|
ephemeral_fstype: ufs
|
||||||
|
ephemeral_fstab: /etc/fstab
|
||||||
|
when: ansible_system == 'FreeBSD'
|
||||||
|
|
||||||
|
- name: Register facts on NetBSD
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
shell_executable: /usr/local/bin/bash
|
||||||
|
ephemeral_device_a: /dev/vnd1
|
||||||
|
ephemeral_device_b: /dev/vnd2
|
||||||
|
ephemeral_create_loop_dev_cmd: >-
|
||||||
|
vnconfig /dev/vnd1 /tmp/myfs_A.img &&
|
||||||
|
vnconfig /dev/vnd2 /tmp/myfs_B.img
|
||||||
|
ephemeral_remove_loop_dev_cmd: >-
|
||||||
|
vnconfig -u /dev/vnd1 &&
|
||||||
|
vnconfig -u /dev/vnd2
|
||||||
|
ephemeral_fstype: ufs
|
||||||
|
ephemeral_fstab: /etc/fstab
|
||||||
|
when: ansible_system == 'NetBSD'
|
||||||
|
|
||||||
|
- name: Register format fs command on Non-Linux and Non-OpenBSD
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
ephemeral_format_fs_cmd: >-
|
||||||
|
newfs {{ ephemeral_device_a }} &&
|
||||||
|
newfs {{ ephemeral_device_b }}
|
||||||
|
when: ansible_system in ('SunOS', 'FreeBSD', 'NetBSD')
|
||||||
|
|
||||||
|
- name: Register facts on OpenBSD
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
shell_executable: /usr/local/bin/bash
|
||||||
|
ephemeral_device_a: /dev/vnd1c
|
||||||
|
ephemeral_device_b: /dev/vnd2c
|
||||||
|
ephemeral_create_loop_dev_cmd: >-
|
||||||
|
vnconfig vnd1 /tmp/myfs_A.img &&
|
||||||
|
vnconfig vnd2 /tmp/myfs_B.img
|
||||||
|
ephemeral_remove_loop_dev_cmd: >-
|
||||||
|
vnconfig -u vnd1 &&
|
||||||
|
vnconfig -u vnd2
|
||||||
|
ephemeral_format_fs_cmd: >-
|
||||||
|
newfs /dev/rvnd1c &&
|
||||||
|
newfs /dev/rvnd2c
|
||||||
|
ephemeral_fstype: ffs
|
||||||
|
ephemeral_fstab: /etc/fstab
|
||||||
|
when: ansible_system == 'OpenBSD'
|
||||||
|
|
||||||
|
|
||||||
- name: Create the mount point
|
- name: Create the mount point
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
path: '{{ output_dir }}/mount_dest'
|
path: '{{ output_dir }}/mount_dest'
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
- name: Create a directory to bind mount
|
- name: Create a directory to bind mount
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
path: '{{ output_dir }}/mount_source'
|
path: '{{ output_dir }}/mount_source'
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
- 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:
|
ansible.builtin.copy:
|
||||||
content: 'Testing
|
content: 'Testing
|
||||||
|
|
||||||
'
|
'
|
||||||
dest: '{{ output_dir }}/mount_source/test_file'
|
dest: '{{ output_dir }}/mount_source/test_file'
|
||||||
|
mode: '0644'
|
||||||
register: orig_info
|
register: orig_info
|
||||||
|
|
||||||
- name: Bind mount a filesystem (Linux)
|
- name: Bind mount a filesystem (Linux)
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: '{{ output_dir }}/mount_dest'
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
|
|
@ -33,7 +121,7 @@
|
||||||
register: bind_result_linux
|
register: bind_result_linux
|
||||||
|
|
||||||
- name: Bind mount a filesystem (FreeBSD)
|
- name: Bind mount a filesystem (FreeBSD)
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: '{{ output_dir }}/mount_dest'
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
|
|
@ -41,14 +129,14 @@
|
||||||
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:
|
ansible.builtin.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:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- (ansible_system == 'Linux' and bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and bind_result_freebsd['changed'])
|
- (ansible_system == 'Linux' and bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and bind_result_freebsd['changed'])
|
||||||
- dest_stat['stat']['exists']
|
- dest_stat['stat']['exists']
|
||||||
|
|
@ -56,7 +144,7 @@
|
||||||
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:
|
ansible.posix.mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: '{{ output_dir }}/mount_dest'
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
|
|
@ -66,7 +154,7 @@
|
||||||
register: bind_result_linux
|
register: bind_result_linux
|
||||||
|
|
||||||
- name: Bind mount a filesystem (FreeBSD)
|
- name: Bind mount a filesystem (FreeBSD)
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: '{{ output_dir }}/mount_dest'
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
|
|
@ -75,13 +163,13 @@
|
||||||
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:
|
ansible.builtin.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:
|
ansible.posix.mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: '{{ output_dir }}/mount_dest'
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
|
|
@ -91,7 +179,7 @@
|
||||||
register: bind_result_linux
|
register: bind_result_linux
|
||||||
|
|
||||||
- name: Remount filesystem with different opts (FreeBSD)
|
- name: Remount filesystem with different opts (FreeBSD)
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
src: '{{ output_dir }}/mount_source'
|
src: '{{ output_dir }}/mount_source'
|
||||||
name: '{{ output_dir }}/mount_dest'
|
name: '{{ output_dir }}/mount_dest'
|
||||||
state: mounted
|
state: mounted
|
||||||
|
|
@ -101,11 +189,14 @@
|
||||||
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
|
ansible.builtin.shell:
|
||||||
|
cmd: set -o pipefail && mount | grep mount_dest | grep -E -w '(ro|read-only)' | wc -l
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
|
changed_when: false
|
||||||
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:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- (ansible_system == 'Linux' and bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and bind_result_freebsd['changed'])
|
- (ansible_system == 'Linux' and bind_result_linux['changed']) or (ansible_system == 'FreeBSD' and bind_result_freebsd['changed'])
|
||||||
- '''1'' in remount_options.stdout'
|
- '''1'' in remount_options.stdout'
|
||||||
|
|
@ -113,29 +204,30 @@
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
|
|
||||||
- name: Unmount the bind mount
|
- name: Unmount the bind mount
|
||||||
mount:
|
ansible.posix.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:
|
ansible.builtin.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:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- unmount_result['changed']
|
- unmount_result['changed']
|
||||||
- not dest_stat['stat']['exists']
|
- not dest_stat['stat']['exists']
|
||||||
when: ansible_system in ('FreeBSD', 'Linux')
|
when: ansible_system in ('FreeBSD', 'Linux')
|
||||||
|
|
||||||
- name: Block to test remounted option
|
- name: Block to test remounted option
|
||||||
|
when: ansible_system in ('Linux')
|
||||||
block:
|
block:
|
||||||
- name: Create fstab record for the first swap file
|
- name: Create fstab record for the first swap file
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
name: none
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap1
|
||||||
opts: sw
|
opts: sw
|
||||||
|
|
@ -144,7 +236,7 @@
|
||||||
register: swap1_created
|
register: swap1_created
|
||||||
|
|
||||||
- name: Try to create fstab record for the first swap file again
|
- name: Try to create fstab record for the first swap file again
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
name: none
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap1
|
||||||
opts: sw
|
opts: sw
|
||||||
|
|
@ -153,13 +245,13 @@
|
||||||
register: swap1_created_again
|
register: swap1_created_again
|
||||||
|
|
||||||
- name: Check that we created the swap1 record
|
- name: Check that we created the swap1 record
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- swap1_created['changed']
|
- swap1_created['changed']
|
||||||
- not swap1_created_again['changed']
|
- not swap1_created_again['changed']
|
||||||
|
|
||||||
- name: Create fstab record for the second swap file
|
- name: Create fstab record for the second swap file
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
name: none
|
name: none
|
||||||
src: /tmp/swap2
|
src: /tmp/swap2
|
||||||
opts: sw
|
opts: sw
|
||||||
|
|
@ -168,69 +260,70 @@
|
||||||
register: swap2_created
|
register: swap2_created
|
||||||
|
|
||||||
- name: Try to create fstab record for the second swap file again
|
- name: Try to create fstab record for the second swap file again
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
name: none
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap2
|
||||||
opts: sw
|
opts: sw
|
||||||
fstype: swap
|
fstype: swap
|
||||||
state: present
|
state: present
|
||||||
register: swap2_created_again
|
register: swap2_created_again
|
||||||
|
|
||||||
- name: Check that we created the swap2 record
|
- name: Check that we created the swap2 record
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- swap2_created['changed']
|
- swap2_created['changed']
|
||||||
- not swap2_created_again['changed']
|
- not swap2_created_again['changed']
|
||||||
|
|
||||||
- name: Remove the fstab record for the first swap file
|
- name: Remove the fstab record for the first swap file
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
name: none
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap1
|
||||||
state: absent
|
state: absent
|
||||||
register: swap1_removed
|
register: swap1_removed
|
||||||
|
|
||||||
- name: Try to remove the fstab record for the first swap file again
|
- name: Try to remove the fstab record for the first swap file again
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
name: none
|
name: none
|
||||||
src: /tmp/swap1
|
src: /tmp/swap1
|
||||||
state: absent
|
state: absent
|
||||||
register: swap1_removed_again
|
register: swap1_removed_again
|
||||||
|
|
||||||
- name: Check that we removed the swap1 record
|
- name: Check that we removed the swap1 record
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- swap1_removed['changed']
|
- swap1_removed['changed']
|
||||||
- not swap1_removed_again['changed']
|
- not swap1_removed_again['changed']
|
||||||
|
|
||||||
- name: Remove the fstab record for the second swap file
|
- name: Remove the fstab record for the second swap file
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
name: none
|
name: none
|
||||||
src: /tmp/swap2
|
src: /tmp/swap2
|
||||||
state: absent
|
state: absent
|
||||||
register: swap2_removed
|
register: swap2_removed
|
||||||
|
|
||||||
- name: Try to remove the fstab record for the second swap file again
|
- name: Try to remove the fstab record for the second swap file again
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
name: none
|
name: none
|
||||||
src: /tmp/swap2
|
src: /tmp/swap2
|
||||||
state: absent
|
state: absent
|
||||||
register: swap2_removed_again
|
register: swap2_removed_again
|
||||||
|
|
||||||
- name: Check that we removed the swap2 record
|
- name: Check that we removed the swap2 record
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- swap2_removed['changed']
|
- swap2_removed['changed']
|
||||||
- not swap2_removed_again['changed']
|
- not swap2_removed_again['changed']
|
||||||
|
|
||||||
- name: Create fstab record with missing last two fields
|
- name: Create fstab record with missing last two fields
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
dest: /etc/fstab
|
dest: /etc/fstab
|
||||||
content: '//nas/photo /home/jik/pictures cifs defaults,credentials=/etc/security/nas.creds,uid=jik,gid=users,forceuid,forcegid,noserverino,_netdev
|
content: '//nas/photo /home/jik/pictures cifs defaults,credentials=/etc/security/nas.creds,uid=jik,gid=users,forceuid,forcegid,noserverino,_netdev
|
||||||
|
|
||||||
'
|
'
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
- name: Try to change the fstab record with the missing last two fields
|
- name: Try to change the fstab record with the missing last two fields
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
src: //nas/photo
|
src: //nas/photo
|
||||||
path: /home/jik/pictures
|
path: /home/jik/pictures
|
||||||
fstype: cifs
|
fstype: cifs
|
||||||
|
|
@ -239,11 +332,12 @@
|
||||||
register: optional_fields_update
|
register: optional_fields_update
|
||||||
|
|
||||||
- name: Get the content of the fstab file
|
- name: Get the content of the fstab file
|
||||||
shell: cat /etc/fstab
|
ansible.builtin.command: cat /etc/fstab
|
||||||
|
changed_when: false
|
||||||
register: optional_fields_content
|
register: optional_fields_content
|
||||||
|
|
||||||
- name: Check if the line containing the missing last two fields was changed
|
- name: Check if the line containing the missing last two fields was changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- optional_fields_update['changed']
|
- optional_fields_update['changed']
|
||||||
- ''' 0 0'' in optional_fields_content.stdout'
|
- ''' 0 0'' in optional_fields_content.stdout'
|
||||||
|
|
@ -260,82 +354,93 @@
|
||||||
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:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: /tmp/myfs.img
|
src: /tmp/myfs.img
|
||||||
fstype: ext2
|
fstype: ext2
|
||||||
state: mounted
|
state: mounted
|
||||||
|
|
||||||
- name: Get the last write time
|
- name: Get the last write time
|
||||||
shell: 'dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-'
|
ansible.builtin.shell:
|
||||||
|
cmd: >-
|
||||||
|
set -o pipefail && dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i "last write time:" | cut -d: -f2-
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
|
changed_when: false
|
||||||
register: last_write_time
|
register: last_write_time
|
||||||
|
|
||||||
- name: Wait 2 second
|
- name: Wait 2 second
|
||||||
pause:
|
ansible.builtin.pause:
|
||||||
seconds: 2
|
seconds: 2
|
||||||
|
|
||||||
- name: Test if the FS is remounted
|
- name: Test if the FS is remounted
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
state: remounted
|
state: remounted
|
||||||
|
|
||||||
- name: Get again the last write time
|
- name: Get again the last write time
|
||||||
shell: 'dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i last write time: |cut -d: -f2-'
|
ansible.builtin.shell:
|
||||||
|
cmd: >-
|
||||||
|
set -o pipefail && dumpe2fs /tmp/myfs.img 2>/dev/null | grep -i "last write time:" |cut -d: -f2-
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
|
changed_when: false
|
||||||
register: last_write_time2
|
register: last_write_time2
|
||||||
|
|
||||||
- name: Fail if they are the same
|
- name: Fail if they are the same
|
||||||
fail:
|
ansible.builtin.fail:
|
||||||
msg: Filesytem was not remounted, testing of the module failed!
|
msg: Filesytem was not remounted, testing of the module failed!
|
||||||
when: last_write is defined and last_write_time2 is defined and last_write_time.stdout == last_write_time2.stdout
|
when: last_write is defined and last_write_time2 is defined and last_write_time.stdout == last_write_time2.stdout
|
||||||
|
|
||||||
- name: Remount filesystem with different opts using remounted option (Linux only)
|
- name: Remount filesystem with different opts using remounted option (Linux only)
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
state: remounted
|
state: remounted
|
||||||
opts: rw,noexec
|
opts: rw,noexec
|
||||||
|
|
||||||
- name: Get remounted options (Linux only)
|
- name: Get remounted options (Linux only)
|
||||||
shell: mount | grep myfs | grep -E -w 'noexec' | wc -l
|
ansible.builtin.shell:
|
||||||
|
cmd: set -o pipefail && mount | grep myfs | grep -E -w 'noexec' | wc -l
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
|
changed_when: false
|
||||||
register: remounted_options
|
register: remounted_options
|
||||||
|
|
||||||
- name: Make sure the filesystem now has the new opts after using remounted (Linux only)
|
- name: Make sure the filesystem now has the new opts after using remounted (Linux only)
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'1' in remounted_options.stdout"
|
- "'1' in remounted_options.stdout"
|
||||||
- "1 == remounted_options.stdout_lines | length"
|
- "1 == remounted_options.stdout_lines | length"
|
||||||
|
|
||||||
- name: Mount the FS again to test backup
|
- name: Mount the FS again to test backup
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: /tmp/myfs.img
|
src: /tmp/myfs.img
|
||||||
fstype: ext2
|
fstype: ext2
|
||||||
state: mounted
|
state: mounted
|
||||||
backup: yes
|
backup: true
|
||||||
register: mount_backup_out
|
register: mount_backup_out
|
||||||
|
|
||||||
- name: ensure backup_file in returned output
|
- name: Ensure backup_file in returned output
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'backup_file' in mount_backup_out"
|
- "'backup_file' in mount_backup_out"
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Umount the test FS
|
- name: Umount the test FS
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: /tmp/myfs.img
|
src: /tmp/myfs.img
|
||||||
opts: loop
|
opts: loop
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Remove the test FS
|
- name: Remove the test FS
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ item }}'
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- /tmp/myfs.img
|
- /tmp/myfs.img
|
||||||
- /tmp/myfs
|
- /tmp/myfs
|
||||||
when: ansible_system in ('Linux')
|
|
||||||
|
|
||||||
- name: Block to test boot option for Linux
|
- name: Block to test boot option for Linux
|
||||||
|
when: ansible_system in ('Linux')
|
||||||
block:
|
block:
|
||||||
- name: Create empty file
|
- name: Create empty file
|
||||||
community.general.filesize:
|
community.general.filesize:
|
||||||
|
|
@ -348,35 +453,35 @@
|
||||||
dev: /tmp/myfs.img
|
dev: /tmp/myfs.img
|
||||||
|
|
||||||
- name: Mount the FS with noauto option
|
- name: Mount the FS with noauto option
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: /tmp/myfs.img
|
src: /tmp/myfs.img
|
||||||
fstype: ext3
|
fstype: ext3
|
||||||
state: mounted
|
state: mounted
|
||||||
boot: no
|
boot: false
|
||||||
opts: rw,user,async
|
opts: rw,user,async
|
||||||
register: mount_info
|
register: mount_info
|
||||||
|
|
||||||
- name: assert the mount without noauto was successful
|
- name: Assert the mount without noauto was successful
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- mount_info['opts'] == 'rw,user,async,noauto'
|
- mount_info['opts'] == 'rw,user,async,noauto'
|
||||||
|
|
||||||
- name: Unmount FS
|
- name: Unmount FS
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Remove the test FS
|
- name: Remove the test FS
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ item }}'
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- /tmp/myfs.img
|
- /tmp/myfs.img
|
||||||
- /tmp/myfs
|
- /tmp/myfs
|
||||||
when: ansible_system in ('Linux')
|
|
||||||
|
|
||||||
- name: Block to test missing newline at the EOF of fstab
|
- name: Block to test missing newline at the EOF of fstab
|
||||||
|
when: ansible_system in ('Linux')
|
||||||
block:
|
block:
|
||||||
- name: Create empty file
|
- name: Create empty file
|
||||||
community.general.filesize:
|
community.general.filesize:
|
||||||
|
|
@ -387,11 +492,12 @@
|
||||||
fstype: ext3
|
fstype: ext3
|
||||||
dev: /tmp/myfs1.img
|
dev: /tmp/myfs1.img
|
||||||
- name: Create custom fstab file without newline
|
- name: Create custom fstab file without newline
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
content: '#TEST COMMENT WITHOUT NEWLINE'
|
content: '#TEST COMMENT WITHOUT NEWLINE'
|
||||||
dest: /tmp/test_fstab
|
dest: /tmp/test_fstab
|
||||||
|
mode: "0644"
|
||||||
- name: Mount the FS using the custom fstab
|
- name: Mount the FS using the custom fstab
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs1
|
path: /tmp/myfs1
|
||||||
src: /tmp/myfs1.img
|
src: /tmp/myfs1.img
|
||||||
fstype: ext3
|
fstype: ext3
|
||||||
|
|
@ -399,23 +505,23 @@
|
||||||
opts: defaults
|
opts: defaults
|
||||||
fstab: /tmp/test_fstab
|
fstab: /tmp/test_fstab
|
||||||
- name: Unmount the mount point in the custom fstab
|
- name: Unmount the mount point in the custom fstab
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs1
|
path: /tmp/myfs1
|
||||||
state: absent
|
state: absent
|
||||||
fstab: /tmp/test_fstab
|
fstab: /tmp/test_fstab
|
||||||
- name: Remove the test FS and the custom fstab
|
- name: Remove the test FS and the custom fstab
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ item }}'
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- /tmp/myfs1.img
|
- /tmp/myfs1.img
|
||||||
- /tmp/myfs1
|
- /tmp/myfs1
|
||||||
- /tmp/test_fstab
|
- /tmp/test_fstab
|
||||||
when: ansible_system in ('Linux')
|
|
||||||
|
|
||||||
- name: Block to test ephemeral option
|
- name: Block to test ephemeral option
|
||||||
environment:
|
environment:
|
||||||
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
when: ansible_system in ('Linux', 'SunOS', 'FreeBSD', 'NetBSD', 'OpenBSD')
|
||||||
block:
|
block:
|
||||||
- name: Create empty file A
|
- name: Create empty file A
|
||||||
community.general.filesize:
|
community.general.filesize:
|
||||||
|
|
@ -427,83 +533,10 @@
|
||||||
path: /tmp/myfs_B.img
|
path: /tmp/myfs_B.img
|
||||||
size: 20M
|
size: 20M
|
||||||
|
|
||||||
- name: Register facts on Linux
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
ephemeral_device_A: /tmp/myfs_A.img
|
|
||||||
ephemeral_device_B: /tmp/myfs_B.img
|
|
||||||
ephemeral_fstype: ext3
|
|
||||||
ephemeral_fstab: /etc/fstab
|
|
||||||
when: ansible_system == 'Linux'
|
|
||||||
|
|
||||||
- name: Register facts on Solaris/SunOS
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
ephemeral_device_A: /dev/lofi/1
|
|
||||||
ephemeral_device_B: /dev/lofi/2
|
|
||||||
ephemeral_create_loop_dev_cmd: >
|
|
||||||
lofiadm -a /tmp/myfs_A.img /dev/lofi/1 &&
|
|
||||||
lofiadm -a /tmp/myfs_B.img /dev/lofi/2
|
|
||||||
ephemeral_remove_loop_dev_cmd: >
|
|
||||||
lofiadm -d /dev/lofi/1 &&
|
|
||||||
lofiadm -d /dev/lofi/2 || true
|
|
||||||
ephemeral_fstype: ufs
|
|
||||||
ephemeral_fstab: /etc/vfstab
|
|
||||||
when: ansible_system == 'SunOS'
|
|
||||||
|
|
||||||
- name: Register facts on FreeBSD
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
ephemeral_device_A: /dev/md1
|
|
||||||
ephemeral_device_B: /dev/md2
|
|
||||||
ephemeral_create_loop_dev_cmd: >
|
|
||||||
mdconfig -a -t vnode -f /tmp/myfs_A.img -u /dev/md1 &&
|
|
||||||
mdconfig -a -t vnode -f /tmp/myfs_B.img -u /dev/md2
|
|
||||||
ephemeral_remove_loop_dev_cmd: >
|
|
||||||
mdconfig -d -u /dev/md1 &&
|
|
||||||
mdconfig -d -u /dev/md2
|
|
||||||
ephemeral_fstype: ufs
|
|
||||||
ephemeral_fstab: /etc/fstab
|
|
||||||
when: ansible_system == 'FreeBSD'
|
|
||||||
|
|
||||||
- name: Register facts on NetBSD
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
ephemeral_device_A: /dev/vnd1
|
|
||||||
ephemeral_device_B: /dev/vnd2
|
|
||||||
ephemeral_create_loop_dev_cmd: >
|
|
||||||
vnconfig /dev/vnd1 /tmp/myfs_A.img &&
|
|
||||||
vnconfig /dev/vnd2 /tmp/myfs_B.img
|
|
||||||
ephemeral_remove_loop_dev_cmd: >
|
|
||||||
vnconfig -u /dev/vnd1 &&
|
|
||||||
vnconfig -u /dev/vnd2
|
|
||||||
ephemeral_fstype: ufs
|
|
||||||
ephemeral_fstab: /etc/fstab
|
|
||||||
when: ansible_system == 'NetBSD'
|
|
||||||
|
|
||||||
- name: Register format fs command on Non-Linux and Non-OpenBSD
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
ephemeral_format_fs_cmd: >
|
|
||||||
yes | newfs {{ ephemeral_device_A }} &&
|
|
||||||
yes | newfs {{ ephemeral_device_B }}
|
|
||||||
when: ansible_system in ('SunOS', 'FreeBSD', 'NetBSD')
|
|
||||||
|
|
||||||
- name: Register facts on OpenBSD
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
ephemeral_device_A: /dev/vnd1c
|
|
||||||
ephemeral_device_B: /dev/vnd2c
|
|
||||||
ephemeral_create_loop_dev_cmd: >
|
|
||||||
vnconfig vnd1 /tmp/myfs_A.img &&
|
|
||||||
vnconfig vnd2 /tmp/myfs_B.img
|
|
||||||
ephemeral_remove_loop_dev_cmd: >
|
|
||||||
vnconfig -u vnd1 &&
|
|
||||||
vnconfig -u vnd2
|
|
||||||
ephemeral_format_fs_cmd: >
|
|
||||||
yes | newfs /dev/rvnd1c &&
|
|
||||||
yes | newfs /dev/rvnd2c
|
|
||||||
ephemeral_fstype: ffs
|
|
||||||
ephemeral_fstab: /etc/fstab
|
|
||||||
when: ansible_system == 'OpenBSD'
|
|
||||||
|
|
||||||
##### FORMAT FS ON LINUX
|
##### FORMAT FS ON LINUX
|
||||||
|
|
||||||
- name: Block to format FS on Linux
|
- name: Block to format FS on Linux
|
||||||
|
when: ansible_system == 'Linux'
|
||||||
block:
|
block:
|
||||||
- name: Format FS A on Linux
|
- name: Format FS A on Linux
|
||||||
community.general.filesystem:
|
community.general.filesystem:
|
||||||
|
|
@ -514,16 +547,21 @@
|
||||||
community.general.filesystem:
|
community.general.filesystem:
|
||||||
fstype: ext3
|
fstype: ext3
|
||||||
dev: /tmp/myfs_B.img
|
dev: /tmp/myfs_B.img
|
||||||
when: ansible_system == 'Linux'
|
|
||||||
|
|
||||||
##### FORMAT FS ON SOLARIS AND BSD
|
##### FORMAT FS ON SOLARIS AND BSD
|
||||||
|
|
||||||
- name: Create loop devices on Solaris and BSD
|
- name: Create loop devices on Solaris and BSD
|
||||||
ansible.builtin.shell: "{{ ephemeral_create_loop_dev_cmd }}"
|
ansible.builtin.shell:
|
||||||
|
cmd: "set -o pipefail && {{ ephemeral_create_loop_dev_cmd }}"
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
|
changed_when: true
|
||||||
when: ephemeral_create_loop_dev_cmd is defined
|
when: ephemeral_create_loop_dev_cmd is defined
|
||||||
|
|
||||||
- name: Format FS A and B on Solaris and BSD
|
- name: Format FS A and B on Solaris and BSD
|
||||||
ansible.builtin.shell: "{{ ephemeral_format_fs_cmd }}"
|
ansible.builtin.shell:
|
||||||
|
cmd: "set -o pipefail && {{ ephemeral_format_fs_cmd }}"
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
|
changed_when: true
|
||||||
when: ephemeral_format_fs_cmd is defined
|
when: ephemeral_format_fs_cmd is defined
|
||||||
|
|
||||||
##### TESTS
|
##### TESTS
|
||||||
|
|
@ -532,69 +570,81 @@
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ ephemeral_fstab }}"
|
path: "{{ ephemeral_fstab }}"
|
||||||
state: touch
|
state: touch
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
- name: Get checksum of /etc/fstab before mounting anything
|
- name: Get checksum of /etc/fstab before mounting anything
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: '{{ ephemeral_fstab }}'
|
path: '{{ ephemeral_fstab }}'
|
||||||
register: fstab_stat_before_mount
|
register: fstab_stat_before_mount
|
||||||
|
|
||||||
- name: Mount the FS A with ephemeral state
|
- name: Mount the FS A with ephemeral state
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: '{{ ephemeral_device_A }}'
|
src: '{{ ephemeral_device_a }}'
|
||||||
fstype: '{{ ephemeral_fstype }}'
|
fstype: '{{ ephemeral_fstype }}'
|
||||||
opts: rw
|
opts: rw
|
||||||
state: ephemeral
|
state: ephemeral
|
||||||
register: ephemeral_mount_info
|
register: ephemeral_mount_info
|
||||||
|
|
||||||
- name: Put something in the directory so we can do additional checks later on
|
- name: Put something in the directory so we can do additional checks later on
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
content: 'Testing'
|
content: 'Testing'
|
||||||
dest: /tmp/myfs/test_file
|
dest: /tmp/myfs/test_file
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
- name: Get checksum of /etc/fstab after an ephemeral mount
|
- name: Get checksum of /etc/fstab after an ephemeral mount
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: '{{ ephemeral_fstab }}'
|
path: '{{ ephemeral_fstab }}'
|
||||||
register: fstab_stat_after_mount
|
register: fstab_stat_after_mount
|
||||||
|
|
||||||
- name: Get mountinfo
|
- name: Get mountinfo
|
||||||
shell: mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
ansible.builtin.shell:
|
||||||
|
cmd: grep -c '/tmp/myfs' <(mount -v)
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
register: check_mountinfo
|
register: check_mountinfo
|
||||||
changed_when: no
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: Assert the mount occured and the fstab is unchanged
|
- name: Assert the mount occured and the fstab is unchanged
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- check_mountinfo.stdout|int == 1
|
- check_mountinfo.stdout|int == 1
|
||||||
- ephemeral_mount_info['changed']
|
- ephemeral_mount_info['changed']
|
||||||
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
||||||
|
|
||||||
- name: Get first mount record
|
- name: Get first mount record
|
||||||
shell: mount -v | grep '/tmp/myfs'
|
ansible.builtin.shell:
|
||||||
|
cmd: grep '/tmp/myfs' <(mount -v)
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
register: ephemeral_mount_record_1
|
register: ephemeral_mount_record_1
|
||||||
changed_when: no
|
changed_when: false
|
||||||
|
|
||||||
- name: Try to mount FS A where FS A is already mounted (should trigger remount and changed)
|
- name: Try to mount FS A where FS A is already mounted (should trigger remount and changed)
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: '{{ ephemeral_device_A }}'
|
src: '{{ ephemeral_device_a }}'
|
||||||
fstype: '{{ ephemeral_fstype }}'
|
fstype: '{{ ephemeral_fstype }}'
|
||||||
opts: ro
|
opts: ro
|
||||||
state: ephemeral
|
state: ephemeral
|
||||||
register: ephemeral_mount_info
|
register: ephemeral_mount_info
|
||||||
|
|
||||||
- name: Get second mount record (should be different than the first)
|
- name: Get second mount record (should be different than the first)
|
||||||
shell: mount -v | grep '/tmp/myfs'
|
ansible.builtin.shell:
|
||||||
|
cmd: grep '/tmp/myfs' <(mount -v)
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
register: ephemeral_mount_record_2
|
register: ephemeral_mount_record_2
|
||||||
changed_when: no
|
changed_when: false
|
||||||
|
|
||||||
- name: Get mountinfo
|
- name: Get mountinfo
|
||||||
shell: mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
ansible.builtin.shell:
|
||||||
|
cmd: grep -c '/tmp/myfs' <(mount -v)
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
|
failed_when: false
|
||||||
register: check_mountinfo
|
register: check_mountinfo
|
||||||
changed_when: no
|
changed_when: false
|
||||||
|
|
||||||
- name: Assert the FS A is still mounted, the options changed and the fstab unchanged
|
- name: Assert the FS A is still mounted, the options changed and the fstab unchanged
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- check_mountinfo.stdout|int == 1
|
- check_mountinfo.stdout|int == 1
|
||||||
- ephemeral_mount_record_1.stdout != ephemeral_mount_record_2.stdout
|
- ephemeral_mount_record_1.stdout != ephemeral_mount_record_2.stdout
|
||||||
|
|
@ -602,31 +652,36 @@
|
||||||
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
- fstab_stat_before_mount['stat']['checksum'] == fstab_stat_after_mount['stat']['checksum']
|
||||||
|
|
||||||
- name: Try to mount file B on file A mountpoint (should fail)
|
- name: Try to mount file B on file A mountpoint (should fail)
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
src: '{{ ephemeral_device_B }}'
|
src: '{{ ephemeral_device_b }}'
|
||||||
fstype: '{{ ephemeral_fstype }}'
|
fstype: '{{ ephemeral_fstype }}'
|
||||||
state: ephemeral
|
state: ephemeral
|
||||||
register: ephemeral_mount_b_info
|
register: ephemeral_mount_b_info
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Get third mount record (should be the same than the second)
|
- name: Get third mount record (should be the same than the second)
|
||||||
shell: mount -v | grep '/tmp/myfs'
|
ansible.builtin.shell:
|
||||||
|
cmd: grep '/tmp/myfs' <(mount -v)
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
register: ephemeral_mount_record_3
|
register: ephemeral_mount_record_3
|
||||||
changed_when: no
|
changed_when: false
|
||||||
|
|
||||||
- name: Get mountinfo
|
- name: Get mountinfo
|
||||||
shell: mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
ansible.builtin.shell:
|
||||||
|
cmd: grep -c '/tmp/myfs' <(mount -v)
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
|
failed_when: false
|
||||||
register: check_mountinfo
|
register: check_mountinfo
|
||||||
changed_when: no
|
changed_when: false
|
||||||
|
|
||||||
- name: Try to stat our test file
|
- name: Try to stat our test file
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: /tmp/myfs/test_file
|
path: /tmp/myfs/test_file
|
||||||
register: test_file_stat
|
register: test_file_stat
|
||||||
|
|
||||||
- name: Assert that mounting FS B over FS A failed
|
- name: Assert that mounting FS B over FS A failed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- check_mountinfo.stdout|int == 1
|
- check_mountinfo.stdout|int == 1
|
||||||
- ephemeral_mount_record_2.stdout == ephemeral_mount_record_3.stdout
|
- ephemeral_mount_record_2.stdout == ephemeral_mount_record_3.stdout
|
||||||
|
|
@ -634,27 +689,30 @@
|
||||||
- ephemeral_mount_b_info is failed
|
- ephemeral_mount_b_info is failed
|
||||||
|
|
||||||
- name: Unmount FS with state = unmounted
|
- name: Unmount FS with state = unmounted
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
state: unmounted
|
state: unmounted
|
||||||
|
|
||||||
- name: Get fstab checksum after unmounting an ephemeral mount with state = unmounted
|
- name: Get fstab checksum after unmounting an ephemeral mount with state = unmounted
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: '{{ ephemeral_fstab }}'
|
path: '{{ ephemeral_fstab }}'
|
||||||
register: fstab_stat_after_unmount
|
register: fstab_stat_after_unmount
|
||||||
|
|
||||||
- name: Get mountinfo
|
- name: Get mountinfo
|
||||||
shell: mount -v | awk '{print $3}' | grep '^/tmp/myfs$' | wc -l
|
ansible.builtin.shell:
|
||||||
|
cmd: grep -c '/tmp/myfs' <(mount -v)
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
register: check_mountinfo
|
register: check_mountinfo
|
||||||
changed_when: no
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: Try to stat our test file
|
- name: Try to stat our test file
|
||||||
stat:
|
ansible.builtin.stat:
|
||||||
path: /tmp/myfs/test_file
|
path: /tmp/myfs/test_file
|
||||||
register: test_file_stat
|
register: test_file_stat
|
||||||
|
|
||||||
- name: Assert that fstab is unchanged after unmounting an ephemeral mount with state = unmounted
|
- name: Assert that fstab is unchanged after unmounting an ephemeral mount with state = unmounted
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- check_mountinfo.stdout|int == 0
|
- check_mountinfo.stdout|int == 0
|
||||||
- not test_file_stat['stat']['exists']
|
- not test_file_stat['stat']['exists']
|
||||||
|
|
@ -662,20 +720,22 @@
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Unmount potential failure relicas
|
- name: Unmount potential failure relicas
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: /tmp/myfs
|
path: /tmp/myfs
|
||||||
state: unmounted
|
state: unmounted
|
||||||
|
|
||||||
- name: Remove loop devices on Solaris and BSD
|
- name: Remove loop devices on Solaris and BSD
|
||||||
ansible.builtin.shell: "{{ ephemeral_remove_loop_dev_cmd }}"
|
ansible.builtin.shell:
|
||||||
|
cmd: "set -o pipefail && {{ ephemeral_remove_loop_dev_cmd }}"
|
||||||
|
executable: "{{ shell_executable }}"
|
||||||
|
changed_when: true
|
||||||
when: ephemeral_remove_loop_dev_cmd is defined
|
when: ephemeral_remove_loop_dev_cmd is defined
|
||||||
|
|
||||||
- name: Remove the test FS
|
- name: Remove the test FS
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ item }}'
|
path: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- /tmp/myfs_A.img
|
- /tmp/myfs_A.img
|
||||||
- /tmp/myfs_B.img
|
- /tmp/myfs_B.img
|
||||||
- /tmp/myfs
|
- /tmp/myfs
|
||||||
when: ansible_system in ('Linux', 'SunOS', 'FreeBSD', 'NetBSD', 'OpenBSD')
|
|
||||||
|
|
|
||||||
|
|
@ -1,124 +1,147 @@
|
||||||
- name: ensure idempotency installed
|
---
|
||||||
package:
|
- name: Ensure idempotency installed
|
||||||
|
ansible.builtin.package:
|
||||||
name: patch
|
name: patch
|
||||||
when: ansible_distribution != "MacOSX"
|
when: ansible_distribution != "MacOSX"
|
||||||
- name: create a directory for the result
|
|
||||||
file:
|
- name: Create a directory for the result
|
||||||
dest: '{{ output_dir }}/patch'
|
ansible.builtin.file:
|
||||||
|
dest: "{{ output_dir }}/patch"
|
||||||
state: directory
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
register: result
|
register: result
|
||||||
- name: assert the directory was created
|
|
||||||
assert:
|
- name: Assert the directory was created
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.state == 'directory'
|
- result.state == 'directory'
|
||||||
- name: copy the origin file
|
|
||||||
copy:
|
- name: Copy the origin file
|
||||||
|
ansible.builtin.copy:
|
||||||
src: ./origin.txt
|
src: ./origin.txt
|
||||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||||
|
mode: "0644"
|
||||||
register: result
|
register: result
|
||||||
- name: patch the origin file in check mode
|
|
||||||
|
- name: Patch the origin file in check mode
|
||||||
check_mode: true
|
check_mode: true
|
||||||
register: result
|
register: result
|
||||||
patch:
|
ansible.posix.patch:
|
||||||
src: result.patch
|
src: result.patch
|
||||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||||
- name: verify patch the origin file in check mode
|
|
||||||
assert:
|
- name: Verify patch the origin file in check mode
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
- name: patch the origin file
|
|
||||||
|
- name: Patch the origin file
|
||||||
register: result
|
register: result
|
||||||
patch:
|
ansible.posix.patch:
|
||||||
src: result.patch
|
src: result.patch
|
||||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||||
- name: verify patch the origin file
|
|
||||||
assert:
|
- name: Verify patch the origin file
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
- name: test patch the origin file idempotency
|
|
||||||
|
- name: Test patch the origin file idempotency
|
||||||
register: result
|
register: result
|
||||||
patch:
|
ansible.posix.patch:
|
||||||
src: result.patch
|
src: result.patch
|
||||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||||
- name: verify test patch the origin file idempotency
|
- name: Verify test patch the origin file idempotency
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
- name: verify the resulted file matches expectations
|
|
||||||
copy:
|
- name: Verify the resulted file matches expectations
|
||||||
|
ansible.builtin.copy:
|
||||||
src: ./result.txt
|
src: ./result.txt
|
||||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||||
|
mode: "0644"
|
||||||
register: result
|
register: result
|
||||||
failed_when: result is changed
|
failed_when: result is changed
|
||||||
- name: patch the workfile file in check mode state absent
|
|
||||||
|
- name: Patch the workfile file in check mode state absent
|
||||||
check_mode: true
|
check_mode: true
|
||||||
register: result
|
register: result
|
||||||
patch:
|
ansible.posix.patch:
|
||||||
src: result.patch
|
src: result.patch
|
||||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||||
state: absent
|
state: absent
|
||||||
- name: verify patch the workfile file in check mode state absent
|
|
||||||
assert:
|
- name: Verify patch the workfile file in check mode state absent
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
- name: patch the workfile file state absent
|
|
||||||
|
- name: Patch the workfile file state absent
|
||||||
register: result
|
register: result
|
||||||
patch:
|
ansible.posix.patch:
|
||||||
src: result.patch
|
src: result.patch
|
||||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||||
state: absent
|
state: absent
|
||||||
- name: verify patch the workfile file state absent
|
|
||||||
assert:
|
- name: Verify patch the workfile file state absent
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
- name: patch the workfile file state absent idempotency
|
|
||||||
|
- name: Patch the workfile file state absent idempotency
|
||||||
register: result
|
register: result
|
||||||
patch:
|
ansible.posix.patch:
|
||||||
src: result.patch
|
src: result.patch
|
||||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||||
state: absent
|
state: absent
|
||||||
- name: verify patch the workfile file state absent idempotency
|
|
||||||
assert:
|
- name: Verify patch the workfile file state absent idempotency
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
- name: verify the resulted file matches expectations
|
|
||||||
copy:
|
- name: Verify the resulted file matches expectations
|
||||||
|
ansible.builtin.copy:
|
||||||
src: ./origin.txt
|
src: ./origin.txt
|
||||||
dest: '{{ output_dir }}/patch/workfile.txt'
|
dest: "{{ output_dir }}/patch/workfile.txt"
|
||||||
|
mode: "0644"
|
||||||
register: result
|
register: result
|
||||||
failed_when: result is changed
|
failed_when: result is changed
|
||||||
|
|
||||||
- name: copy the origin file whitespace
|
- name: Copy the origin file whitespace
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: ./origin.txt
|
src: ./origin.txt
|
||||||
dest: '{{ output_dir }}/patch/workfile_whitespace.txt'
|
dest: "{{ output_dir }}/patch/workfile_whitespace.txt"
|
||||||
|
mode: "0644"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: patch the origin file
|
- name: Patch the origin file
|
||||||
register: result
|
register: result
|
||||||
patch:
|
ansible.posix.patch:
|
||||||
src: result_whitespace.patch
|
src: result_whitespace.patch
|
||||||
dest: '{{ output_dir }}/patch/workfile_whitespace.txt'
|
dest: "{{ output_dir }}/patch/workfile_whitespace.txt"
|
||||||
ignore_whitespace: yes
|
ignore_whitespace: true
|
||||||
- name: verify patch the origin file
|
- name: Verify patch the origin file
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
- name: test patch the origin file idempotency
|
- name: Test patch the origin file idempotency
|
||||||
register: result
|
register: result
|
||||||
patch:
|
ansible.posix.patch:
|
||||||
src: result_whitespace.patch
|
src: result_whitespace.patch
|
||||||
dest: '{{ output_dir }}/patch/workfile_whitespace.txt'
|
dest: "{{ output_dir }}/patch/workfile_whitespace.txt"
|
||||||
ignore_whitespace: yes
|
ignore_whitespace: true
|
||||||
- name: verify test patch the origin file idempotency
|
- name: Verify test patch the origin file idempotency
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
- name: verify the resulted file matches expectations
|
- name: Verify the resulted file matches expectations
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: ./result_whitespace.txt
|
src: ./result_whitespace.txt
|
||||||
dest: '{{ output_dir }}/patch/workfile_whitespace.txt'
|
dest: "{{ output_dir }}/patch/workfile_whitespace.txt"
|
||||||
|
mode: "0644"
|
||||||
register: result
|
register: result
|
||||||
failed_when: result is changed
|
failed_when: result is changed
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
|
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
|
||||||
|
|
||||||
# This file is part of Ansible
|
# This file is part of Ansible
|
||||||
|
|
@ -15,8 +16,9 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- include_tasks: seboolean.yml
|
- name: Include_tasks for when SELinux is enabled
|
||||||
|
ansible.builtin.include_tasks: seboolean.yml
|
||||||
when:
|
when:
|
||||||
- ansible_selinux is defined
|
- ansible_selinux is defined
|
||||||
- ansible_selinux != False
|
- ansible_selinux
|
||||||
- ansible_selinux.status == 'enabled'
|
- ansible_selinux.status == 'enabled'
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
|
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
|
||||||
|
|
||||||
# This file is part of Ansible
|
# This file is part of Ansible
|
||||||
|
|
@ -15,69 +16,89 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- name: install requirements for RHEL 7 and earlier
|
- name: Install requirements for RHEL 7 and earlier
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: policycoreutils-python
|
name: policycoreutils-python
|
||||||
when:
|
when:
|
||||||
- ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('7', '<=')
|
- ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('7', '<=')
|
||||||
|
|
||||||
- name: install requirements for RHEL 8 and later
|
- name: Install requirements for RHEL 8 and later
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: policycoreutils-python-utils
|
name: policycoreutils-python-utils
|
||||||
when:
|
when:
|
||||||
- ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>=')
|
- ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>=')
|
||||||
|
|
||||||
|
- name: Get getsebool output preflight
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: set -o pipefail && semanage boolean -l | grep 'httpd_can_network_connect\W'
|
||||||
|
executable: /bin/bash
|
||||||
|
changed_when: false
|
||||||
|
register: getsebool_output_preflight
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
shell: setsebool -P httpd_can_network_connect 0
|
ansible.builtin.shell:
|
||||||
##########################################################################################
|
cmd: set -o pipefail && setsebool -P httpd_can_network_connect 0
|
||||||
- name: set flag and don't keep it persistent
|
executable: /bin/bash
|
||||||
seboolean:
|
changed_when: getsebool_output_preflight.stdout.startswith('httpd_can_network_connect --> on')
|
||||||
|
|
||||||
|
- name: Set flag and don't keep it persistent
|
||||||
|
ansible.posix.seboolean:
|
||||||
name: httpd_can_network_connect
|
name: httpd_can_network_connect
|
||||||
state: yes
|
state: true
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getsebool output
|
- name: Get getsebool output
|
||||||
shell: semanage boolean -l | grep 'httpd_can_network_connect\W'
|
ansible.builtin.shell:
|
||||||
|
cmd: set -o pipefail && semanage boolean -l | grep 'httpd_can_network_connect\W'
|
||||||
|
executable: /bin/bash
|
||||||
|
changed_when: false
|
||||||
register: getsebool_output
|
register: getsebool_output
|
||||||
|
|
||||||
- name: check output
|
- name: Check output
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is changed
|
- output is changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
- output.name == 'httpd_can_network_connect'
|
- output.name == 'httpd_can_network_connect'
|
||||||
- getsebool_output.stdout.startswith('httpd_can_network_connect (on , off)')
|
- getsebool_output.stdout.startswith('httpd_can_network_connect (on , off)')
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
- name: unset flag
|
- name: Unset flag
|
||||||
seboolean:
|
ansible.posix.seboolean:
|
||||||
name: httpd_can_network_connect
|
name: httpd_can_network_connect
|
||||||
state: no
|
state: false
|
||||||
|
|
||||||
- name: get getsebool output
|
- name: Get getsebool output
|
||||||
shell: semanage boolean -l | grep 'httpd_can_network_connect\W'
|
ansible.builtin.shell:
|
||||||
|
cmd: set -o pipefail && semanage boolean -l | grep 'httpd_can_network_connect\W'
|
||||||
|
executable: /bin/bash
|
||||||
|
changed_when: false
|
||||||
register: getsebool_output
|
register: getsebool_output
|
||||||
|
|
||||||
- name: check output
|
- name: Check output
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is changed
|
- output is changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
- output.name == 'httpd_can_network_connect'
|
- output.name == 'httpd_can_network_connect'
|
||||||
- getsebool_output.stdout.startswith('httpd_can_network_connect (off , off)')
|
- getsebool_output.stdout.startswith('httpd_can_network_connect (off , off)')
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
- name: set flag and keep it persistent
|
- name: Set flag and keep it persistent
|
||||||
seboolean:
|
ansible.posix.seboolean:
|
||||||
name: httpd_can_network_connect
|
name: httpd_can_network_connect
|
||||||
state: yes
|
state: true
|
||||||
persistent: yes
|
persistent: true
|
||||||
register: output
|
register: output
|
||||||
|
|
||||||
- name: get getsebool output
|
- name: Get getsebool output
|
||||||
shell: semanage boolean -l | grep 'httpd_can_network_connect\W'
|
ansible.builtin.shell:
|
||||||
|
cmd: set -o pipefail && semanage boolean -l | grep 'httpd_can_network_connect\W'
|
||||||
|
executable: /bin/bash
|
||||||
|
changed_when: false
|
||||||
register: getsebool_output
|
register: getsebool_output
|
||||||
|
|
||||||
- name: check output
|
- name: Check output
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- output is changed
|
- output is changed
|
||||||
- output is not failed
|
- output is not failed
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# (c) 2017, Sam Doran <sdoran@redhat.com>
|
# (c) 2017, Sam Doran <sdoran@redhat.com>
|
||||||
|
|
||||||
# This file is part of Ansible
|
# This file is part of Ansible
|
||||||
|
|
@ -15,22 +16,26 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
- debug:
|
- name: Debug message for when SELinux is disabled
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: SELinux is disabled
|
msg: SELinux is disabled
|
||||||
when: ansible_selinux is defined and ansible_selinux == False
|
when: ansible_selinux is defined and not ansible_selinux
|
||||||
|
|
||||||
- debug:
|
- name: Debug message for when SELinux is enabled and not disabled
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: SELinux is {{ ansible_selinux.status }}
|
msg: SELinux is {{ ansible_selinux.status }}
|
||||||
when: ansible_selinux is defined and ansible_selinux != False
|
when: ansible_selinux is defined and ansible_selinux
|
||||||
|
|
||||||
- include_tasks: selinux.yml
|
- name: Include_tasks for when SELinux is enabled
|
||||||
|
ansible.builtin.include_tasks: selinux.yml
|
||||||
when:
|
when:
|
||||||
- ansible_selinux is defined
|
- ansible_selinux is defined
|
||||||
- ansible_selinux != False
|
- ansible_selinux
|
||||||
- ansible_selinux.status == 'enabled'
|
- ansible_selinux.status == 'enabled'
|
||||||
|
|
||||||
- include_tasks: selogin.yml
|
- name: Include tasks for selogin when SELinux is enabled
|
||||||
|
ansible.builtin.include_tasks: selogin.yml
|
||||||
when:
|
when:
|
||||||
- ansible_selinux is defined
|
- ansible_selinux is defined
|
||||||
- ansible_selinux != False
|
- ansible_selinux
|
||||||
- ansible_selinux.status == 'enabled'
|
- ansible_selinux.status == 'enabled'
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# (c) 2017, Sam Doran <sdoran@redhat.com>
|
# (c) 2017, Sam Doran <sdoran@redhat.com>
|
||||||
|
|
||||||
# This file is part of Ansible
|
# This file is part of Ansible
|
||||||
|
|
@ -14,67 +15,67 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
# First Test
|
# First Test
|
||||||
# ##############################################################################
|
# ##############################################################################
|
||||||
# Test changing the state, which requires a reboot
|
# Test changing the state, which requires a reboot
|
||||||
|
|
||||||
- name: TEST 1 | Make sure grubby is present
|
- name: TEST 1 | Make sure grubby is present
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: grubby
|
name: grubby
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: TEST 1 | Get current SELinux config file contents
|
- name: TEST 1 | Get current SELinux config file contents
|
||||||
slurp:
|
ansible.builtin.slurp:
|
||||||
src: /etc/sysconfig/selinux
|
src: /etc/sysconfig/selinux
|
||||||
register: selinux_config_original_base64
|
register: selinux_config_original_base64
|
||||||
|
|
||||||
- name: TEST 1 | Register SELinux config and SELinux status
|
- name: TEST 1 | Register SELinux config and SELinux status
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
selinux_config_original_raw: "{{ selinux_config_original_base64.content | b64decode }}"
|
selinux_config_original_raw: "{{ selinux_config_original_base64.content | b64decode }}"
|
||||||
before_test_sestatus: "{{ ansible_selinux }}"
|
before_test_sestatus: "{{ ansible_selinux }}"
|
||||||
|
|
||||||
- name: TEST 1 | Split by line and register original config
|
- name: TEST 1 | Split by line and register original config
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
selinux_config_original: "{{ selinux_config_original_raw.split('\n') }}"
|
selinux_config_original: "{{ selinux_config_original_raw.split('\n') }}"
|
||||||
|
|
||||||
- debug:
|
- name: TEST 1 | Debug selinux_config_original, before_test_sestatus, and ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: "{{ item }}"
|
var: "{{ item }}"
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
with_items:
|
loop:
|
||||||
- selinux_config_original
|
- selinux_config_original
|
||||||
- before_test_sestatus
|
- before_test_sestatus
|
||||||
- ansible_selinux
|
- ansible_selinux
|
||||||
|
|
||||||
- name: TEST 1 | Setup SELinux configuration for tests
|
- name: TEST 1 | Setup SELinux configuration for tests
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: targeted
|
policy: targeted
|
||||||
|
|
||||||
- name: TEST 1 | Disable SELinux
|
- name: TEST 1 | Disable SELinux
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: disabled
|
state: disabled
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _disable_test1
|
register: _disable_test1
|
||||||
|
|
||||||
- debug:
|
- name: TEST 1 | Debug _disable_test1
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _disable_test1
|
var: _disable_test1
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: Before gathering the fact
|
- name: Before gathering the fact
|
||||||
debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ ansible_selinux }}"
|
msg: "{{ ansible_selinux }}"
|
||||||
|
|
||||||
- name: TEST 1 | Re-gather facts
|
- name: TEST 1 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- name: After gathering the fact
|
- name: After gathering the fact
|
||||||
debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ ansible_selinux }}"
|
msg: "{{ ansible_selinux }}"
|
||||||
|
|
||||||
- name: TEST 1 | Assert that status was changed, reboot_required is True, a warning was displayed, and SELinux is configured properly
|
- name: TEST 1 | Assert that status was changed, reboot_required is True, a warning was displayed, and SELinux is configured properly
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _disable_test1 is changed
|
- _disable_test1 is changed
|
||||||
- _disable_test1.reboot_required
|
- _disable_test1.reboot_required
|
||||||
|
|
@ -82,53 +83,56 @@
|
||||||
- ansible_selinux.config_mode == 'disabled'
|
- ansible_selinux.config_mode == 'disabled'
|
||||||
- ansible_selinux.type == 'targeted'
|
- ansible_selinux.type == 'targeted'
|
||||||
|
|
||||||
- debug:
|
- name: TEST 1 | Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 1 | Disable SELinux again
|
- name: TEST 1 | Disable SELinux again
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: disabled
|
state: disabled
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _disable_test2
|
register: _disable_test2
|
||||||
|
|
||||||
- debug:
|
- name: Test 1 | Debug _disable_test2
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _disable_test2
|
var: _disable_test2
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 1 | Assert that no change is reported, a warning was displayed, and reboot_required is True
|
- name: TEST 1 | Assert that no change is reported, a warning was displayed, and reboot_required is True
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _disable_test2 is not changed
|
- _disable_test2 is not changed
|
||||||
- (_disable_test1.warnings | length ) >= 1
|
- (_disable_test1.warnings | length ) >= 1
|
||||||
- _disable_test2.reboot_required
|
- _disable_test2.reboot_required
|
||||||
|
|
||||||
- name: TEST 1 | Get modified config file
|
- name: TEST 1 | Get modified config file
|
||||||
slurp:
|
ansible.builtin.slurp:
|
||||||
src: /etc/sysconfig/selinux
|
src: /etc/sysconfig/selinux
|
||||||
register: selinux_config_after_base64
|
register: selinux_config_after_base64
|
||||||
|
|
||||||
- name: TEST 1 | Register modified config
|
- name: TEST 1 | Register modified config
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
selinux_config_after_raw: "{{ selinux_config_after_base64.content | b64decode }}"
|
selinux_config_after_raw: "{{ selinux_config_after_base64.content | b64decode }}"
|
||||||
|
|
||||||
- name: TEST 1 | Split by line and register modified config
|
- name: TEST 1 | Split by line and register modified config
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
selinux_config_after: "{{ selinux_config_after_raw.split('\n') }}"
|
selinux_config_after: "{{ selinux_config_after_raw.split('\n') }}"
|
||||||
|
|
||||||
- debug:
|
- name: TEST 1 | Debug selinux_config_after
|
||||||
|
ansible.builtin.debug:
|
||||||
var: selinux_config_after
|
var: selinux_config_after
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 1 | Ensure SELinux config file is properly formatted
|
- name: TEST 1 | Ensure SELinux config file is properly formatted
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- selinux_config_original | length == selinux_config_after | length
|
- selinux_config_original | length == selinux_config_after | length
|
||||||
- selinux_config_after[selinux_config_after.index('SELINUX=disabled')] is search("^SELINUX=\w+$")
|
- selinux_config_after[selinux_config_after.index('SELINUX=disabled')] is search("^SELINUX=\w+$")
|
||||||
- selinux_config_after[selinux_config_after.index('SELINUXTYPE=targeted')] is search("^SELINUXTYPE=\w+$")
|
- selinux_config_after[selinux_config_after.index('SELINUXTYPE=targeted')] is search("^SELINUXTYPE=\w+$")
|
||||||
|
|
||||||
- name: TEST 1 | Disable SELinux again, with kernel arguments update
|
- name: TEST 1 | Disable SELinux again, with kernel arguments update
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: disabled
|
state: disabled
|
||||||
policy: targeted
|
policy: targeted
|
||||||
update_kernel_param: true
|
update_kernel_param: true
|
||||||
|
|
@ -136,72 +140,76 @@
|
||||||
|
|
||||||
- name: Check kernel command-line arguments
|
- name: Check kernel command-line arguments
|
||||||
ansible.builtin.command: grubby --info=DEFAULT
|
ansible.builtin.command: grubby --info=DEFAULT
|
||||||
|
changed_when: false
|
||||||
register: _grubby_test1
|
register: _grubby_test1
|
||||||
|
|
||||||
- name: TEST 1 | Assert that kernel cmdline contains selinux=0
|
- name: TEST 1 | Assert that kernel cmdline contains selinux=0
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "' selinux=0' in _grubby_test1.stdout"
|
- "' selinux=0' in _grubby_test1.stdout"
|
||||||
|
|
||||||
- name: TEST 1 | Enable SELinux, without kernel arguments update
|
- name: TEST 1 | Enable SELinux, without kernel arguments update
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: disabled
|
state: disabled
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _disable_test2
|
register: _disable_test2
|
||||||
|
|
||||||
- name: Check kernel command-line arguments
|
- name: Check kernel command-line arguments
|
||||||
ansible.builtin.command: grubby --info=DEFAULT
|
ansible.builtin.command: grubby --info=DEFAULT
|
||||||
|
changed_when: false
|
||||||
register: _grubby_test1
|
register: _grubby_test1
|
||||||
|
|
||||||
- name: TEST 1 | Assert that kernel cmdline still contains selinux=0
|
- name: TEST 1 | Assert that kernel cmdline still contains selinux=0
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "' selinux=0' in _grubby_test1.stdout"
|
- "' selinux=0' in _grubby_test1.stdout"
|
||||||
|
|
||||||
- name: TEST 1 | Reset SELinux configuration for next test (also kernel args)
|
- name: TEST 1 | Reset SELinux configuration for next test (also kernel args)
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
update_kernel_param: true
|
update_kernel_param: true
|
||||||
policy: targeted
|
policy: targeted
|
||||||
|
|
||||||
- name: Check kernel command-line arguments
|
- name: Check kernel command-line arguments
|
||||||
ansible.builtin.command: grubby --info=DEFAULT
|
ansible.builtin.command: grubby --info=DEFAULT
|
||||||
|
changed_when: false
|
||||||
register: _grubby_test2
|
register: _grubby_test2
|
||||||
|
|
||||||
- name: TEST 1 | Assert that kernel cmdline doesn't contain selinux=0
|
- name: TEST 1 | Assert that kernel cmdline doesn't contain selinux=0
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "' selinux=0' not in _grubby_test2.stdout"
|
- "' selinux=0' not in _grubby_test2.stdout"
|
||||||
|
|
||||||
|
|
||||||
# Second Test
|
# Second Test
|
||||||
# ##############################################################################
|
# ##############################################################################
|
||||||
# Test changing only the policy, which does not require a reboot
|
# Test changing only the policy, which does not require a reboot
|
||||||
|
|
||||||
- name: TEST 2 | Make sure the policy is present
|
- name: TEST 2 | Make sure the policy is present
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: selinux-policy-mls
|
name: selinux-policy-mls
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: TEST 2 | Set SELinux policy
|
- name: TEST 2 | Set SELinux policy
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: mls
|
policy: mls
|
||||||
register: _state_test1
|
register: _state_test1
|
||||||
|
|
||||||
- debug:
|
- name: TEST 2 | Debug _state_test1
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _state_test1
|
var: _state_test1
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 2 | Re-gather facts
|
- name: TEST 2 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- debug:
|
- name: TEST 2 | Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
tags: debug
|
tags: debug
|
||||||
|
|
||||||
- name: TEST 2 | Assert that status was changed, reboot_required is False, no warnings were displayed, and SELinux is configured properly
|
- name: TEST 2 | Assert that status was changed, reboot_required is False, no warnings were displayed, and SELinux is configured properly
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _state_test1 is changed
|
- _state_test1 is changed
|
||||||
- not _state_test1.reboot_required
|
- not _state_test1.reboot_required
|
||||||
|
|
@ -210,76 +218,79 @@
|
||||||
- ansible_selinux.type == 'mls'
|
- ansible_selinux.type == 'mls'
|
||||||
|
|
||||||
- name: TEST 2 | Set SELinux policy again
|
- name: TEST 2 | Set SELinux policy again
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: mls
|
policy: mls
|
||||||
register: _state_test2
|
register: _state_test2
|
||||||
|
|
||||||
- debug:
|
- name: TEST 2 | Debug _state_test2
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _state_test2
|
var: _state_test2
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 2 | Assert that no change was reported, no warnings were displayed, and reboot_required is False
|
- name: TEST 2 | Assert that no change was reported, no warnings were displayed, and reboot_required is False
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _state_test2 is not changed
|
- _state_test2 is not changed
|
||||||
- _state_test2.warnings is not defined
|
- _state_test2.warnings is not defined
|
||||||
- not _state_test2.reboot_required
|
- not _state_test2.reboot_required
|
||||||
|
|
||||||
- name: TEST 2 | Get modified config file
|
- name: TEST 2 | Get modified config file
|
||||||
slurp:
|
ansible.builtin.slurp:
|
||||||
src: /etc/sysconfig/selinux
|
src: /etc/sysconfig/selinux
|
||||||
register: selinux_config_after_base64
|
register: selinux_config_after_base64
|
||||||
|
|
||||||
- name: TEST 2 | Register modified config
|
- name: TEST 2 | Register modified config
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
selinux_config_after_raw: "{{ selinux_config_after_base64.content | b64decode }}"
|
selinux_config_after_raw: "{{ selinux_config_after_base64.content | b64decode }}"
|
||||||
|
|
||||||
- name: TEST 2 | Split by line and register modified config
|
- name: TEST 2 | Split by line and register modified config
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
selinux_config_after: "{{ selinux_config_after_raw.split('\n') }}"
|
selinux_config_after: "{{ selinux_config_after_raw.split('\n') }}"
|
||||||
|
|
||||||
- debug:
|
- name: TEST 2 | Debug selinux_config_after
|
||||||
|
ansible.builtin.debug:
|
||||||
var: selinux_config_after
|
var: selinux_config_after
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 2 | Ensure SELinux config file is properly formatted
|
- name: TEST 2 | Ensure SELinux config file is properly formatted
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- selinux_config_original | length == selinux_config_after | length
|
- selinux_config_original | length == selinux_config_after | length
|
||||||
- selinux_config_after[selinux_config_after.index('SELINUX=enforcing')] is search("^SELINUX=\w+$")
|
- selinux_config_after[selinux_config_after.index('SELINUX=enforcing')] is search("^SELINUX=\w+$")
|
||||||
- selinux_config_after[selinux_config_after.index('SELINUXTYPE=mls')] is search("^SELINUXTYPE=\w+$")
|
- selinux_config_after[selinux_config_after.index('SELINUXTYPE=mls')] is search("^SELINUXTYPE=\w+$")
|
||||||
|
|
||||||
- name: TEST 2 | Reset SELinux configuration for next test
|
- name: TEST 2 | Reset SELinux configuration for next test
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: targeted
|
policy: targeted
|
||||||
|
|
||||||
|
|
||||||
# Third Test
|
# Third Test
|
||||||
# ##############################################################################
|
# ##############################################################################
|
||||||
# Test changing non-existing policy
|
# Test changing non-existing policy
|
||||||
|
|
||||||
- name: TEST 3 | Set SELinux policy
|
- name: TEST 3 | Set SELinux policy
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: non-existing-selinux-policy
|
policy: non-existing-selinux-policy
|
||||||
register: _state_test1
|
register: _state_test1
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
|
|
||||||
- debug:
|
- name: TEST 3 | Debug _state_test1
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _state_test1
|
var: _state_test1
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 3 | Re-gather facts
|
- name: TEST 3 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- debug:
|
- name: TEST3 | Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
tags: debug
|
tags: debug
|
||||||
|
|
||||||
- name: TEST 3 | Assert that status was not changed, the task failed, the msg contains proper information and SELinux was not changed
|
- name: TEST 3 | Assert that status was not changed, the task failed, the msg contains proper information and SELinux was not changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _state_test1 is not changed
|
- _state_test1 is not changed
|
||||||
- _state_test1 is failed
|
- _state_test1 is failed
|
||||||
|
|
@ -287,40 +298,40 @@
|
||||||
- ansible_selinux.config_mode == 'enforcing'
|
- ansible_selinux.config_mode == 'enforcing'
|
||||||
- ansible_selinux.type == 'targeted'
|
- ansible_selinux.type == 'targeted'
|
||||||
|
|
||||||
|
|
||||||
# Fourth Test
|
# Fourth Test
|
||||||
# ##############################################################################
|
# ##############################################################################
|
||||||
# Test if check mode returns correct changed values and
|
# Test if check mode returns correct changed values and
|
||||||
# doesn't make any changes
|
# doesn't make any changes
|
||||||
|
|
||||||
|
|
||||||
- name: TEST 4 | Set SELinux to enforcing
|
- name: TEST 4 | Set SELinux to enforcing
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _check_mode_test1
|
register: _check_mode_test1
|
||||||
|
|
||||||
- debug:
|
- name: TEST 4 | Debug _check_mode_test1
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _check_mode_test1
|
var: _check_mode_test1
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 4 | Set SELinux to enforcing in check mode
|
- name: TEST 4 | Set SELinux to enforcing in check mode
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _check_mode_test1
|
register: _check_mode_test1
|
||||||
check_mode: yes
|
check_mode: true
|
||||||
|
|
||||||
- name: TEST 4 | Re-gather facts
|
- name: TEST 4 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- debug:
|
- name: TEST 4| Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
tags: debug
|
tags: debug
|
||||||
|
|
||||||
- name: TEST 4 | Assert that check mode is idempotent
|
- name: TEST 4 | Assert that check mode is idempotent
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _check_mode_test1 is success
|
- _check_mode_test1 is success
|
||||||
- not _check_mode_test1.reboot_required
|
- not _check_mode_test1.reboot_required
|
||||||
|
|
@ -328,22 +339,23 @@
|
||||||
- ansible_selinux.type == 'targeted'
|
- ansible_selinux.type == 'targeted'
|
||||||
|
|
||||||
- name: TEST 4 | Set SELinux to permissive in check mode
|
- name: TEST 4 | Set SELinux to permissive in check mode
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: permissive
|
state: permissive
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _check_mode_test2
|
register: _check_mode_test2
|
||||||
check_mode: yes
|
check_mode: true
|
||||||
|
|
||||||
- name: TEST 4 | Re-gather facts
|
- name: TEST 4 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- debug:
|
- name: TEST 4 | Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
tags: debug
|
tags: debug
|
||||||
|
|
||||||
- name: TEST 4 | Assert that check mode doesn't set state permissive and returns changed
|
- name: TEST 4 | Assert that check mode doesn't set state permissive and returns changed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _check_mode_test2 is changed
|
- _check_mode_test2 is changed
|
||||||
- not _check_mode_test2.reboot_required
|
- not _check_mode_test2.reboot_required
|
||||||
|
|
@ -351,21 +363,22 @@
|
||||||
- ansible_selinux.type == 'targeted'
|
- ansible_selinux.type == 'targeted'
|
||||||
|
|
||||||
- name: TEST 4 | Disable SELinux in check mode
|
- name: TEST 4 | Disable SELinux in check mode
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: disabled
|
state: disabled
|
||||||
register: _check_mode_test3
|
register: _check_mode_test3
|
||||||
check_mode: yes
|
check_mode: true
|
||||||
|
|
||||||
- name: TEST 4 | Re-gather facts
|
- name: TEST 4 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- debug:
|
- name: TEST 4 | Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
tags: debug
|
tags: debug
|
||||||
|
|
||||||
- name: TEST 4 | Assert that check mode didn't change anything, status is changed, reboot_required is True, a warning was displayed
|
- name: TEST 4 | Assert that check mode didn't change anything, status is changed, reboot_required is True, a warning was displayed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _check_mode_test3 is changed
|
- _check_mode_test3 is changed
|
||||||
- _check_mode_test3.reboot_required
|
- _check_mode_test3.reboot_required
|
||||||
|
|
@ -374,31 +387,33 @@
|
||||||
- ansible_selinux.type == 'targeted'
|
- ansible_selinux.type == 'targeted'
|
||||||
|
|
||||||
- name: TEST 4 | Set SELinux to permissive
|
- name: TEST 4 | Set SELinux to permissive
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: permissive
|
state: permissive
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _check_mode_test4
|
register: _check_mode_test4
|
||||||
|
|
||||||
- debug:
|
- name: TEST 4 | Debug _check_mode_test4
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _check_mode_test4
|
var: _check_mode_test4
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 4 | Disable SELinux in check mode
|
- name: TEST 4 | Disable SELinux in check mode
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: disabled
|
state: disabled
|
||||||
register: _check_mode_test4
|
register: _check_mode_test4
|
||||||
check_mode: yes
|
check_mode: true
|
||||||
|
|
||||||
- name: TEST 4 | Re-gather facts
|
- name: TEST 4 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- debug:
|
- name: TEST 4 | Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
tags: debug
|
tags: debug
|
||||||
|
|
||||||
- name: TEST 4 | Assert that check mode didn't change anything, status is changed, reboot_required is True, a warning was displayed
|
- name: TEST 4 | Assert that check mode didn't change anything, status is changed, reboot_required is True, a warning was displayed
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _check_mode_test4 is changed
|
- _check_mode_test4 is changed
|
||||||
- _check_mode_test4.reboot_required
|
- _check_mode_test4.reboot_required
|
||||||
|
|
@ -407,36 +422,38 @@
|
||||||
- ansible_selinux.type == 'targeted'
|
- ansible_selinux.type == 'targeted'
|
||||||
|
|
||||||
- name: TEST 4 | Set SELinux to enforcing
|
- name: TEST 4 | Set SELinux to enforcing
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _check_mode_test5
|
register: _check_mode_test5
|
||||||
|
|
||||||
- debug:
|
- name: TEST 4 | Debug _check_mode_test5
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _check_mode_test5
|
var: _check_mode_test5
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 4 | Disable SELinux
|
- name: TEST 4 | Disable SELinux
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: disabled
|
state: disabled
|
||||||
register: _check_mode_test5
|
register: _check_mode_test5
|
||||||
|
|
||||||
- name: TEST 4 | Disable SELinux in check mode
|
- name: TEST 4 | Disable SELinux in check mode
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: disabled
|
state: disabled
|
||||||
register: _check_mode_test5
|
register: _check_mode_test5
|
||||||
check_mode: yes
|
check_mode: true
|
||||||
|
|
||||||
- name: TEST 4 | Re-gather facts
|
- name: TEST 4 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- debug:
|
- name: TEST 4 | Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
tags: debug
|
tags: debug
|
||||||
|
|
||||||
- name: TEST 4 | Assert that in check mode status was not changed, reboot_required is True, a warning was displayed, and SELinux is configured properly
|
- name: TEST 4 | Assert that in check mode status was not changed, reboot_required is True, a warning was displayed, and SELinux is configured properly
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _check_mode_test5 is success
|
- _check_mode_test5 is success
|
||||||
- _check_mode_test5.reboot_required
|
- _check_mode_test5.reboot_required
|
||||||
|
|
@ -450,32 +467,34 @@
|
||||||
# sure the module re-adds the expected lines
|
# sure the module re-adds the expected lines
|
||||||
|
|
||||||
- name: TEST 5 | Remove SELINUX key from /etc/selinux/config
|
- name: TEST 5 | Remove SELINUX key from /etc/selinux/config
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/selinux/config
|
path: /etc/selinux/config
|
||||||
regexp: '^SELINUX='
|
regexp: ^SELINUX=
|
||||||
state: absent
|
state: absent
|
||||||
backup: yes
|
backup: true
|
||||||
register: _lineinfile_out1
|
register: _lineinfile_out1
|
||||||
|
|
||||||
- debug:
|
- name: TEST 5 | Debug _lineinfile_out1
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _lineinfile_out1
|
var: _lineinfile_out1
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 5 | Set SELinux to enforcing
|
- name: TEST 5 | Set SELinux to enforcing
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _set_enforcing1
|
register: _set_enforcing1
|
||||||
|
|
||||||
- name: TEST 5 | Re-gather facts
|
- name: TEST 5 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- debug:
|
- name: TEST 5 | Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 5 | Assert that SELINUX key is populated
|
- name: TEST 5 | Assert that SELINUX key is populated
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _set_enforcing1 is success
|
- _set_enforcing1 is success
|
||||||
- _set_enforcing1 is changed
|
- _set_enforcing1 is changed
|
||||||
|
|
@ -483,31 +502,33 @@
|
||||||
- ansible_selinux.config_mode == 'enforcing'
|
- ansible_selinux.config_mode == 'enforcing'
|
||||||
|
|
||||||
- name: TEST 5 | Remove SELINUXTYPE key from /etc/selinux/config
|
- name: TEST 5 | Remove SELINUXTYPE key from /etc/selinux/config
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/selinux/config
|
path: /etc/selinux/config
|
||||||
regexp: '^SELINUXTYPE='
|
regexp: ^SELINUXTYPE=
|
||||||
state: absent
|
state: absent
|
||||||
register: _lineinfile_out2
|
register: _lineinfile_out2
|
||||||
|
|
||||||
- debug:
|
- name: TEST 5 | Debug _lineinfile_out2
|
||||||
|
ansible.builtin.debug:
|
||||||
var: _lineinfile_out2
|
var: _lineinfile_out2
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 5 | Set SELinux Policy to targeted
|
- name: TEST 5 | Set SELinux Policy to targeted
|
||||||
selinux:
|
ansible.posix.selinux:
|
||||||
state: enforcing
|
state: enforcing
|
||||||
policy: targeted
|
policy: targeted
|
||||||
register: _set_policy2
|
register: _set_policy2
|
||||||
|
|
||||||
- name: TEST 5 | Re-gather facts
|
- name: TEST 5 | Re-gather facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- debug:
|
- name: TEST 5 | Debug ansible_selinux
|
||||||
|
ansible.builtin.debug:
|
||||||
var: ansible_selinux
|
var: ansible_selinux
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: TEST 5 | Assert that SELINUXTYPE key is populated
|
- name: TEST 5 | Assert that SELINUXTYPE key is populated
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- _set_policy2 is success
|
- _set_policy2 is success
|
||||||
- _set_policy2 is changed
|
- _set_policy2 is changed
|
||||||
|
|
@ -515,7 +536,8 @@
|
||||||
- ansible_selinux.type == 'targeted'
|
- ansible_selinux.type == 'targeted'
|
||||||
|
|
||||||
- name: TEST 5 | Restore original SELinux config file /etc/selinux/config
|
- name: TEST 5 | Restore original SELinux config file /etc/selinux/config
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
dest: /etc/selinux/config
|
dest: /etc/selinux/config
|
||||||
src: "{{ _lineinfile_out1['backup'] }}"
|
src: "{{ _lineinfile_out1['backup'] }}"
|
||||||
remote_src: yes
|
remote_src: true
|
||||||
|
mode: "0644"
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
- name: create user for testing
|
---
|
||||||
user:
|
- name: Create user for testing
|
||||||
|
ansible.builtin.user:
|
||||||
name: seuser
|
name: seuser
|
||||||
- name: attempt to add mapping without 'seuser'
|
- name: Attempt to add mapping without 'seuser'
|
||||||
register: selogin_error
|
register: selogin_error
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
community.general.system.selogin:
|
community.general.system.selogin:
|
||||||
login: seuser
|
login: seuser
|
||||||
- name: verify failure
|
- name: Verify failure
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- selogin_error is failed
|
- selogin_error is failed
|
||||||
- name: map login to SELinux user
|
- name: Map login to SELinux user
|
||||||
register: selogin_new_mapping
|
register: selogin_new_mapping
|
||||||
check_mode: '{{ item }}'
|
check_mode: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
- true
|
- true
|
||||||
- false
|
- false
|
||||||
|
|
@ -21,16 +22,16 @@
|
||||||
community.general.system.selogin:
|
community.general.system.selogin:
|
||||||
login: seuser
|
login: seuser
|
||||||
seuser: staff_u
|
seuser: staff_u
|
||||||
- name: new mapping- verify functionality and check_mode
|
- name: New mapping- verify functionality and check_mode
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- selogin_new_mapping.results[0] is changed
|
- selogin_new_mapping.results[0] is changed
|
||||||
- selogin_new_mapping.results[1] is changed
|
- selogin_new_mapping.results[1] is changed
|
||||||
- selogin_new_mapping.results[2] is not changed
|
- selogin_new_mapping.results[2] is not changed
|
||||||
- selogin_new_mapping.results[3] is not changed
|
- selogin_new_mapping.results[3] is not changed
|
||||||
- name: change SELinux user login mapping
|
- name: Change SELinux user login mapping
|
||||||
register: selogin_mod_mapping
|
register: selogin_mod_mapping
|
||||||
check_mode: '{{ item }}'
|
check_mode: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
- true
|
- true
|
||||||
- false
|
- false
|
||||||
|
|
@ -39,16 +40,16 @@
|
||||||
community.general.system.selogin:
|
community.general.system.selogin:
|
||||||
login: seuser
|
login: seuser
|
||||||
seuser: user_u
|
seuser: user_u
|
||||||
- name: changed mapping- verify functionality and check_mode
|
- name: Changed mapping- verify functionality and check_mode
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- selogin_mod_mapping.results[0] is changed
|
- selogin_mod_mapping.results[0] is changed
|
||||||
- selogin_mod_mapping.results[1] is changed
|
- selogin_mod_mapping.results[1] is changed
|
||||||
- selogin_mod_mapping.results[2] is not changed
|
- selogin_mod_mapping.results[2] is not changed
|
||||||
- selogin_mod_mapping.results[3] is not changed
|
- selogin_mod_mapping.results[3] is not changed
|
||||||
- name: remove SELinux user mapping
|
- name: Remove SELinux user mapping
|
||||||
register: selogin_del_mapping
|
register: selogin_del_mapping
|
||||||
check_mode: '{{ item }}'
|
check_mode: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
- true
|
- true
|
||||||
- false
|
- false
|
||||||
|
|
@ -57,14 +58,14 @@
|
||||||
community.general.system.selogin:
|
community.general.system.selogin:
|
||||||
login: seuser
|
login: seuser
|
||||||
state: absent
|
state: absent
|
||||||
- name: delete mapping- verify functionality and check_mode
|
- name: Delete mapping- verify functionality and check_mode
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- selogin_del_mapping.results[0] is changed
|
- selogin_del_mapping.results[0] is changed
|
||||||
- selogin_del_mapping.results[1] is changed
|
- selogin_del_mapping.results[1] is changed
|
||||||
- selogin_del_mapping.results[2] is not changed
|
- selogin_del_mapping.results[2] is not changed
|
||||||
- selogin_del_mapping.results[3] is not changed
|
- selogin_del_mapping.results[3] is not changed
|
||||||
- name: remove test user
|
- name: Remove test user
|
||||||
user:
|
ansible.builtin.user:
|
||||||
name: seuser
|
name: seuser
|
||||||
state: absent
|
state: absent
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,16 @@
|
||||||
# and should not be used as examples of how to write Ansible roles #
|
# and should not be used as examples of how to write Ansible roles #
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
||||||
- set_fact:
|
- name: Set pkg_mgr and ansible_pkg_mgr on FreeBSD
|
||||||
|
ansible.builtin.set_fact:
|
||||||
pkg_mgr: community.general.pkgng
|
pkg_mgr: community.general.pkgng
|
||||||
ansible_pkg_mgr: community.general.pkgng
|
ansible_pkg_mgr: community.general.pkgng
|
||||||
cacheable: yes
|
cacheable: true
|
||||||
when: ansible_os_family == "FreeBSD"
|
when: ansible_os_family == "FreeBSD"
|
||||||
|
|
||||||
- set_fact:
|
- name: Set pkg_mgr and ansible_pkg_mgr on Suse
|
||||||
|
ansible.builtin.set_fact:
|
||||||
pkg_mgr: community.general.zypper
|
pkg_mgr: community.general.zypper
|
||||||
ansible_pkg_mgr: community.general.zypper
|
ansible_pkg_mgr: community.general.zypper
|
||||||
cacheable: yes
|
cacheable: true
|
||||||
when: ansible_os_family == "Suse"
|
when: ansible_os_family == "Suse"
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
---
|
||||||
dependencies:
|
dependencies:
|
||||||
- prepare_tests
|
- prepare_tests
|
||||||
|
|
|
||||||
|
|
@ -1,310 +1,350 @@
|
||||||
- name: install rsync
|
---
|
||||||
package:
|
- name: Install rsync
|
||||||
|
ansible.builtin.package:
|
||||||
name: rsync
|
name: rsync
|
||||||
when: ansible_distribution != "MacOSX"
|
when: ansible_distribution != "MacOSX"
|
||||||
- name: Clean up the working directory and files
|
|
||||||
file:
|
- name: Clean up the working disrectory and files
|
||||||
path: '{{ output_dir }}'
|
ansible.builtin.file:
|
||||||
|
path: "{{ output_dir }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Create the working directory
|
- name: Create the working directory
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: '{{ output_dir }}'
|
path: "{{ output_dir }}"
|
||||||
state: directory
|
state: directory
|
||||||
- name: create test new files
|
mode: "0755"
|
||||||
copy:
|
|
||||||
dest: '{{output_dir}}/{{item}}'
|
- name: Create test new files
|
||||||
mode: '0644'
|
ansible.builtin.copy:
|
||||||
content: 'hello world'
|
dest: "{{ output_dir }}/{{ item }}"
|
||||||
with_items:
|
mode: "0644"
|
||||||
|
content: hello world
|
||||||
|
loop:
|
||||||
- foo.txt
|
- foo.txt
|
||||||
- bar.txt
|
- bar.txt
|
||||||
|
|
||||||
- name: synchronize file to new filename
|
- name: Synchronize file to new filename
|
||||||
synchronize:
|
ansible.posix.synchronize:
|
||||||
src: '{{output_dir}}/foo.txt'
|
src: "{{ output_dir }}/foo.txt"
|
||||||
dest: '{{output_dir}}/foo.result'
|
dest: "{{ output_dir }}/foo.result"
|
||||||
register: sync_result
|
register: sync_result
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- '''changed'' in sync_result'
|
|
||||||
- sync_result.changed == true
|
|
||||||
- '''cmd'' in sync_result'
|
|
||||||
- '''rsync'' in sync_result.cmd'
|
|
||||||
- '''msg'' in sync_result'
|
|
||||||
- sync_result.msg.startswith('>f+')
|
|
||||||
- 'sync_result.msg.endswith(''+ foo.txt
|
|
||||||
|
|
||||||
'')'
|
- name: Check that the file was copied over correctly
|
||||||
- name: test that the file was really copied over
|
ansible.builtin.assert:
|
||||||
stat:
|
that:
|
||||||
path: '{{ output_dir }}/foo.result'
|
- "'changed' in sync_result"
|
||||||
|
- sync_result.changed == true
|
||||||
|
- "'cmd' in sync_result"
|
||||||
|
- "'rsync' in sync_result.cmd"
|
||||||
|
- "'msg' in sync_result"
|
||||||
|
- sync_result.msg.startswith('>f+')
|
||||||
|
- "sync_result.msg.endswith('+ foo.txt\n')"
|
||||||
|
|
||||||
|
- name: Test that the file was really copied over
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ output_dir }}/foo.result"
|
||||||
register: stat_result
|
register: stat_result
|
||||||
- assert:
|
|
||||||
|
- name: Test that the file was really copied over
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- stat_result.stat.exists == True
|
- stat_result.stat.exists == True
|
||||||
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
||||||
|
|
||||||
- name: test that the file is not copied a second time
|
- name: Test that the file is not copied a second time
|
||||||
synchronize:
|
ansible.posix.synchronize:
|
||||||
src='{{output_dir}}/foo.txt'
|
src: "'{{ output_dir }}/foo.txt'"
|
||||||
dest='{{output_dir}}/foo.result'
|
dest: "'{{ output_dir }}/foo.result'"
|
||||||
register: sync_result
|
register: sync_result
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- assert:
|
|
||||||
|
- name: Test that no change occurred
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sync_result.changed == False
|
- not sync_result.changed
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{output_dir}}/{{item}}'
|
path: "{{ output_dir }}/{{ item }}"
|
||||||
with_items:
|
loop:
|
||||||
- foo.result
|
- foo.result
|
||||||
- bar.result
|
- bar.result
|
||||||
|
|
||||||
- name: Synchronize using the mode=push param
|
- name: Synchronize using the mode=push param
|
||||||
synchronize:
|
ansible.posix.synchronize:
|
||||||
src: '{{output_dir}}/foo.txt'
|
src: "{{ output_dir }}/foo.txt"
|
||||||
dest: '{{output_dir}}/foo.result'
|
dest: "{{ output_dir }}/foo.result"
|
||||||
mode: push
|
mode: push
|
||||||
register: sync_result
|
register: sync_result
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- '''changed'' in sync_result'
|
|
||||||
- sync_result.changed == true
|
|
||||||
- '''cmd'' in sync_result'
|
|
||||||
- '''rsync'' in sync_result.cmd'
|
|
||||||
- '''msg'' in sync_result'
|
|
||||||
- sync_result.msg.startswith('>f+')
|
|
||||||
- 'sync_result.msg.endswith(''+ foo.txt
|
|
||||||
|
|
||||||
'')'
|
- name: Check that the file was copied over correctly mode=push
|
||||||
- name: test that the file was really copied over
|
ansible.builtin.assert:
|
||||||
stat:
|
that:
|
||||||
path: '{{ output_dir }}/foo.result'
|
- "'changed' in sync_result"
|
||||||
|
- sync_result.changed == true
|
||||||
|
- "'cmd' in sync_result"
|
||||||
|
- "'rsync' in sync_result.cmd"
|
||||||
|
- "'msg' in sync_result"
|
||||||
|
- sync_result.msg.startswith('>f+')
|
||||||
|
- "sync_result.msg.endswith('+ foo.txt\n')"
|
||||||
|
|
||||||
|
- name: Test that the file was really copied over
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ output_dir }}/foo.result"
|
||||||
register: stat_result
|
register: stat_result
|
||||||
- assert:
|
|
||||||
|
- name: Ensure file exists and checksum matches
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- stat_result.stat.exists == True
|
- stat_result.stat.exists == True
|
||||||
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
||||||
|
|
||||||
- name: test that the file is not copied a second time
|
- name: Test that the file is not copied a second time
|
||||||
synchronize:
|
ansible.posix.synchronize:
|
||||||
src: '{{output_dir}}/foo.txt'
|
src: "{{ output_dir }}/foo.txt"
|
||||||
dest: '{{output_dir}}/foo.result'
|
dest: "{{ output_dir }}/foo.result"
|
||||||
mode: push
|
mode: push
|
||||||
register: sync_result
|
register: sync_result
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- assert:
|
|
||||||
|
- name: Ensure no change occorred
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sync_result.changed == False
|
- sync_result.changed == False
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{output_dir}}/{{item}}'
|
path: "{{ output_dir }}/{{ item }}"
|
||||||
with_items:
|
loop:
|
||||||
- foo.result
|
- foo.result
|
||||||
- bar.result
|
- bar.result
|
||||||
|
|
||||||
- name: Synchronize using the mode=pull param
|
- name: Synchronize using the mode=pull param
|
||||||
synchronize:
|
ansible.posix.synchronize:
|
||||||
src: '{{output_dir}}/foo.txt'
|
src: "{{ output_dir }}/foo.txt"
|
||||||
dest: '{{output_dir}}/foo.result'
|
dest: "{{ output_dir }}/foo.result"
|
||||||
mode: pull
|
mode: pull
|
||||||
register: sync_result
|
register: sync_result
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- '''changed'' in sync_result'
|
|
||||||
- sync_result.changed == true
|
|
||||||
- '''cmd'' in sync_result'
|
|
||||||
- '''rsync'' in sync_result.cmd'
|
|
||||||
- '''msg'' in sync_result'
|
|
||||||
- sync_result.msg.startswith('>f+')
|
|
||||||
- 'sync_result.msg.endswith(''+ foo.txt
|
|
||||||
|
|
||||||
'')'
|
- name: Check that the file was copied over correctly mode=pull
|
||||||
- name: test that the file was really copied over
|
ansible.builtin.assert:
|
||||||
stat:
|
that:
|
||||||
path: '{{ output_dir }}/foo.result'
|
- "'changed' in sync_result"
|
||||||
|
- sync_result.changed == true
|
||||||
|
- "'cmd' in sync_result"
|
||||||
|
- "'rsync' in sync_result.cmd"
|
||||||
|
- "'msg' in sync_result"
|
||||||
|
- sync_result.msg.startswith('>f+')
|
||||||
|
- "sync_result.msg.endswith('+ foo.txt\n')"
|
||||||
|
|
||||||
|
- name: Test that the file was really copied over
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ output_dir }}/foo.result"
|
||||||
register: stat_result
|
register: stat_result
|
||||||
- assert:
|
|
||||||
|
- name: Ensure file exists and checksum matches
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- stat_result.stat.exists == True
|
- stat_result.stat.exists == True
|
||||||
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
||||||
|
|
||||||
- name: test that the file is not copied a second time
|
- name: Test that the file is not copied a second time
|
||||||
synchronize:
|
ansible.posix.synchronize:
|
||||||
src: '{{output_dir}}/foo.txt'
|
src: "{{ output_dir }}/foo.txt"
|
||||||
dest: '{{output_dir}}/foo.result'
|
dest: "{{ output_dir }}/foo.result"
|
||||||
mode: pull
|
mode: pull
|
||||||
register: sync_result
|
register: sync_result
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- assert:
|
|
||||||
|
- name: Ensure no change occorred
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sync_result.changed == False
|
- sync_result.changed == False
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{output_dir}}/{{item}}'
|
path: "{{ output_dir }}/{{ item }}"
|
||||||
with_items:
|
loop:
|
||||||
- foo.result
|
- foo.result
|
||||||
- bar.result
|
- bar.result
|
||||||
|
|
||||||
- name: synchronize files using with_items (issue#5965)
|
- name: Synchronize files using with_items (issue#5965)
|
||||||
synchronize:
|
ansible.posix.synchronize:
|
||||||
src: '{{output_dir}}/{{item}}'
|
src: "{{ output_dir }}/{{ item }}"
|
||||||
dest: '{{output_dir}}/{{item}}.result'
|
dest: "{{ output_dir }}/{{ item }}.result"
|
||||||
with_items:
|
with_items:
|
||||||
- foo.txt
|
- foo.txt
|
||||||
- bar.txt
|
- bar.txt
|
||||||
register: sync_result
|
register: sync_result
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- assert:
|
|
||||||
|
- name: Validate syncrhonize with_items
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sync_result.changed
|
- sync_result.changed
|
||||||
- sync_result.msg == 'All items completed'
|
- sync_result.msg == 'All items completed'
|
||||||
- '''results'' in sync_result'
|
- "'results' in sync_result"
|
||||||
- sync_result.results|length == 2
|
- sync_result.results|length == 2
|
||||||
- 'sync_result.results[0].msg.endswith(''+ foo.txt
|
- "sync_result.results[0].msg.endswith('+ foo.txt\n')"
|
||||||
|
- "sync_result.results[1].msg.endswith('+ bar.txt\n')"
|
||||||
|
|
||||||
'')'
|
|
||||||
- 'sync_result.results[1].msg.endswith(''+ bar.txt
|
|
||||||
|
|
||||||
'')'
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{output_dir}}/{{item}}.result'
|
path: "{{ output_dir }}/{{ item }}.result"
|
||||||
with_items:
|
loop:
|
||||||
- foo.txt
|
- foo.txt
|
||||||
- bar.txt
|
- bar.txt
|
||||||
|
|
||||||
- name: synchronize files using rsync_path (issue#7182)
|
- name: Synchronize files using rsync_path (issue#7182)
|
||||||
synchronize:
|
ansible.posix.synchronize:
|
||||||
src: '{{output_dir}}/foo.txt'
|
src: "{{ output_dir }}/foo.txt"
|
||||||
dest: '{{output_dir}}/foo.rsync_path'
|
dest: "{{ output_dir }}/foo.rsync_path"
|
||||||
rsync_path: 'sudo rsync'
|
rsync_path: sudo rsync
|
||||||
register: sync_result
|
register: sync_result
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- assert:
|
|
||||||
that:
|
- name: Validate syncrhonize using rsync_path (issue#7182)
|
||||||
- '''changed'' in sync_result'
|
ansible.builtin.assert:
|
||||||
- sync_result.changed == true
|
that:
|
||||||
- '''cmd'' in sync_result'
|
- "'changed' in sync_result"
|
||||||
- '''rsync'' in sync_result.cmd'
|
- sync_result.changed == true
|
||||||
- '''rsync_path'' in sync_result.cmd'
|
- "'cmd' in sync_result"
|
||||||
- '''msg'' in sync_result'
|
- "'rsync' in sync_result.cmd"
|
||||||
- sync_result.msg.startswith('>f+')
|
- "'rsync_path' in sync_result.cmd"
|
||||||
- 'sync_result.msg.endswith(''+ foo.txt
|
- "'msg' in sync_result"
|
||||||
|
- sync_result.msg.startswith('>f+')
|
||||||
|
- "sync_result.msg.endswith('+ foo.txt\n')"
|
||||||
|
|
||||||
'')'
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{output_dir}}/{{item}}'
|
path: "{{ output_dir }}/{{ item }}"
|
||||||
with_items:
|
loop:
|
||||||
- foo.rsync_path
|
- foo.rsync_path
|
||||||
- name: add subdirectories for link-dest test
|
|
||||||
file:
|
- name: Add subdirectories for link-dest test
|
||||||
path: '{{output_dir}}/{{item}}/'
|
ansible.builtin.file:
|
||||||
|
path: "{{ output_dir }}/{{ item }}/"
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0755'
|
mode: "0755"
|
||||||
with_items:
|
loop:
|
||||||
- directory_a
|
- directory_a
|
||||||
- directory_b
|
- directory_b
|
||||||
- name: copy foo.txt into the first directory
|
|
||||||
synchronize:
|
- name: Copy foo.txt into the first directory
|
||||||
src: '{{output_dir}}/foo.txt'
|
ansible.posix.synchronize:
|
||||||
dest: '{{output_dir}}/{{item}}/foo.txt'
|
src: "{{ output_dir }}/foo.txt"
|
||||||
with_items:
|
dest: "{{ output_dir }}/{{ item }}/foo.txt"
|
||||||
|
loop:
|
||||||
- directory_a
|
- directory_a
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- name: synchronize files using link_dest
|
|
||||||
synchronize:
|
- name: Synchronize files using link_dest
|
||||||
src: '{{output_dir}}/directory_a/foo.txt'
|
ansible.posix.synchronize:
|
||||||
dest: '{{output_dir}}/directory_b/foo.txt'
|
src: "{{ output_dir }}/directory_a/foo.txt"
|
||||||
|
dest: "{{ output_dir }}/directory_b/foo.txt"
|
||||||
link_dest:
|
link_dest:
|
||||||
- '{{output_dir}}/directory_a'
|
- "{{ output_dir }}/directory_a"
|
||||||
register: sync_result
|
register: sync_result
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- name: get stat information for directory_a
|
|
||||||
stat:
|
- name: Get stat information for directory_a
|
||||||
path: '{{ output_dir }}/directory_a/foo.txt'
|
ansible.builtin.stat:
|
||||||
|
path: "{{ output_dir }}/directory_a/foo.txt"
|
||||||
register: stat_result_a
|
register: stat_result_a
|
||||||
- name: get stat information for directory_b
|
|
||||||
stat:
|
- name: Get stat information for directory_b
|
||||||
path: '{{ output_dir }}/directory_b/foo.txt'
|
ansible.builtin.stat:
|
||||||
|
path: "{{ output_dir }}/directory_b/foo.txt"
|
||||||
register: stat_result_b
|
register: stat_result_b
|
||||||
- assert:
|
|
||||||
|
- name: Ensure file exists and inode matches
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- '''changed'' in sync_result'
|
- "'changed' in sync_result"
|
||||||
- sync_result.changed == true
|
- sync_result.changed == true
|
||||||
- stat_result_a.stat.inode == stat_result_b.stat.inode
|
- stat_result_a.stat.inode == stat_result_b.stat.inode
|
||||||
- name: synchronize files using link_dest that would be recursive
|
|
||||||
synchronize:
|
- name: Synchronize files using link_dest that would be recursive
|
||||||
src: '{{output_dir}}/foo.txt'
|
ansible.posix.synchronize:
|
||||||
dest: '{{output_dir}}/foo.result'
|
src: "{{ output_dir }}/foo.txt"
|
||||||
|
dest: "{{ output_dir }}/foo.result"
|
||||||
link_dest:
|
link_dest:
|
||||||
- '{{output_dir}}'
|
- "{{ output_dir }}"
|
||||||
register: sync_result
|
register: sync_result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
|
|
||||||
- assert:
|
- name: Ensure no change occorred and failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sync_result is not changed
|
- sync_result is not changed
|
||||||
- sync_result is failed
|
- sync_result is failed
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{output_dir}}/{{item}}'
|
path: "{{ output_dir }}/{{ item }}"
|
||||||
with_items:
|
loop:
|
||||||
- directory_b/foo.txt
|
- directory_b/foo.txt
|
||||||
- directory_a/foo.txt
|
- directory_a/foo.txt
|
||||||
- directory_a
|
- directory_a
|
||||||
- directory_b
|
- directory_b
|
||||||
|
|
||||||
- name: setup - test for source with working dir with spaces in path
|
- name: Setup - test for source with working dir with spaces in path
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
path: '{{output_dir}}/{{item}}'
|
path: "{{ output_dir }}/{{ item }}"
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
mode: "0755"
|
||||||
with_items:
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- 'directory a'
|
loop:
|
||||||
- 'directory b'
|
- directory a
|
||||||
- name: setup - create test new files
|
- directory b
|
||||||
copy:
|
|
||||||
dest: '{{output_dir}}/directory a/{{item}}'
|
- name: Setup - create test new files
|
||||||
mode: '0644'
|
ansible.builtin.copy:
|
||||||
content: 'hello world'
|
dest: "{{ output_dir }}/directory a/{{ item }}"
|
||||||
with_items:
|
mode: "0644"
|
||||||
|
content: hello world
|
||||||
|
loop:
|
||||||
- foo.txt
|
- foo.txt
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
- name: copy source with spaces in dir path
|
|
||||||
synchronize:
|
- name: Copy source with spaces in dir path
|
||||||
src: '{{output_dir}}/directory a/foo.txt'
|
ansible.posix.synchronize:
|
||||||
dest: '{{output_dir}}/directory b/'
|
src: "{{ output_dir }}/directory a/foo.txt"
|
||||||
delegate_to: '{{ inventory_hostname }}'
|
dest: "{{ output_dir }}/directory b/"
|
||||||
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
register: sync_result
|
register: sync_result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
- name: get stat information for directory_b
|
|
||||||
stat:
|
- name: Get stat information for directory_b
|
||||||
path: '{{ output_dir }}/directory b/foo.txt'
|
ansible.builtin.stat:
|
||||||
|
path: "{{ output_dir }}/directory b/foo.txt"
|
||||||
register: stat_result_b
|
register: stat_result_b
|
||||||
- assert:
|
|
||||||
|
- name: Ensure file exists and checksum matches
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- '''changed'' in sync_result'
|
- "'changed' in sync_result"
|
||||||
- sync_result.changed == true
|
- sync_result.changed == true
|
||||||
- stat_result_b.stat.exists == True
|
- stat_result_b.stat.exists == True
|
||||||
- stat_result_b.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
- stat_result_b.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: '{{output_dir}}/{{item}}'
|
path: "{{ output_dir }}/{{ item }}"
|
||||||
with_items:
|
loop:
|
||||||
- 'directory b/foo.txt'
|
- directory b/foo.txt
|
||||||
- 'directory a/foo.txt'
|
- directory a/foo.txt
|
||||||
- 'directory a'
|
- directory a
|
||||||
- 'directory b'
|
- directory b
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
---
|
||||||
dependencies:
|
dependencies:
|
||||||
- prepare_tests
|
- prepare_tests
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test code for the sysctl module.
|
# Test code for the sysctl module.
|
||||||
# (c) 2017, James Tanner <tanner.jc@gmail.com>
|
# (c) 2017, James Tanner <tanner.jc@gmail.com>
|
||||||
|
|
||||||
|
|
@ -24,79 +25,91 @@
|
||||||
when:
|
when:
|
||||||
- ansible_facts.virtualization_type == 'docker' or ansible_facts.virtualization_type == 'container'
|
- ansible_facts.virtualization_type == 'docker' or ansible_facts.virtualization_type == 'container'
|
||||||
block:
|
block:
|
||||||
- set_fact:
|
- name: Set output_dir_test fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
output_dir_test: "{{ output_dir }}/test_sysctl"
|
output_dir_test: "{{ output_dir }}/test_sysctl"
|
||||||
|
|
||||||
- name: make sure our testing sub-directory does not exist
|
- name: Make sure our testing sub-directory does not exist
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ output_dir_test }}"
|
path: "{{ output_dir_test }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: create our testing sub-directory
|
- name: Create our testing sub-directory
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ output_dir_test }}"
|
path: "{{ output_dir_test }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
##
|
##
|
||||||
## sysctl - file manipulation
|
## sysctl - file manipulation
|
||||||
##
|
##
|
||||||
|
|
||||||
- name: copy the example conf to the test dir
|
- name: Copy the example conf to the test dir
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: sysctl.conf
|
src: sysctl.conf
|
||||||
dest: "{{ output_dir_test }}"
|
dest: "{{ output_dir_test }}"
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
- name: Set vm.swappiness to 5
|
- name: Set vm.swappiness to 5
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: vm.swappiness
|
name: vm.swappiness
|
||||||
value: 5
|
value: 5
|
||||||
state: present
|
state: present
|
||||||
reload: no
|
reload: false
|
||||||
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
|
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
|
||||||
register: sysctl_test0
|
register: sysctl_test0
|
||||||
|
|
||||||
- debug:
|
- name: Debug sysctl_test0
|
||||||
|
ansible.builtin.debug:
|
||||||
var: sysctl_test0
|
var: sysctl_test0
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: get file content
|
- name: Get file content
|
||||||
shell: "cat {{ output_dir_test }}/sysctl.conf | egrep -v ^\\#"
|
ansible.builtin.shell:
|
||||||
|
cmd: set -o pipefail && cat {{ output_dir_test }}/sysctl.conf | egrep -v ^\#
|
||||||
|
executable: /bin/bash
|
||||||
|
changed_when: false
|
||||||
register: sysctl_content0
|
register: sysctl_content0
|
||||||
|
|
||||||
- debug:
|
- name: Debug sysctl_content0
|
||||||
|
ansible.builtin.debug:
|
||||||
var: sysctl_content0
|
var: sysctl_content0
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: Set vm.swappiness to 5 again
|
- name: Set vm.swappiness to 5 again
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: vm.swappiness
|
name: vm.swappiness
|
||||||
value: 5
|
value: 5
|
||||||
state: present
|
state: present
|
||||||
reload: no
|
reload: false
|
||||||
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
|
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
|
||||||
register: sysctl_test1
|
register: sysctl_test1
|
||||||
|
|
||||||
- name: validate results
|
- name: Validate results
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_test0 is changed
|
- sysctl_test0 is changed
|
||||||
- sysctl_test1 is not changed
|
- sysctl_test1 is not changed
|
||||||
- 'sysctl_content0.stdout_lines[sysctl_content0.stdout_lines.index("vm.swappiness=5")] == "vm.swappiness=5"'
|
- sysctl_content0.stdout_lines[sysctl_content0.stdout_lines.index("vm.swappiness=5")] == "vm.swappiness=5"
|
||||||
|
|
||||||
- name: Remove kernel.panic
|
- name: Remove kernel.panic
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: kernel.panic
|
name: kernel.panic
|
||||||
value: 2
|
value: 2
|
||||||
reload: no
|
reload: false
|
||||||
state: absent
|
state: absent
|
||||||
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
|
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
|
||||||
register: sysctl_test2
|
register: sysctl_test2
|
||||||
|
|
||||||
- name: get file content
|
- name: Get file content
|
||||||
shell: "cat {{ output_dir_test }}/sysctl.conf | egrep -v ^\\#"
|
ansible.builtin.shell:
|
||||||
|
cmd: set -o pipefail && cat {{ output_dir_test }}/sysctl.conf | egrep -v ^\#
|
||||||
|
executable: /bin/bash
|
||||||
|
changed_when: false
|
||||||
register: sysctl_content2
|
register: sysctl_content2
|
||||||
|
|
||||||
- debug:
|
- name: Debug sysctl_test2 sysctl_content2
|
||||||
|
ansible.builtin.debug:
|
||||||
var: item
|
var: item
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
with_items:
|
with_items:
|
||||||
|
|
@ -104,38 +117,39 @@
|
||||||
- "{{ sysctl_content2 }}"
|
- "{{ sysctl_content2 }}"
|
||||||
|
|
||||||
- name: Validate results for key removal
|
- name: Validate results for key removal
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_test2 is changed
|
- sysctl_test2 is changed
|
||||||
- "'kernel.panic' not in sysctl_content2.stdout_lines"
|
- "'kernel.panic' not in sysctl_content2.stdout_lines"
|
||||||
|
|
||||||
- name: Test remove kernel.panic again
|
- name: Test remove kernel.panic again
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: kernel.panic
|
name: kernel.panic
|
||||||
value: 2
|
value: 2
|
||||||
state: absent
|
state: absent
|
||||||
reload: no
|
reload: false
|
||||||
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
|
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
|
||||||
register: sysctl_test2_change_test
|
register: sysctl_test2_change_test
|
||||||
|
|
||||||
- name: Assert that no change was made
|
- name: Assert that no change was made
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_test2_change_test is not changed
|
- sysctl_test2_change_test is not changed
|
||||||
|
|
||||||
- name: Try sysctl with an invalid name
|
- name: Try sysctl with an invalid name
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: test.invalid
|
name: test.invalid
|
||||||
value: 1
|
value: 1
|
||||||
register: sysctl_test3
|
register: sysctl_test3
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
|
|
||||||
- debug:
|
- name: Debug sysctl_test3
|
||||||
|
ansible.builtin.debug:
|
||||||
var: sysctl_test3
|
var: sysctl_test3
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: validate results for test 3
|
- name: Validate results for test 3
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_test3 is failed
|
- sysctl_test3 is failed
|
||||||
|
|
||||||
|
|
@ -143,77 +157,79 @@
|
||||||
## sysctl - sysctl_set
|
## sysctl - sysctl_set
|
||||||
##
|
##
|
||||||
|
|
||||||
- name: set net.ipv4.ip_forward
|
- name: Set net.ipv4.ip_forward
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: net.ipv4.ip_forward
|
name: net.ipv4.ip_forward
|
||||||
value: 1
|
value: 1
|
||||||
sysctl_set: yes
|
sysctl_set: true
|
||||||
reload: no
|
reload: false
|
||||||
register: sysctl_test3
|
register: sysctl_test3
|
||||||
|
|
||||||
- name: check with sysctl command
|
- name: Check with sysctl command
|
||||||
shell: sysctl net.ipv4.ip_forward
|
ansible.builtin.command: sysctl net.ipv4.ip_forward
|
||||||
|
changed_when: false
|
||||||
register: sysctl_check3
|
register: sysctl_check3
|
||||||
|
|
||||||
- debug:
|
- name: Debug sysctl_test3 sysctl_check3
|
||||||
|
ansible.builtin.debug:
|
||||||
var: item
|
var: item
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ sysctl_test3 }}"
|
- "{{ sysctl_test3 }}"
|
||||||
- "{{ sysctl_check3 }}"
|
- "{{ sysctl_check3 }}"
|
||||||
|
|
||||||
- name: validate results for test 3
|
- name: Validate results for test 3
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_test3 is changed
|
- sysctl_test3 is changed
|
||||||
- 'sysctl_check3.stdout_lines == ["net.ipv4.ip_forward = 1"]'
|
- sysctl_check3.stdout_lines == ["net.ipv4.ip_forward = 1"]
|
||||||
|
|
||||||
- name: Try sysctl with no name
|
- name: Try sysctl with no name
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: ""
|
name: ""
|
||||||
value: 1
|
value: 1
|
||||||
sysctl_set: yes
|
sysctl_set: true
|
||||||
ignore_errors: True
|
ignore_errors: true
|
||||||
register: sysctl_no_name
|
register: sysctl_no_name
|
||||||
|
|
||||||
- name: validate nameless results
|
- name: Validate nameless results
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_no_name is failed
|
- sysctl_no_name is failed
|
||||||
- "sysctl_no_name.msg == 'name cannot be blank'"
|
- sysctl_no_name.msg == 'name cannot be blank'
|
||||||
|
|
||||||
- name: Try sysctl with no value
|
- name: Try sysctl with no value
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: Foo
|
name: Foo
|
||||||
value:
|
value:
|
||||||
sysctl_set: yes
|
sysctl_set: true
|
||||||
ignore_errors: True
|
ignore_errors: true
|
||||||
register: sysctl_no_value
|
register: sysctl_no_value
|
||||||
|
|
||||||
- name: validate nameless results
|
- name: Validate nameless results
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_no_value is failed
|
- sysctl_no_value is failed
|
||||||
- "sysctl_no_value.msg == 'value cannot be None'"
|
- sysctl_no_value.msg == 'value cannot be None'
|
||||||
|
|
||||||
- name: Try sysctl with an invalid name
|
- name: Try sysctl with an invalid name
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: test.invalid
|
name: test.invalid
|
||||||
value: 1
|
value: 1
|
||||||
sysctl_set: yes
|
sysctl_set: true
|
||||||
register: sysctl_test4
|
register: sysctl_test4
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
|
|
||||||
- debug:
|
- name: Debug sysctl_test4
|
||||||
|
ansible.builtin.debug:
|
||||||
var: sysctl_test4
|
var: sysctl_test4
|
||||||
verbosity: 1
|
verbosity: 1
|
||||||
|
|
||||||
- name: validate results for test 4
|
- name: Validate results for test 4
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_test4 is failed
|
- sysctl_test4 is failed
|
||||||
|
|
||||||
|
|
||||||
- name: Test on RHEL VMs
|
- name: Test on RHEL VMs
|
||||||
when:
|
when:
|
||||||
- ansible_facts.virtualization_type != 'docker'
|
- ansible_facts.virtualization_type != 'docker'
|
||||||
|
|
@ -221,34 +237,37 @@
|
||||||
block:
|
block:
|
||||||
# Test reload: yes
|
# Test reload: yes
|
||||||
- name: Set sysctl property using module
|
- name: Set sysctl property using module
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: vm.swappiness
|
name: vm.swappiness
|
||||||
value: '22'
|
value: "22"
|
||||||
state: present
|
state: present
|
||||||
reload: yes
|
reload: true
|
||||||
register: sysctl_set1
|
register: sysctl_set1
|
||||||
|
|
||||||
- name: Change sysctl property using command
|
- name: Change sysctl property using command
|
||||||
command: sysctl vm.swappiness=33
|
ansible.builtin.command: sysctl vm.swappiness=33
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
- name: Set sysctl property using module
|
- name: Set sysctl property using module
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: vm.swappiness
|
name: vm.swappiness
|
||||||
value: '22'
|
value: "22"
|
||||||
state: present
|
state: present
|
||||||
reload: yes
|
reload: true
|
||||||
register: sysctl_set2
|
register: sysctl_set2
|
||||||
|
|
||||||
- name: Read /etc/sysctl.conf
|
- name: Read /etc/sysctl.conf
|
||||||
command: 'egrep -v ^# /etc/sysctl.conf'
|
ansible.builtin.command: egrep -v ^# /etc/sysctl.conf
|
||||||
|
changed_when: false
|
||||||
register: sysctl_conf_content
|
register: sysctl_conf_content
|
||||||
|
|
||||||
- name: Get current value of vm.swappiness
|
- name: Get current value of vm.swappiness
|
||||||
command: sysctl -n vm.swappiness
|
ansible.builtin.command: sysctl -n vm.swappiness
|
||||||
|
changed_when: false
|
||||||
register: sysctl_current_vm_swappiness
|
register: sysctl_current_vm_swappiness
|
||||||
|
|
||||||
- name: Ensure changes were made appropriately
|
- name: Ensure changes were made appropriately
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_set1 is changed
|
- sysctl_set1 is changed
|
||||||
- sysctl_set2 is changed
|
- sysctl_set2 is changed
|
||||||
|
|
@ -257,33 +276,35 @@
|
||||||
|
|
||||||
# Test reload: yes in check mode
|
# Test reload: yes in check mode
|
||||||
- name: Set the same value using module in check mode
|
- name: Set the same value using module in check mode
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: vm.swappiness
|
name: vm.swappiness
|
||||||
value: '22'
|
value: "22"
|
||||||
state: present
|
state: present
|
||||||
reload: yes
|
reload: true
|
||||||
check_mode: yes
|
check_mode: true
|
||||||
register: sysctl_check_mode1
|
register: sysctl_check_mode1
|
||||||
|
|
||||||
- name: Set a different value using module in check mode
|
- name: Set a different value using module in check mode
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: vm.swappiness
|
name: vm.swappiness
|
||||||
value: '44'
|
value: "44"
|
||||||
state: present
|
state: present
|
||||||
reload: yes
|
reload: true
|
||||||
check_mode: yes
|
check_mode: true
|
||||||
register: sysctl_check_mode2
|
register: sysctl_check_mode2
|
||||||
|
|
||||||
- name: Read /etc/sysctl.conf
|
- name: Read /etc/sysctl.conf
|
||||||
command: 'egrep -v ^# /etc/sysctl.conf'
|
ansible.builtin.command: egrep -v ^# /etc/sysctl.conf
|
||||||
|
changed_when: false
|
||||||
register: sysctl_check_mode_conf_content
|
register: sysctl_check_mode_conf_content
|
||||||
|
|
||||||
- name: Get current value of vm.swappiness
|
- name: Get current value of vm.swappiness
|
||||||
command: sysctl -n vm.swappiness
|
ansible.builtin.command: sysctl -n vm.swappiness
|
||||||
|
changed_when: false
|
||||||
register: sysctl_check_mode_current_vm_swappiness
|
register: sysctl_check_mode_current_vm_swappiness
|
||||||
|
|
||||||
- name: Ensure no changes were made in check mode
|
- name: Ensure no changes were made in check mode
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_check_mode1 is success
|
- sysctl_check_mode1 is success
|
||||||
- sysctl_check_mode2 is changed
|
- sysctl_check_mode2 is changed
|
||||||
|
|
@ -292,21 +313,22 @@
|
||||||
|
|
||||||
# Test sysctl: invalid value
|
# Test sysctl: invalid value
|
||||||
- name: Set invalid sysctl property using module
|
- name: Set invalid sysctl property using module
|
||||||
sysctl:
|
ansible.posix.sysctl:
|
||||||
name: vm.mmap_rnd_bits
|
name: vm.mmap_rnd_bits
|
||||||
value: '1024'
|
value: "1024"
|
||||||
state: present
|
state: present
|
||||||
reload: yes
|
reload: true
|
||||||
sysctl_set: True
|
sysctl_set: true
|
||||||
ignore_errors: True
|
ignore_errors: true
|
||||||
register: sysctl_invalid_set1
|
register: sysctl_invalid_set1
|
||||||
|
|
||||||
- name: Read /etc/sysctl.conf
|
- name: Read /etc/sysctl.conf
|
||||||
command: 'cat /etc/sysctl.conf'
|
ansible.builtin.command: cat /etc/sysctl.conf
|
||||||
|
changed_when: false
|
||||||
register: sysctl_invalid_conf_content
|
register: sysctl_invalid_conf_content
|
||||||
|
|
||||||
- name: Ensure changes were not made
|
- name: Ensure changes were not made
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- sysctl_invalid_set1 is failed
|
- sysctl_invalid_set1 is failed
|
||||||
- "'vm.mmap_rnd_bits' not in sysctl_invalid_conf_content.stdout"
|
- "'vm.mmap_rnd_bits' not in sysctl_invalid_conf_content.stdout"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,2 @@
|
||||||
plugins/modules/synchronize.py pylint:disallowed-name
|
|
||||||
plugins/modules/synchronize.py use-argspec-type-path
|
|
||||||
plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec
|
|
||||||
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented
|
|
||||||
plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc
|
|
||||||
plugins/modules/synchronize.py validate-modules:undocumented-parameter
|
|
||||||
tests/utils/shippable/check_matrix.py replace-urlopen
|
tests/utils/shippable/check_matrix.py replace-urlopen
|
||||||
tests/utils/shippable/timing.py shebang
|
tests/utils/shippable/timing.py shebang
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,2 @@
|
||||||
plugins/modules/synchronize.py pylint:disallowed-name
|
|
||||||
plugins/modules/synchronize.py use-argspec-type-path
|
|
||||||
plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec
|
|
||||||
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented
|
|
||||||
plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc
|
|
||||||
plugins/modules/synchronize.py validate-modules:undocumented-parameter
|
|
||||||
tests/utils/shippable/check_matrix.py replace-urlopen
|
tests/utils/shippable/check_matrix.py replace-urlopen
|
||||||
tests/utils/shippable/timing.py shebang
|
tests/utils/shippable/timing.py shebang
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1 @@
|
||||||
plugins/modules/synchronize.py pylint:disallowed-name
|
|
||||||
plugins/modules/synchronize.py use-argspec-type-path
|
|
||||||
plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec
|
|
||||||
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented
|
|
||||||
plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc
|
|
||||||
plugins/modules/synchronize.py validate-modules:undocumented-parameter
|
|
||||||
tests/utils/shippable/timing.py shebang
|
tests/utils/shippable/timing.py shebang
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1 @@
|
||||||
plugins/modules/synchronize.py pylint:disallowed-name
|
|
||||||
plugins/modules/synchronize.py use-argspec-type-path
|
|
||||||
plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec
|
|
||||||
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented
|
|
||||||
plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc
|
|
||||||
plugins/modules/synchronize.py validate-modules:undocumented-parameter
|
|
||||||
tests/utils/shippable/timing.py shebang
|
tests/utils/shippable/timing.py shebang
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
plugins/modules/synchronize.py pylint:blacklisted-name
|
|
||||||
plugins/modules/synchronize.py use-argspec-type-path
|
|
||||||
plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec
|
|
||||||
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented
|
|
||||||
plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc
|
|
||||||
plugins/modules/synchronize.py validate-modules:undocumented-parameter
|
|
||||||
tests/utils/shippable/check_matrix.py replace-urlopen
|
|
||||||
tests/utils/shippable/timing.py shebang
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
|
---
|
||||||
fixtures:
|
fixtures:
|
||||||
taskvars_in: taskvars_in.json
|
taskvars_in: taskvars_in.json
|
||||||
taskvars_out: taskvars_out.json
|
taskvars_out: taskvars_out.json
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'local'"
|
- SAM._connection.transport == 'local'
|
||||||
- "self._play_context.shell == 'sh'"
|
- self._play_context.shell == 'sh'
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,40 @@
|
||||||
|
---
|
||||||
task_args:
|
task_args:
|
||||||
src: /tmp/deleteme
|
src: /tmp/deleteme
|
||||||
dest: /tmp/deleteme
|
dest: /tmp/deleteme
|
||||||
# rsync_path: rsync
|
# rsync_path: rsync
|
||||||
_task:
|
_task:
|
||||||
become: True
|
become: true
|
||||||
become_method: None
|
become_method: None
|
||||||
fixtures:
|
fixtures:
|
||||||
taskvars_in: task_vars_in.json
|
taskvars_in: task_vars_in.json
|
||||||
taskvars_out: task_vars_out.json
|
taskvars_out: task_vars_out.json
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
_play_context:
|
_play_context:
|
||||||
become: True
|
become: true
|
||||||
become_method: sudo
|
become_method: sudo
|
||||||
remote_addr: el6host
|
remote_addr: el6host
|
||||||
remote_user: root
|
remote_user: root
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'local'"
|
- SAM._connection.transport == 'local'
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
# this is a crucial aspect of this scenario ...
|
# this is a crucial aspect of this scenario ...
|
||||||
# note: become_user None -> root
|
# note: become_user None -> root
|
||||||
- "self.final_module_args['rsync_path'] == 'sudo -u root rsync'"
|
- self.final_module_args['rsync_path'] == 'sudo -u root rsync'
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
|
||||||
- "self.task.become == True"
|
- self.task.become == True
|
||||||
- "self.task.become_user == None"
|
- self.task.become_user == None
|
||||||
- "self._play_context.shell == 'sh'"
|
- self._play_context.shell == 'sh'
|
||||||
- "self._play_context.remote_addr == 'el6host'"
|
- self._play_context.remote_addr == 'el6host'
|
||||||
- "self._play_context.remote_user == 'root'"
|
- self._play_context.remote_user == 'root'
|
||||||
- "self._play_context.become == False"
|
- self._play_context.become == False
|
||||||
- "self._play_context.become_user == 'root'"
|
- self._play_context.become_user == 'root'
|
||||||
- "self._play_context.password == None"
|
- self._play_context.password == None
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
task_args:
|
task_args:
|
||||||
src: /tmp/deleteme
|
src: /tmp/deleteme
|
||||||
dest: /tmp/deleteme
|
dest: /tmp/deleteme
|
||||||
|
|
@ -9,31 +10,31 @@ fixtures:
|
||||||
taskvars_in: task_vars_in.json
|
taskvars_in: task_vars_in.json
|
||||||
taskvars_out: task_vars_out.json
|
taskvars_out: task_vars_out.json
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
_play_context:
|
_play_context:
|
||||||
become: True
|
become: true
|
||||||
become_method: sudo
|
become_method: sudo
|
||||||
remote_addr: el6host
|
remote_addr: el6host
|
||||||
remote_user: root
|
remote_user: root
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'local'"
|
- SAM._connection.transport == 'local'
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
# this is a crucial aspect of this scenario ...
|
# this is a crucial aspect of this scenario ...
|
||||||
# note: become_user None -> root
|
# note: become_user None -> root
|
||||||
- "self.final_module_args['rsync_path'] == 'sudo -u root rsync'"
|
- self.final_module_args['rsync_path'] == 'sudo -u root rsync'
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
|
||||||
- "self.task.become == None"
|
- self.task.become == None
|
||||||
- "self.task.become_user == None"
|
- self.task.become_user == None
|
||||||
- "self._play_context.shell == 'sh'"
|
- self._play_context.shell == 'sh'
|
||||||
- "self._play_context.remote_addr == 'el6host'"
|
- self._play_context.remote_addr == 'el6host'
|
||||||
- "self._play_context.remote_user == 'root'"
|
- self._play_context.remote_user == 'root'
|
||||||
- "self._play_context.become == False"
|
- self._play_context.become == False
|
||||||
- "self._play_context.become_user == 'root'"
|
- self._play_context.become_user == 'root'
|
||||||
- "self._play_context.password == None"
|
- self._play_context.password == None
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
task_args:
|
task_args:
|
||||||
src: /tmp/deleteme
|
src: /tmp/deleteme
|
||||||
dest: /tmp/deleteme
|
dest: /tmp/deleteme
|
||||||
|
|
@ -5,25 +6,25 @@ fixtures:
|
||||||
taskvars_in: task_vars_in.json
|
taskvars_in: task_vars_in.json
|
||||||
taskvars_out: task_vars_out.json
|
taskvars_out: task_vars_out.json
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
_play_context:
|
_play_context:
|
||||||
remote_addr: '127.0.0.1'
|
remote_addr: 127.0.0.1
|
||||||
remote_user: vagrant
|
remote_user: vagrant
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'local'"
|
- SAM._connection.transport == 'local'
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
- "self.final_module_args['dest_port'] == 2202"
|
- self.final_module_args['dest_port'] == 2202
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'
|
||||||
- "self._play_context.shell == 'sh'"
|
- self._play_context.shell == 'sh'
|
||||||
- "self._play_context.remote_addr == '127.0.0.1'"
|
- self._play_context.remote_addr == '127.0.0.1'
|
||||||
- "self._play_context.remote_user == 'vagrant'"
|
- self._play_context.remote_user == 'vagrant'
|
||||||
- "self._play_context.become == False"
|
- self._play_context.become == False
|
||||||
- "self._play_context.become_user == 'root'"
|
- self._play_context.become_user == 'root'
|
||||||
- "self._play_context.password == None"
|
- self._play_context.password == None
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
task:
|
task:
|
||||||
# become: None
|
# become: None
|
||||||
task_args:
|
task_args:
|
||||||
|
|
@ -7,26 +8,26 @@ fixtures:
|
||||||
taskvars_in: task_vars_in.json
|
taskvars_in: task_vars_in.json
|
||||||
taskvars_out: task_vars_out.json
|
taskvars_out: task_vars_out.json
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
_play_context:
|
_play_context:
|
||||||
become: True
|
become: true
|
||||||
remote_addr: '127.0.0.1'
|
remote_addr: 127.0.0.1
|
||||||
remote_user: vagrant
|
remote_user: vagrant
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'local'"
|
- SAM._connection.transport == 'local'
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
- "self.final_module_args['dest_port'] == 2202"
|
- self.final_module_args['dest_port'] == 2202
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'
|
||||||
- "self._play_context.shell == 'sh'"
|
- self._play_context.shell == 'sh'
|
||||||
- "self._play_context.remote_addr == '127.0.0.1'"
|
- self._play_context.remote_addr == '127.0.0.1'
|
||||||
- "self._play_context.remote_user == 'vagrant'"
|
- self._play_context.remote_user == 'vagrant'
|
||||||
- "self._play_context.become == False"
|
- self._play_context.become == False
|
||||||
- "self._play_context.become_user == 'root'"
|
- self._play_context.become_user == 'root'
|
||||||
- "self._play_context.password == None"
|
- self._play_context.password == None
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
task_args:
|
task_args:
|
||||||
src: /tmp/deleteme
|
src: /tmp/deleteme
|
||||||
dest: /tmp/deleteme
|
dest: /tmp/deleteme
|
||||||
|
|
@ -5,25 +6,25 @@ fixtures:
|
||||||
taskvars_in: task_vars_in.json
|
taskvars_in: task_vars_in.json
|
||||||
taskvars_out: task_vars_out.json
|
taskvars_out: task_vars_out.json
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
_play_context:
|
_play_context:
|
||||||
remote_addr: '127.0.0.1'
|
remote_addr: 127.0.0.1
|
||||||
remote_user: vagrant
|
remote_user: vagrant
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'local'"
|
- SAM._connection.transport == 'local'
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
- "self.final_module_args['dest_port'] == 2202"
|
- self.final_module_args['dest_port'] == 2202
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'
|
||||||
- "self._play_context.shell == 'sh'"
|
- self._play_context.shell == 'sh'
|
||||||
- "self._play_context.remote_addr == '127.0.0.1'"
|
- self._play_context.remote_addr == '127.0.0.1'
|
||||||
- "self._play_context.remote_user == 'vagrant'"
|
- self._play_context.remote_user == 'vagrant'
|
||||||
- "self._play_context.become == False"
|
- self._play_context.become == False
|
||||||
- "self._play_context.become_user == 'root'"
|
- self._play_context.become_user == 'root'
|
||||||
- "self._play_context.password == None"
|
- self._play_context.password == None
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
|
---
|
||||||
fixtures:
|
fixtures:
|
||||||
taskvars_in: taskvars_in.json
|
taskvars_in: taskvars_in.json
|
||||||
taskvars_out: taskvars_out.json
|
taskvars_out: taskvars_out.json
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
_play_context:
|
_play_context:
|
||||||
private_key_file: ~/test.pem
|
private_key_file: ~/test.pem
|
||||||
task_args:
|
task_args:
|
||||||
|
|
@ -15,11 +16,11 @@ task_args:
|
||||||
src: /tmp/deleteme
|
src: /tmp/deleteme
|
||||||
|
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'local'"
|
- SAM._connection.transport == 'local'
|
||||||
- "self._play_context.shell == 'sh'"
|
- self._play_context.shell == 'sh'
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
|
||||||
- "self.final_module_args['private_key'] == '~/.ssh/id_rsa'"
|
- self.final_module_args['private_key'] == '~/.ssh/id_rsa'
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
fixtures:
|
fixtures:
|
||||||
taskvars_in: task_vars_in.json
|
taskvars_in: task_vars_in.json
|
||||||
taskvars_out: task_vars_out.json
|
taskvars_out: task_vars_out.json
|
||||||
|
|
@ -11,16 +12,16 @@ _play_context:
|
||||||
remote_addr: u1404
|
remote_addr: u1404
|
||||||
remote_user: root
|
remote_user: root
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'ssh'"
|
- SAM._connection.transport == 'ssh'
|
||||||
- "self._play_context.shell == None"
|
- self._play_context.shell == None
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
fixtures:
|
fixtures:
|
||||||
taskvars_in: task_vars_in.json
|
taskvars_in: task_vars_in.json
|
||||||
taskvars_out: task_vars_out.json
|
taskvars_out: task_vars_out.json
|
||||||
|
|
@ -12,17 +13,17 @@ _play_context:
|
||||||
remote_user: root
|
remote_user: root
|
||||||
private_key_file: ~/test.pem
|
private_key_file: ~/test.pem
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'ssh'"
|
- SAM._connection.transport == 'ssh'
|
||||||
- "self._play_context.shell == None"
|
- self._play_context.shell == None
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
|
||||||
- "self.final_module_args['private_key'] == '~/test.pem'"
|
- self.final_module_args['private_key'] == '~/test.pem'
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
fixtures:
|
fixtures:
|
||||||
taskvars_in: task_vars_in.json
|
taskvars_in: task_vars_in.json
|
||||||
taskvars_out: task_vars_out.json
|
taskvars_out: task_vars_out.json
|
||||||
|
|
@ -7,27 +8,27 @@ task_args:
|
||||||
_task:
|
_task:
|
||||||
delegate_to: u1404
|
delegate_to: u1404
|
||||||
_play_context:
|
_play_context:
|
||||||
become: True
|
become: true
|
||||||
become_user: None # if ! None|root, different testcase
|
become_user: None # if ! None|root, different testcase
|
||||||
become_method: su
|
become_method: su
|
||||||
shell: None
|
shell: None
|
||||||
remote_addr: u1404
|
remote_addr: u1404
|
||||||
remote_user: root
|
remote_user: root
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'ssh'"
|
- SAM._connection.transport == 'ssh'
|
||||||
- "self._play_context.shell == None"
|
- self._play_context.shell == None
|
||||||
- "self._play_context.remote_addr == 'u1404'"
|
- self._play_context.remote_addr == 'u1404'
|
||||||
- "self._play_context.remote_user == 'root'"
|
- self._play_context.remote_user == 'root'
|
||||||
- "not self._play_context.become"
|
- not self._play_context.become
|
||||||
- "self._play_context.become_method == 'su'"
|
- self._play_context.become_method == 'su'
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
fixtures:
|
fixtures:
|
||||||
taskvars_in: task_vars_in.json
|
taskvars_in: task_vars_in.json
|
||||||
taskvars_out: task_vars_out.json
|
taskvars_out: task_vars_out.json
|
||||||
|
|
@ -13,17 +14,17 @@ _play_context:
|
||||||
remote_user: root
|
remote_user: root
|
||||||
private_key_file: ~/test.pem
|
private_key_file: ~/test.pem
|
||||||
connection:
|
connection:
|
||||||
transport: 'ssh'
|
transport: ssh
|
||||||
hostvars:
|
hostvars:
|
||||||
'127.0.0.1': {}
|
127.0.0.1: {}
|
||||||
'::1': {}
|
::1: {}
|
||||||
'localhost': {}
|
localhost: {}
|
||||||
asserts:
|
asserts:
|
||||||
- "hasattr(SAM._connection, 'ismock')"
|
- hasattr(SAM._connection, 'ismock')
|
||||||
- "SAM._connection.transport == 'ssh'"
|
- SAM._connection.transport == 'ssh'
|
||||||
- "self._play_context.shell == None"
|
- self._play_context.shell == None
|
||||||
- "self.execute_called"
|
- self.execute_called
|
||||||
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
|
- self.final_module_args['_local_rsync_path'] == 'rsync'
|
||||||
- "self.final_module_args['src'] == '/tmp/deleteme'"
|
- self.final_module_args['src'] == '/tmp/deleteme'
|
||||||
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
|
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
|
||||||
- "self.final_module_args['private_key'] == '~/.ssh/id_rsa'"
|
- self.final_module_args['private_key'] == '~/.ssh/id_rsa'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue