Compare commits

..

1 commit

Author SHA1 Message Date
Adam Miller
70e24a227b
Merge 078b145f72 into 05ee6ebc2a 2023-12-01 04:35:08 +00:00
68 changed files with 2394 additions and 2627 deletions

View file

@ -1,4 +1,3 @@
---
trigger:
batch: true
branches:
@ -14,7 +13,7 @@ pr:
- stable-*
schedules:
- cron: "0 9 * * *"
- cron: 0 9 * * *
displayName: Nightly
always: true
branches:
@ -42,6 +41,7 @@ resources:
pool: Standard
stages:
- stage: Sanity_devel
displayName: Ansible devel sanity
dependsOn: []
@ -49,14 +49,14 @@ stages:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: devel/{0}
testFormat: "devel/{0}"
targets:
- name: Sanity
test: sanity
- name: Units
test: units
- name: Lint
test: lint
# - name: Lint
# test: lint
- stage: Sanity_2_16
displayName: Ansible 2.16 sanity
dependsOn: []
@ -64,14 +64,12 @@ stages:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.16/{0}
testFormat: "2.16/{0}"
targets:
- name: Sanity
test: sanity
- name: Units
test: units
- name: Lint
test: lint
- stage: Sanity_2_15
displayName: Ansible 2.15 sanity
dependsOn: []
@ -79,7 +77,7 @@ stages:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.15/{0}
testFormat: "2.15/{0}"
targets:
- name: Sanity
test: sanity
@ -92,13 +90,26 @@ stages:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.14/{0}
testFormat: "2.14/{0}"
targets:
- name: Sanity
test: sanity
- name: Units
test: units
## Docker
- stage: Sanity_2_9
displayName: Ansible 2.9 sanity
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: "2.9/{0}"
targets:
- name: Sanity
test: sanity
- name: Units
test: units
## Docker
- stage: Docker_devel
displayName: Docker devel
dependsOn: []
@ -166,8 +177,28 @@ stages:
test: ubuntu2004
- name: Ubuntu 22.04
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
displayName: Remote devel
dependsOn: []
@ -229,12 +260,27 @@ stages:
test: freebsd/13.1
- name: 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
condition: succeededOrFailed()
dependsOn:
- Sanity_2_9
- Remote_2_9
- Docker_2_9
- Sanity_2_14
- Remote_2_14
- Docker_2_14

1
.github/BOTMETA.yml vendored
View file

@ -1,4 +1,3 @@
---
automerge: false
files:
$module_utils/mount.py:

View file

@ -11,7 +11,13 @@ An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and de
<!--start requires_ansible-->
## Ansible version compatibility
This collection has been tested against following Ansible versions: **>=2.14**.
This collection has been tested against following Ansible versions: **>=2.9**.
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-->
## Included content
@ -57,6 +63,8 @@ collections:
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
<!--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). -->
@ -83,10 +91,12 @@ None
<!-- List the versions of Ansible the collection has been tested with. Must match what is in galaxy.yml. -->
- ansible-core 2.17 (devel)
- ansible-core 2.16 (stable)
- ansible-core 2.15 (stable)
- ansible-core 2.14 (stable)
- ansible-core 2.14 (devel)
- ansible-core 2.13 (stable)
- ansible-core 2.12 (stable)
- ansible-core 2.11 (stable)
- ansible-base 2.10 (stable)
- ansible 2.9 (stable)
## Roadmap

View file

@ -1,2 +0,0 @@
major_changes:
- "Dropping support for Ansible 2.9, ansible-core 2.14 will be minimum required version for this release"

View file

@ -1,2 +1 @@
---
comment: false

View file

@ -1,4 +1,3 @@
---
namespace: ansible
name: posix
version: 1.5.4

View file

@ -1,8 +1,8 @@
---
requires_ansible: ">=2.14.0"
requires_ansible: '>=2.9'
plugin_routing:
callback:
skippy:
deprecation:
removal_date: "2022-06-01"
removal_date: '2022-06-01'
warning_text: See the plugin documentation for more details

View file

@ -177,7 +177,7 @@ class ActionModule(ActionBase):
# Store remote connection type
self._remote_transport = self._connection.transport
use_ssh_args = _tmp_args.pop('use_ssh_args', False)
use_ssh_args = _tmp_args.pop('use_ssh_args', None)
if use_ssh_args and self._connection.transport == 'ssh':
ssh_args = [
@ -185,7 +185,7 @@ class ActionModule(ActionBase):
self._connection.get_option('ssh_common_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
if self._remote_transport in DOCKER:

View file

@ -26,13 +26,13 @@ options:
description:
- Path on the source host that will be synchronized to the destination.
- The path can be absolute or relative.
type: path
type: str
required: true
dest:
description:
- Path on the destination host that will be synchronized from the source.
- The path can be absolute or relative.
type: path
type: str
required: true
dest_port:
description:
@ -135,6 +135,13 @@ options:
that does not match the inventory user, you should set this parameter to C(false).
type: bool
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:
description:
- SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections.
@ -150,7 +157,7 @@ options:
- 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.
type: list
default: []
default:
elements: str
partial:
description:
@ -171,7 +178,7 @@ options:
- Add a destination to hard link against during the rsync.
type: list
default:
elements: path
elements: str
delay_updates:
description:
- This option puts the temporary file from each updated file into a holding directory until the end of the transfer,
@ -179,30 +186,6 @@ options:
type: bool
default: true
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:
- rsync must be installed on both the local and remote host.
@ -252,7 +235,7 @@ EXAMPLES = r'''
src: rsync://somehost.com/path/
dest: /some/absolute/path/
- name: Synchronization using rsync protocol on delegate host (push)
- name: Synchronization using rsync protocol on delegate host (push)
ansible.posix.synchronize:
src: /some/absolute/path/
dest: rsync://somehost.com/path/
@ -379,11 +362,11 @@ def substitute_controller(path):
if not client_addr:
ssh_env_string = os.environ.get('SSH_CLIENT', None)
try:
client_addr, _ = ssh_env_string.split(None, 1) # pylint: disable=disallowed-name
client_addr, _ = ssh_env_string.split(None, 1)
except AttributeError:
ssh_env_string = os.environ.get('SSH_CONNECTION', None)
try:
client_addr, _ = ssh_env_string.split(None, 1) # pylint: disable=disallowed-name
client_addr, _ = ssh_env_string.split(None, 1)
except AttributeError:
pass
if not client_addr:
@ -405,8 +388,8 @@ def is_rsh_needed(source, dest):
def main():
module = AnsibleModule(
argument_spec=dict(
src=dict(type='path', required=True),
dest=dict(type='path', required=True),
src=dict(type='str', required=True),
dest=dict(type='str', required=True),
dest_port=dict(type='int'),
delete=dict(type='bool', default=False),
private_key=dict(type='path'),
@ -429,14 +412,13 @@ def main():
set_remote_user=dict(type='bool', default=True),
rsync_timeout=dict(type='int', default=0),
rsync_opts=dict(type='list', default=[], elements='str'),
_ssh_args=dict(type='str'),
use_ssh_args=dict(type='bool', default=False),
ssh_args=dict(type='str'),
ssh_connection_multiplexing=dict(type='bool', default=False),
partial=dict(type='bool', default=False),
verify_host=dict(type='bool', default=False),
delay_updates=dict(type='bool', default=True),
mode=dict(type='str', default='push', choices=['pull', 'push']),
link_dest=dict(type='list', elements='path'),
link_dest=dict(type='list', elements='str'),
),
supports_check_mode=True,
)
@ -472,7 +454,7 @@ def main():
owner = module.params['owner']
group = module.params['group']
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']
verify_host = module.params['verify_host']
link_dest = module.params['link_dest']
@ -590,7 +572,7 @@ def main():
# hardlink is actually a change
cmd.append('-vv')
for x in link_dest:
link_path = os.path.abspath(x)
link_path = os.path.abspath(os.path.expanduser(x))
destination_path = os.path.abspath(os.path.dirname(dest))
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))
@ -599,6 +581,12 @@ def main():
changed_marker = '<<CHANGED>>'
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(dest))
cmdstr = ' '.join(cmd)

View file

@ -1,4 +1,3 @@
---
language: python
env:
@ -16,14 +15,14 @@ matrix:
- env: T=2.9/freebsd/12.0/1
- env: T=2.9/linux/centos6/1
- env: T=2.9/linux/centos7/1
# - env: T=2.9/linux/centos8/1
# - env: T=2.9/linux/centos8/1
- env: T=2.9/linux/fedora30/1
- env: T=2.9/linux/fedora31/1
- env: T=2.9/linux/opensuse15py2/1
- env: T=2.9/linux/opensuse15/1
- env: T=2.9/linux/ubuntu1604/1
- env: T=2.9/linux/ubuntu1804/1
# - env: T=2.10/aix/7.2/1
# - env: T=2.10/aix/7.2/1
- env: T=2.10/osx/10.11/1
- env: T=2.10/rhel/7.6/1
- env: T=2.10/rhel/8.2/1
@ -31,14 +30,14 @@ matrix:
- env: T=2.10/freebsd/12.1/1
- env: T=2.10/linux/centos6/1
- env: T=2.10/linux/centos7/1
# - env: T=2.10/linux/centos8/1
# - env: T=2.10/linux/centos8/1
- env: T=2.10/linux/fedora30/1
- env: T=2.10/linux/fedora31/1
- env: T=2.10/linux/opensuse15py2/1
- env: T=2.10/linux/opensuse15/1
- env: T=2.10/linux/ubuntu1604/1
- env: T=2.10/linux/ubuntu1804/1
# - env: T=devel/aix/7.2/1
# - env: T=devel/aix/7.2/1
- env: T=devel/osx/10.11/1
- env: T=devel/rhel/7.6/1
- env: T=devel/rhel/8.1/1
@ -46,7 +45,7 @@ matrix:
- env: T=devel/freebsd/12.1/1
- env: T=devel/linux/centos6/1
- env: T=devel/linux/centos7/1
# - env: T=devel/linux/centos8/1
# - env: T=devel/linux/centos8/1
- env: T=devel/linux/fedora30/1
- env: T=devel/linux/fedora31/1
- env: T=devel/linux/opensuse15py2/1
@ -57,7 +56,7 @@ matrix:
branches:
except:
- "*-patch-*"
- revert-*-*
- "revert-*-*"
build:
ci:

View file

@ -1,3 +1,3 @@
---
collections:
- community.general
- community.general

View file

@ -1,4 +1,3 @@
---
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
# This file is part of Ansible
@ -17,38 +16,35 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Create ansible user
ansible.builtin.user:
user:
name: "{{ test_user }}"
- name: Create ansible group
ansible.builtin.group:
group:
name: "{{ test_group }}"
- name: Clean up working directory and files
ansible.builtin.file:
file:
path: "{{ output_dir }}"
state: absent
- name: Create working directory
ansible.builtin.file:
file:
path: "{{ output_dir }}"
state: directory
mode: "0755"
- name: Create ansible file
ansible.builtin.file:
file:
path: "{{ test_file }}"
state: touch
mode: "0644"
- name: Create ansible dir
ansible.builtin.file:
file:
path: "{{ test_dir }}"
state: directory
mode: "0755"
##############################################################################
- name: Grant ansible user read access to a file
ansible.posix.acl:
acl:
path: "{{ test_file }}"
entity: "{{ test_user }}"
etype: user
@ -56,21 +52,12 @@
state: present
register: output
- name: Debug ansible.posix.acl output
ansible.builtin.debug:
msg: "{{ output }}"
- name: Get getfacl output
ansible.builtin.command: getfacl {{ test_file | quote }}
changed_when: false
- name: get getfacl output
shell: "getfacl {{ test_file | quote }}"
register: getfacl_output
- name: Debug getfacl output
ansible.builtin.debug:
msg: "{{ getfacl_output.stdout_lines }}"
- name: Verify Output
ansible.builtin.assert:
- name: verify output
assert:
that:
- output is changed
- output is not failed
@ -78,25 +65,16 @@
- "'user:{{ test_user }}:r--' in getfacl_output.stdout_lines"
##############################################################################
- name: Obtain the acl for a specific file
ansible.posix.acl:
acl:
path: "{{ test_file }}"
register: output
- name: Debug ansible.posix.acl output
ansible.builtin.debug:
msg: "{{ output }}"
- name: Get getfacl output
ansible.builtin.command: getfacl {{ test_file | quote }}
changed_when: false
- name: get getfacl output
shell: "getfacl {{ test_file | quote }}"
register: getfacl_output
- name: Debug getfacl output
ansible.builtin.debug:
msg: "{{ getfacl_output.stdout_lines }}"
- name: Verify output
ansible.builtin.assert:
- name: verify output
assert:
that:
- output is not changed
- output is not failed
@ -111,22 +89,20 @@
- "'mask::r--' in getfacl_output.stdout_lines"
- "'other::r--' in getfacl_output.stdout_lines"
##############################################################################
#
- name: Removes the acl for ansible user on a specific file
ansible.posix.acl:
acl:
path: "{{ test_file }}"
entity: "{{ test_user }}"
etype: user
state: absent
register: output
- name: Get getfacl output
ansible.builtin.command: getfacl {{ test_file | quote }}
changed_when: false
- name: get getfacl output
shell: "getfacl {{ test_file | quote }}"
register: getfacl_output
- name: Verify output
ansible.builtin.assert:
- name: verify output
assert:
that:
- output is changed
- output is not failed
@ -134,22 +110,21 @@
- "'user:{{ test_user }}:r--' not in getfacl_output.stdout_lines"
##############################################################################
- name: Sets default acl for ansible user on ansible dir
ansible.posix.acl:
acl:
path: "{{ test_dir }}"
entity: "{{ test_user }}"
etype: user
permissions: rw
default: true
default: yes
state: present
register: output
- name: Get getfacl output
ansible.builtin.command: getfacl {{ test_dir | quote }}
changed_when: false
- name: get getfacl output
shell: "getfacl {{ test_dir | quote }}"
register: getfacl_output
- name: Verify output
ansible.builtin.assert:
- name: verify output
assert:
that:
- output is changed
- output is not failed
@ -157,24 +132,22 @@
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
##############################################################################
- name: Cleanup
ansible.builtin.command: setfacl -b {{ test_dir | quote }}
changed_when: false
shell: "setfacl -b {{ test_dir | quote }}"
##############################################################################
- name: Same as previous but using entry shorthand
ansible.posix.acl:
acl:
path: "{{ test_dir }}"
entry: user:{{ test_user }}:rw-
default: true
entry: "user:{{ test_user }}:rw-"
default: yes
state: present
register: output
- name: Get getfacl output
ansible.builtin.command: getfacl {{ test_dir | quote }}
changed_when: false
- name: get getfacl output
shell: "getfacl {{ test_dir | quote }}"
register: getfacl_output
- name: Verify output
ansible.builtin.assert:
- name: verify output
assert:
that:
- output is changed
- output is not failed
@ -182,20 +155,19 @@
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
##############################################################################
- name: Same as previous, to test idempotence
ansible.posix.acl:
acl:
path: "{{ test_dir }}"
entry: user:{{ test_user }}:rw-
default: true
entry: "user:{{ test_user }}:rw-"
default: yes
state: present
register: output
- name: Get getfacl output
ansible.builtin.command: getfacl {{ test_dir | quote }}
changed_when: false
- name: get getfacl output
shell: "getfacl {{ test_dir | quote }}"
register: getfacl_output
- name: Verify output
ansible.builtin.assert:
- name: verify output
assert:
that:
- output is not changed
- output is not failed
@ -203,34 +175,32 @@
- "'default:user:{{ test_user }}:rw-' in getfacl_output.stdout_lines"
##############################################################################
- name: Cleanup
ansible.builtin.command: setfacl -b {{ test_dir | quote }}
changed_when: false
shell: "setfacl -b {{ test_dir | quote }}"
##############################################################################
- name: Set default acls
ansible.posix.acl:
acl:
path: "{{ test_dir }}"
entry: "{{ item }}"
default: true
default: yes
state: present
with_items:
- user:{{ test_user }}:rw-
- group:{{ test_group }}:rw-
- "user:{{ test_user }}:rw-"
- "group:{{ test_group }}:rw-"
- name: Remove default group test_user acl
ansible.posix.acl:
acl:
path: "{{ test_dir }}"
entry: group:{{ test_group }}:rw-
default: true
entry: "group:{{ test_group }}:rw-"
default: yes
state: absent
register: output
- name: Get getfacl output
ansible.builtin.command: getfacl {{ test_dir | quote }}
changed_when: false
- name: get getfacl output
shell: "getfacl {{ test_dir | quote }}"
register: getfacl_output
- name: Verify output
ansible.builtin.assert:
- name: verify output
assert:
that:
- output is changed
- output is not failed

View file

@ -1,4 +1,3 @@
---
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
# This file is part of Ansible
@ -16,21 +15,22 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Test ACL
- block:
- 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:
test_user: ansible_user
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"
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 }}"

View file

@ -1,3 +1,2 @@
---
dependencies:
- prepare_tests

View file

@ -1,4 +1,3 @@
---
# Test code for the at module.
# (c) 2017, James Tanner <tanner.jc@gmail.com>
@ -17,56 +16,47 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Set output_dir_test fast
ansible.builtin.set_fact:
output_dir_test: "{{ output_dir }}/at"
- set_fact: output_dir_test={{output_dir}}/at
- name: Make sure our testing sub-directory does not exist
ansible.builtin.file:
path: "{{ output_dir_test }}"
state: absent
- name: make sure our testing sub-directory does not exist
file: path="{{ output_dir_test }}" state=absent
- name: Create our testing sub-directory
ansible.builtin.file:
path: "{{ output_dir_test }}"
state: directory
mode: "0755"
- name: create our testing sub-directory
file: path="{{ output_dir_test }}" state=directory
##
## at
##
- name: Define distros to attempt installing at on
ansible.builtin.set_fact:
- name: define distros to attempt installing at on
set_fact:
package_distros:
- RedHat
- CentOS
- ScientificLinux
- Fedora
- Ubuntu
- Debian
- openSUSE Leap
- RedHat
- CentOS
- ScientificLinux
- Fedora
- Ubuntu
- Debian
- openSUSE Leap
- name: Ensure at is installed
ansible.builtin.package:
- name: ensure at is installed
package:
name: at
state: present
when: ansible_distribution in package_distros
- name: Run the first example
ansible.posix.at:
command: ls -d / > /dev/null
- name: run the first example
at:
command: "ls -d / > /dev/null"
count: 20
units: minutes
register: at_test0
- name: Debug var=at_test0
ansible.builtin.debug:
var: at_test0
- name: Validate results
ansible.builtin.assert:
that:
- at_test0.changed is defined
- at_test0.count is defined
- at_test0.script_file is defined
- at_test0.state is defined
- at_test0.units is defined
- debug: var=at_test0
- name: validate results
assert:
that:
- 'at_test0.changed is defined'
- 'at_test0.count is defined'
- 'at_test0.script_file is defined'
- 'at_test0.state is defined'
- 'at_test0.units is defined'

View file

@ -1,4 +1,3 @@
---
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_command: command="/bin/true" ssh-dss DATA_COMMAND root@testing
@ -9,27 +8,27 @@ dss_key_trailing: ssh-dss DATA_TRAILING root@testing foo bar baz
rsa_key_basic: ssh-rsa DATA_BASIC root@testing
multiple_key_base: |
ssh-rsa DATA_BASIC 1@testing
ssh-dss DATA_TRAILING 2@testing foo bar baz
ssh-dss DATA_TRAILING 3@testing foo bar baz
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
ssh-rsa DATA_BASIC 1@testing
ssh-dss DATA_TRAILING 2@testing foo bar baz
ssh-dss DATA_TRAILING 3@testing foo bar baz
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
multiple_key_different_order: |
ssh-dss DATA_TRAILING 2@testing foo bar baz
ssh-dss DATA_TRAILING 3@testing foo bar baz
ssh-rsa DATA_BASIC 1@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
ssh-dss DATA_TRAILING 2@testing foo bar baz
ssh-dss DATA_TRAILING 3@testing foo bar baz
ssh-rsa DATA_BASIC 1@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
multiple_key_different_order_2: |
ssh-dss DATA_TRAILING 2@testing foo bar baz
ssh-rsa WHATEVER 2.5@testing
ssh-dss DATA_TRAILING 3@testing foo bar baz
ssh-rsa DATA_BASIC 1@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
ssh-dss DATA_TRAILING 2@testing foo bar baz
ssh-rsa WHATEVER 2.5@testing
ssh-dss DATA_TRAILING 3@testing foo bar baz
ssh-rsa DATA_BASIC 1@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
multiple_key_exclusive: |
ssh-rsa DATA_BASIC 1@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
ssh-rsa DATA_BASIC 1@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
multiple_keys_comments: |
ssh-rsa DATA_BASIC 1@testing

View file

@ -1,3 +1,2 @@
---
dependencies:
- prepare_tests

View file

@ -1,37 +1,34 @@
---
# -------------------------------------------------------------
# check mode
- name: CHECK MODE | copy an existing file in place with comments
ansible.builtin.copy:
copy:
src: existing_authorized_keys
dest: "{{ output_dir | expanduser }}/authorized_keys"
mode: "0600"
- name: CHECK MODE | add key in check mode to validate return codes
ansible.posix.authorized_key:
authorized_key:
user: root
key: "{{ multiple_key_different_order_2 }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
check_mode: true
check_mode: True
register: result
- name: CHECK MODE | assert that authorized_keys return values are consistent
ansible.builtin.assert:
assert:
that:
- result.changed == True
- 'result.changed == True'
- '"user" in result'
- '"key" in result'
- name: CHECK MODE | recopy authorized_keys to ensure it was not changed
ansible.builtin.copy:
copy:
src: existing_authorized_keys
dest: "{{ output_dir | expanduser }}/authorized_keys"
mode: "0600"
register: result
- name: CHECK MODE | assert that the authorized_keys file was not changed
ansible.builtin.assert:
assert:
that:
- result.changed == False
- 'result.changed == False'

View file

@ -1,9 +1,8 @@
---
# -------------------------------------------------------------
# comments
- name: Add rsa key with existing comment
ansible.posix.authorized_key:
authorized_key:
user: root
key: "{{ rsa_key_basic }}"
state: present
@ -11,7 +10,7 @@
register: result
- name: Change the comment on an existing key
ansible.posix.authorized_key:
authorized_key:
user: root
key: "{{ rsa_key_basic }}"
comment: user@acme.com
@ -19,18 +18,18 @@
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Get the file content
ansible.builtin.command: fgrep DATA_BASIC "{{ output_dir | expanduser }}/authorized_keys"
changed_when: false
- name: get the file content
shell: cat "{{ output_dir | expanduser }}/authorized_keys" | fgrep DATA_BASIC
changed_when: no
register: content
- name: Assert that comment on an existing key was changed
ansible.builtin.assert:
assert:
that:
- "'user@acme.com' in content.stdout"
- name: Set the same key with comment to ensure no changes are reported
ansible.posix.authorized_key:
authorized_key:
user: root
key: "{{ rsa_key_basic }}"
comment: user@acme.com
@ -39,12 +38,11 @@
register: result
- name: Assert that no changes were made when running again
ansible.builtin.assert:
assert:
that:
- not result.changed
- name: Debug the result and content
ansible.builtin.debug:
- debug:
var: "{{ item }}"
verbosity: 1
with_items:

View file

@ -1,4 +1,3 @@
---
# test code for the authorized_key module
# - (c) 2014, James Cammarata <jcammarata@ansible.com>
# - (c) 2021, Hideki Saito <saito@fgrep.org>
@ -18,16 +17,16 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Setup testing environment
ansible.builtin.import_tasks: setup_steps.yml
import_tasks: setup_steps.yml
- name: Test for multiple keys handling
ansible.builtin.import_tasks: multiple_keys.yml
import_tasks: multiple_keys.yml
- name: Test for ssh-dss key handling
ansible.builtin.import_tasks: ssh_dss.yml
import_tasks: ssh_dss.yml
- name: Test for check mode
ansible.builtin.import_tasks: check_mode.yml
import_tasks: check_mode.yml
- name: Test for the management of comments with key
ansible.builtin.import_tasks: comments.yml
import_tasks: comments.yml

View file

@ -1,39 +1,38 @@
---
# -------------------------------------------------------------
# multiple keys
- name: Add multiple keys
ansible.posix.authorized_key:
- name: add multiple keys
authorized_key:
user: root
key: "{{ multiple_key_base }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == multiple_key_base
- result.key_options == None
- 'result.changed == True'
- 'result.key == multiple_key_base'
- 'result.key_options == None'
- name: Add multiple keys different order
ansible.posix.authorized_key:
- name: add multiple keys different order
authorized_key:
user: root
key: "{{ multiple_key_different_order }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == multiple_key_different_order
- result.key_options == None
- 'result.changed == True'
- 'result.key == multiple_key_different_order'
- 'result.key_options == None'
- name: Add multiple keys exclusive
ansible.posix.authorized_key:
- name: add multiple keys exclusive
authorized_key:
user: root
key: "{{ multiple_key_exclusive }}"
state: present
@ -41,42 +40,42 @@
exclusive: true
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == multiple_key_exclusive
- result.key_options == None
- 'result.changed == True'
- 'result.key == multiple_key_exclusive'
- 'result.key_options == None'
- name: Add multiple keys in different calls
ansible.posix.authorized_key:
- name: add multiple keys in different calls
authorized_key:
user: root
key: ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
key: "ecdsa-sha2-nistp521 ECDSA_DATA 4@testing"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Add multiple keys in different calls
ansible.posix.authorized_key:
- name: add multiple keys in different calls
authorized_key:
user: root
key: ssh-rsa DATA_BASIC 1@testing
key: "ssh-rsa DATA_BASIC 1@testing"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Get the file content
ansible.builtin.command: /bin/cat "{{ output_dir | expanduser }}/authorized_keys"
changed_when: false
- name: get the file content
shell: cat "{{ output_dir | expanduser }}/authorized_keys"
changed_when: no
register: multiple_keys_at_a_time
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == false
- multiple_keys_at_a_time.stdout == multiple_key_exclusive.strip()
- 'result.changed == false'
- 'multiple_keys_at_a_time.stdout == multiple_key_exclusive.strip()'
- name: Add multiple keys comment
ansible.posix.authorized_key:
- name: add multiple keys comment
authorized_key:
user: root
key: "{{ multiple_keys_comments }}"
state: present
@ -84,14 +83,14 @@
exclusive: true
register: result
- name: Get the file content
ansible.builtin.command: /bin/cat "{{ output_dir | expanduser }}/authorized_keys"
changed_when: false
- name: get the file content
shell: cat "{{ output_dir | expanduser }}/authorized_keys"
changed_when: no
register: multiple_keys_comments
- name: Assert that the keys exist and comment only lines were not added
ansible.builtin.assert:
- name: assert that the keys exist and comment only lines were not added
assert:
that:
- result.changed == False
- multiple_keys_comments.stdout == multiple_key_exclusive.strip()
- result.key_options == None
- 'result.changed == False'
- 'multiple_keys_comments.stdout == multiple_key_exclusive.strip()'
- 'result.key_options == None'

View file

@ -1,40 +1,37 @@
---
# -------------------------------------------------------------
# Setup steps
- name: Clean up the working directory and files
ansible.builtin.file:
path: "{{ output_dir }}"
file:
path: '{{ output_dir }}'
state: absent
- name: Create the working directory
ansible.builtin.file:
path: "{{ output_dir }}"
file:
path: '{{ output_dir }}'
state: directory
mode: "0744"
- name: Copy an existing file in place with comments
ansible.builtin.copy:
- name: copy an existing file in place with comments
copy:
src: existing_authorized_keys
dest: "{{ output_dir | expanduser }}/authorized_keys"
mode: "0600"
- name: Add multiple keys different order
ansible.posix.authorized_key:
- name: add multiple keys different order
authorized_key:
user: root
key: "{{ multiple_key_different_order_2 }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Get the file content
ansible.builtin.command: /bin/cat "{{ output_dir | expanduser }}/authorized_keys"
changed_when: false
- name: get the file content
shell: cat "{{ output_dir | expanduser }}/authorized_keys"
changed_when: no
register: multiple_keys_existing
- name: Assert that the key was added and comments and ordering preserved
ansible.builtin.assert:
- name: assert that the key was added and comments and ordering preserved
assert:
that:
- result.changed == True
- 'result.changed == True'
- '"# I like candy" in multiple_keys_existing.stdout'
- '"# I like candy" in multiple_keys_existing.stdout_lines[0]'
- '"ssh-rsa DATA_BASIC 1@testing" in multiple_keys_existing.stdout'
@ -44,20 +41,19 @@
# start afresh
- name: Remove file foo.txt
ansible.builtin.file:
- name: remove file foo.txt
file:
path: "{{ output_dir | expanduser }}/authorized_keys"
state: absent
- name: Touch the authorized_keys file
ansible.builtin.file:
- name: touch the authorized_keys file
file:
dest: "{{ output_dir }}/authorized_keys"
state: touch
mode: "0600"
register: result
- name: Assert that the authorized_keys file was created
ansible.builtin.assert:
- name: assert that the authorized_keys file was created
assert:
that:
- result.changed == True
- result.state == "file"
- 'result.changed == True'
- 'result.state == "file"'

View file

@ -1,250 +1,241 @@
---
# -------------------------------------------------------------
# basic ssh-dss key
- name: Add basic ssh-dss key
ansible.posix.authorized_key:
user: root
key: "{{ dss_key_basic }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
- name: add basic ssh-dss key
authorized_key: user=root key="{{ dss_key_basic }}" state=present path="{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == dss_key_basic
- result.key_options == None
- 'result.changed == True'
- 'result.key == dss_key_basic'
- 'result.key_options == None'
- name: Re-add basic ssh-dss key
ansible.posix.authorized_key:
user: root
key: "{{ dss_key_basic }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
- name: re-add basic ssh-dss key
authorized_key: user=root key="{{ dss_key_basic }}" state=present path="{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that nothing changed
ansible.builtin.assert:
- name: assert that nothing changed
assert:
that:
- result.changed == False
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with an unquoted option
- name: Add ssh-dss key with an unquoted option
ansible.posix.authorized_key:
- name: add ssh-dss key with an unquoted option
authorized_key:
user: root
key: "{{ dss_key_unquoted_option }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == dss_key_unquoted_option
- result.key_options == None
- 'result.changed == True'
- 'result.key == dss_key_unquoted_option'
- 'result.key_options == None'
- name: Re-add ssh-dss key with an unquoted option
ansible.posix.authorized_key:
- name: re-add ssh-dss key with an unquoted option
authorized_key:
user: root
key: "{{ dss_key_unquoted_option }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that nothing changed
ansible.builtin.assert:
- name: assert that nothing changed
assert:
that:
- result.changed == False
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a leading command="/bin/foo"
- name: Add ssh-dss key with a leading command
ansible.posix.authorized_key:
- name: add ssh-dss key with a leading command
authorized_key:
user: root
key: "{{ dss_key_command }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == dss_key_command
- result.key_options == None
- 'result.changed == True'
- 'result.key == dss_key_command'
- 'result.key_options == None'
- name: Re-add ssh-dss key with a leading command
ansible.posix.authorized_key:
- name: re-add ssh-dss key with a leading command
authorized_key:
user: root
key: "{{ dss_key_command }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that nothing changed
ansible.builtin.assert:
- name: assert that nothing changed
assert:
that:
- result.changed == False
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a complex quoted leading command
# ie. command="/bin/echo foo 'bar baz'"
- name: Add ssh-dss key with a complex quoted leading command
ansible.posix.authorized_key:
- name: add ssh-dss key with a complex quoted leading command
authorized_key:
user: root
key: "{{ dss_key_complex_command }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == dss_key_complex_command
- result.key_options == None
- 'result.changed == True'
- 'result.key == dss_key_complex_command'
- 'result.key_options == None'
- name: Re-add ssh-dss key with a complex quoted leading command
ansible.posix.authorized_key:
- name: re-add ssh-dss key with a complex quoted leading command
authorized_key:
user: root
key: "{{ dss_key_complex_command }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that nothing changed
ansible.builtin.assert:
- name: assert that nothing changed
assert:
that:
- result.changed == False
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a command and a single option, which are
# in a comma-separated list
- name: Add ssh-dss key with a command and a single option
ansible.posix.authorized_key:
- name: add ssh-dss key with a command and a single option
authorized_key:
user: root
key: "{{ dss_key_command_single_option }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == dss_key_command_single_option
- result.key_options == None
- 'result.changed == True'
- 'result.key == dss_key_command_single_option'
- 'result.key_options == None'
- name: Re-add ssh-dss key with a command and a single option
ansible.posix.authorized_key:
- name: re-add ssh-dss key with a command and a single option
authorized_key:
user: root
key: "{{ dss_key_command_single_option }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that nothing changed
ansible.builtin.assert:
- name: assert that nothing changed
assert:
that:
- result.changed == False
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a command and multiple other options
- name: Add ssh-dss key with a command and multiple options
ansible.posix.authorized_key:
- name: add ssh-dss key with a command and multiple options
authorized_key:
user: root
key: "{{ dss_key_command_multiple_options }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == dss_key_command_multiple_options
- result.key_options == None
- 'result.changed == True'
- 'result.key == dss_key_command_multiple_options'
- 'result.key_options == None'
- name: Re-add ssh-dss key with a command and multiple options
ansible.posix.authorized_key:
- name: re-add ssh-dss key with a command and multiple options
authorized_key:
user: root
key: "{{ dss_key_command_multiple_options }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that nothing changed
ansible.builtin.assert:
- name: assert that nothing changed
assert:
that:
- result.changed == False
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with multiple trailing parts, which are space-
# separated and not quoted in any way
- name: Add ssh-dss key with trailing parts
ansible.posix.authorized_key:
- name: add ssh-dss key with trailing parts
authorized_key:
user: root
key: "{{ dss_key_trailing }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
- name: assert that the key was added
assert:
that:
- result.changed == True
- result.key == dss_key_trailing
- result.key_options == None
- 'result.changed == True'
- 'result.key == dss_key_trailing'
- 'result.key_options == None'
- name: Re-add ssh-dss key with trailing parts
ansible.posix.authorized_key:
- name: re-add ssh-dss key with trailing parts
authorized_key:
user: root
key: "{{ dss_key_trailing }}"
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that nothing changed
ansible.builtin.assert:
- name: assert that nothing changed
assert:
that:
- result.changed == False
- 'result.changed == False'
# -------------------------------------------------------------
# basic ssh-dss key with mutliple permit-open options
# https://github.com/ansible/ansible-modules-core/issues/1715
- name: Add basic ssh-dss key with multi-opts
ansible.posix.authorized_key:
- name: add basic ssh-dss key with multi-opts
authorized_key:
user: root
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
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key with multi-opts was added
ansible.builtin.assert:
- name: assert that the key with multi-opts was added
assert:
that:
- result.changed == True
- 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.changed == True'
- '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\""'
- name: Get the file content
ansible.builtin.command: fgrep DATA_BASIC "{{ output_dir | expanduser }}/authorized_keys"
changed_when: false
- name: get the file content
shell: cat "{{ output_dir | expanduser }}/authorized_keys" | fgrep DATA_BASIC
changed_when: no
register: content
- name: Validate content
ansible.builtin.assert:
- name: validate content
assert:
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"'

View file

@ -1,3 +1,2 @@
---
dependencies:
- setup_pkg_mgr

View file

@ -1,173 +1,172 @@
---
# Test playbook for the firewalld module - icmp block inversion operations
# (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)
- name: Icmp block inversion enabled when icmp block inversion is truthy and state is enabled
block:
- name: Testing enable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: true
permanent: true
state: enabled
register: result
- name: Testing enable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: yes
permanent: yes
state: enabled
register: result
- name: Assert icmp block inversion is enabled
ansible.builtin.assert:
that:
- result is changed
- name: assert icmp block inversion is enabled
assert:
that:
- result is changed
- name: Testing enable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: true
permanent: true
state: enabled
register: result
- name: Testing enable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: yes
permanent: yes
state: enabled
register: result
- name: Assert icmp block inversion is enabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert icmp block inversion is enabled (verify not changed)
assert:
that:
- result is not changed
- name: Icmp block inversion disabled when icmp block inversion is falsy and state is enabled
block:
- name: Testing disable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: false
permanent: true
state: enabled
register: result
- name: Testing disable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: no
permanent: yes
state: enabled
register: result
- name: Assert icmp block inversion is disabled
ansible.builtin.assert:
that:
- result is changed
- name: assert icmp block inversion is disabled
assert:
that:
- result is changed
- name: Testing disable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: false
permanent: true
state: enabled
register: result
- name: Testing disable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: no
permanent: yes
state: enabled
register: result
- name: Assert icmp block inversion is disabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert icmp block inversion is disabled (verify not changed)
assert:
that:
- result is not changed
- name: Icmp block inversion enabled when icmp block inversion is falsy and state is disabled
block:
- name: Testing enable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: false
permanent: true
state: disabled
register: result
- name: Testing enable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: no
permanent: yes
state: disabled
register: result
- name: Assert icmp block inversion is enabled
ansible.builtin.assert:
that:
- result is changed
- name: assert icmp block inversion is enabled
assert:
that:
- result is changed
- name: Testing enable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: false
permanent: true
state: disabled
register: result
- name: Testing enable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: no
permanent: yes
state: disabled
register: result
- name: Assert icmp block inversion is enabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert icmp block inversion is enabled (verify not changed)
assert:
that:
- result is not changed
- name: Icmp block inversion disabled when icmp block inversion is truthy and state is disabled
block:
- name: Testing disable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: true
permanent: true
state: disabled
register: result
- name: Testing disable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: yes
permanent: yes
state: disabled
register: result
- name: Assert icmp block inversion is disabled
ansible.builtin.assert:
that:
- result is changed
- name: assert icmp block inversion is disabled
assert:
that:
- result is changed
- name: Testing disable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: true
permanent: true
state: disabled
register: result
- name: Testing disable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: yes
permanent: yes
state: disabled
register: result
- name: Assert icmp block inversion is disabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert icmp block inversion is disabled (verify not changed)
assert:
that:
- result is not changed
# Validate backwards compatible behavior until icmp block inversion is switched from string to boolean type
- name: Icmp block inversion enabled when icmp block inversion is non-boolean string and state is enabled
block:
- name: Testing enable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: some string
permanent: true
state: enabled
register: result
- name: Testing enable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: 'some string'
permanent: yes
state: enabled
register: result
- name: Assert icmp block inversion is enabled
ansible.builtin.assert:
that:
- result is changed
- name: assert icmp block inversion is enabled
assert:
that:
- result is changed
- name: Testing enable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: some string
permanent: true
state: enabled
register: result
- name: Testing enable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: 'some string'
permanent: yes
state: enabled
register: result
- name: Assert icmp block inversion is enabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert icmp block inversion is enabled (verify not changed)
assert:
that:
- result is not changed
- name: Icmp block inversion disabled when icmp block inversion is non-boolean string and state is disabled
block:
- name: Testing disable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: some string
permanent: true
state: disabled
register: result
- name: Testing disable icmp block inversion
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: 'some string'
permanent: yes
state: disabled
register: result
- name: Assert icmp block inversion is disabled
ansible.builtin.assert:
that:
- result is changed
- name: assert icmp block inversion is disabled
assert:
that:
- result is changed
- name: Testing disable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: some string
permanent: true
state: disabled
register: result
- name: Testing disable icmp block inversion (verify not changed)
ansible.posix.firewalld:
zone: trusted
icmp_block_inversion: 'some string'
permanent: yes
state: disabled
register: result
- name: Assert icmp block inversion is disabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert icmp block inversion is disabled (verify not changed)
assert:
that:
- result is not changed

View file

@ -1,88 +1,87 @@
---
# Test playbook for the firewalld module - interface operations
# (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)
- name: Validate adding interface
block:
- name: Add lo interface to trusted zone
ansible.posix.firewalld:
interface: lo
zone: trusted
permanent: true
state: enabled
register: result
- name: Add lo interface to trusted zone
ansible.posix.firewalld:
interface: lo
zone: trusted
permanent: Yes
state: enabled
register: result
- name: Assert lo was added to trusted zone
ansible.builtin.assert:
that:
- result is changed
- name: assert lo was added to trusted zone
assert:
that:
- result is changed
- name: Add lo interface to trusted zone (verify not changed)
ansible.posix.firewalld:
interface: lo
zone: trusted
permanent: true
state: enabled
register: result
- name: Add lo interface to trusted zone (verify not changed)
ansible.posix.firewalld:
interface: lo
zone: trusted
permanent: Yes
state: enabled
register: result
- name: Assert lo was added to trusted zone (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert lo was added to trusted zone (verify not changed)
assert:
that:
- result is not changed
- name: Validate moving interfaces
block:
- name: Move lo interface from trusted zone to internal zone
ansible.posix.firewalld:
interface: lo
zone: internal
permanent: true
state: enabled
register: result
- name: Move lo interface from trusted zone to internal zone
ansible.posix.firewalld:
interface: lo
zone: internal
permanent: Yes
state: enabled
register: result
- name: Assert lo was moved from trusted zone to internal zone
ansible.builtin.assert:
that:
- result is changed
- name: Assert lo was moved from trusted zone to internal zone
assert:
that:
- result is changed
- name: Move lo interface from trusted zone to internal zone (verify not changed)
ansible.posix.firewalld:
interface: lo
zone: internal
permanent: true
state: enabled
register: result
- name: Move lo interface from trusted zone to internal zone (verify not changed)
ansible.posix.firewalld:
interface: lo
zone: internal
permanent: Yes
state: enabled
register: result
- name: Assert lo was moved from trusted zone to internal zone (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert lo was moved from trusted zone to internal zone (verify not changed)
assert:
that:
- result is not changed
- name: Validate removing interface
block:
- name: Remove lo interface from internal zone
ansible.posix.firewalld:
interface: lo
zone: internal
permanent: true
state: disabled
register: result
- name: Remove lo interface from internal zone
ansible.posix.firewalld:
interface: lo
zone: internal
permanent: Yes
state: disabled
register: result
- name: Assert lo interface was removed from internal zone
ansible.builtin.assert:
that:
- result is changed
- name: Assert lo interface was removed from internal zone
assert:
that:
- result is changed
- name: Remove lo interface from internal zone (verify not changed)
ansible.posix.firewalld:
interface: lo
zone: internal
permanent: true
state: disabled
register: result
- name: Remove lo interface from internal zone (verify not changed)
ansible.posix.firewalld:
interface: lo
zone: internal
permanent: Yes
state: disabled
register: result
- name: Assert lo interface was removed from internal zone (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: Assert lo interface was removed from internal zone (verify not changed)
assert:
that:
- result is not changed

View file

@ -1,24 +1,17 @@
---
# Test playbook for the firewalld module
# (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)
- 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:
- name: Ensure firewalld is installed
ansible.builtin.package:
package:
name: firewalld
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
ansible.builtin.service:
service:
name: dbus-broker
enabled: true
state: started
@ -26,20 +19,25 @@
- name: Test Online Operations
block:
- name: Start firewalld
ansible.builtin.service:
- name: start firewalld
service:
name: firewalld
state: started
- name: Import test tasks
ansible.builtin.import_tasks: run_all_tests.yml
- import_tasks: run_all_tests.yml
- name: Test Offline Operations
block:
- name: Stop firewalld
ansible.builtin.service:
- name: stop firewalld
service:
name: firewalld
state: stopped
- name: Import test tasks
ansible.builtin.import_tasks: run_all_tests.yml
- 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

View file

@ -1,173 +1,172 @@
---
# Test playbook for the firewalld module - masquerade operations
# (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)
- name: Masquerade enabled when masquerade is truthy and state is enabled
block:
- name: Testing enable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: true
permanent: true
state: enabled
register: result
- name: Testing enable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: yes
permanent: yes
state: enabled
register: result
- name: Assert masquerade is enabled
ansible.builtin.assert:
that:
- result is changed
- name: assert masquerade is enabled
assert:
that:
- result is changed
- name: Testing enable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: true
permanent: true
state: enabled
register: result
- name: Testing enable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: yes
permanent: yes
state: enabled
register: result
- name: Assert masquerade is enabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert masquerade is enabled (verify not changed)
assert:
that:
- result is not changed
- name: Masquerade disabled when masquerade is falsy and state is enabled
block:
- name: Testing disable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: false
permanent: true
state: enabled
register: result
- name: Testing disable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: no
permanent: yes
state: enabled
register: result
- name: Assert masquerade is disabled
ansible.builtin.assert:
that:
- result is changed
- name: assert masquerade is disabled
assert:
that:
- result is changed
- name: Testing disable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: false
permanent: true
state: enabled
register: result
- name: Testing disable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: no
permanent: yes
state: enabled
register: result
- name: Assert masquerade is disabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert masquerade is disabled (verify not changed)
assert:
that:
- result is not changed
- name: Masquerade enabled when masquerade is falsy and state is disabled
block:
- name: Testing enable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: false
permanent: true
state: disabled
register: result
- name: Testing enable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: no
permanent: yes
state: disabled
register: result
- name: Assert masquerade is enabled
ansible.builtin.assert:
that:
- result is changed
- name: assert masquerade is enabled
assert:
that:
- result is changed
- name: Testing enable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: false
permanent: true
state: disabled
register: result
- name: Testing enable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: no
permanent: yes
state: disabled
register: result
- name: Assert masquerade is enabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert masquerade is enabled (verify not changed)
assert:
that:
- result is not changed
- name: Masquerade disabled when masquerade is truthy and state is disabled
block:
- name: Testing disable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: true
permanent: true
state: disabled
register: result
- name: Testing disable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: yes
permanent: yes
state: disabled
register: result
- name: Assert masquerade is disabled
ansible.builtin.assert:
that:
- result is changed
- name: assert masquerade is disabled
assert:
that:
- result is changed
- name: Testing disable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: true
permanent: true
state: disabled
register: result
- name: Testing disable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: yes
permanent: yes
state: disabled
register: result
- name: Assert masquerade is disabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert masquerade is disabled (verify not changed)
assert:
that:
- result is not changed
# Validate backwards compatible behavior until masquerade is switched from string to boolean type
- name: Masquerade enabled when masquerade is non-boolean string and state is enabled
block:
- name: Testing enable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: some string
permanent: true
state: enabled
register: result
- name: Testing enable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: 'some string'
permanent: yes
state: enabled
register: result
- name: Assert masquerade is enabled
ansible.builtin.assert:
that:
- result is changed
- name: assert masquerade is enabled
assert:
that:
- result is changed
- name: Testing enable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: some string
permanent: true
state: enabled
register: result
- name: Testing enable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: 'some string'
permanent: yes
state: enabled
register: result
- name: Assert masquerade is enabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert masquerade is enabled (verify not changed)
assert:
that:
- result is not changed
- name: Masquerade disabled when masquerade is non-boolean string and state is disabled
block:
- name: Testing disable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: some string
permanent: true
state: disabled
register: result
- name: Testing disable masquerade
ansible.posix.firewalld:
zone: trusted
masquerade: 'some string'
permanent: yes
state: disabled
register: result
- name: Assert masquerade is disabled
ansible.builtin.assert:
that:
- result is changed
- name: assert masquerade is disabled
assert:
that:
- result is changed
- name: Testing disable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: some string
permanent: true
state: disabled
register: result
- name: Testing disable masquerade (verify not changed)
ansible.posix.firewalld:
zone: trusted
masquerade: 'some string'
permanent: yes
state: disabled
register: result
- name: Assert masquerade is disabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: assert masquerade is disabled (verify not changed)
assert:
that:
- result is not changed

View file

@ -1,10 +1,9 @@
---
# Test playbook for the firewalld module - port operations
# (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)
- name: Firewalld port forward test permanent enabled
ansible.posix.firewalld:
- name: firewalld port forward test permanent enabled
firewalld:
port_forward:
- port: 8080
proto: tcp
@ -13,13 +12,13 @@
state: enabled
register: result
- name: Assert firewalld port test permanent enabled worked
ansible.builtin.assert:
- name: assert firewalld port test permanent enabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld port test permanent enabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld port test permanent enabled rerun (verify not changed)
firewalld:
port_forward:
- port: 8080
proto: tcp
@ -28,13 +27,13 @@
state: enabled
register: result
- name: Assert firewalld port test permanent enabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld port test permanent enabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld port test permanent disabled
ansible.posix.firewalld:
- name: firewalld port test permanent disabled
firewalld:
port_forward:
- port: 8080
proto: tcp
@ -43,13 +42,13 @@
state: disabled
register: result
- name: Assert firewalld port test permanent disabled worked
ansible.builtin.assert:
- name: assert firewalld port test permanent disabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld port test permanent disabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld port test permanent disabled rerun (verify not changed)
firewalld:
port_forward:
- port: 8080
proto: tcp
@ -58,7 +57,7 @@
state: disabled
register: result
- name: Assert firewalld port test permanent disabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld port test permanent disabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed

View file

@ -1,58 +1,57 @@
---
# Test playbook for the firewalld module - port operations
# (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)
- name: Firewalld port range test permanent enabled
ansible.posix.firewalld:
- name: firewalld port range test permanent enabled
firewalld:
port: 5500-6850/tcp
permanent: true
state: enabled
register: result
- name: Assert firewalld port range test permanent enabled worked
ansible.builtin.assert:
- name: assert firewalld port range test permanent enabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld port range test permanent enabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld port range test permanent enabled rerun (verify not changed)
firewalld:
port: 5500-6850/tcp
permanent: true
state: enabled
register: result
- name: Assert firewalld port range test permanent enabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld port range test permanent enabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld port test permanent enabled
ansible.posix.firewalld:
- name: firewalld port test permanent enabled
firewalld:
port: 6900/tcp
permanent: true
state: enabled
register: result
- name: Assert firewalld port test permanent enabled worked
ansible.builtin.assert:
- name: assert firewalld port test permanent enabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld port test permanent enabled
ansible.posix.firewalld:
- name: firewalld port test permanent enabled
firewalld:
port: 6900/tcp
permanent: true
state: enabled
register: result
- name: Assert firewalld port test permanent enabled worked
ansible.builtin.assert:
- name: assert firewalld port test permanent enabled worked
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld port test disabled
ansible.posix.firewalld:
- name: firewalld port test disabled
firewalld:
port: "{{ item }}"
permanent: true
state: disabled
@ -60,50 +59,50 @@
- 6900/tcp
- 5500-6850/tcp
- name: Firewalld port test permanent enabled
ansible.posix.firewalld:
- name: firewalld port test permanent enabled
firewalld:
port: 8081/tcp
permanent: true
state: enabled
register: result
- name: Assert firewalld port test permanent enabled worked
ansible.builtin.assert:
- name: assert firewalld port test permanent enabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld port test permanent enabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld port test permanent enabled rerun (verify not changed)
firewalld:
port: 8081/tcp
permanent: true
state: enabled
register: result
- name: Assert firewalld port test permanent enabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld port test permanent enabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld port test permanent disabled
ansible.posix.firewalld:
- name: firewalld port test permanent disabled
firewalld:
port: 8081/tcp
permanent: true
state: disabled
register: result
- name: Assert firewalld port test permanent disabled worked
ansible.builtin.assert:
- name: assert firewalld port test permanent disabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld port test permanent disabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld port test permanent disabled rerun (verify not changed)
firewalld:
port: 8081/tcp
permanent: true
state: disabled
register: result
- name: Assert firewalld port test permanent disabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld port test permanent disabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed

View file

@ -1,4 +1,3 @@
---
# Test playbook for the firewalld module - protocol operations
# (c) 2022, Robért S. Guhr <rguhr@cronon.net>
@ -17,50 +16,50 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Firewalld protocol test permanent enabled
ansible.posix.firewalld:
- name: firewalld protocol test permanent enabled
firewalld:
protocol: ospf
permanent: true
state: enabled
register: result
- name: Assert firewalld protocol test permanent enabled worked
ansible.builtin.assert:
- name: assert firewalld protocol test permanent enabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld protocol test permanent enabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld protocol test permanent enabled rerun (verify not changed)
firewalld:
protocol: ospf
permanent: true
state: enabled
register: result
- name: Assert firewalld protocol test permanent enabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld protocol test permanent enabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld protocol test permanent disabled
ansible.posix.firewalld:
- name: firewalld protocol test permanent disabled
firewalld:
protocol: ospf
permanent: true
state: disabled
register: result
- name: Assert firewalld protocol test permanent disabled worked
ansible.builtin.assert:
- name: assert firewalld protocol test permanent disabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld protocol test permanent disabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld protocol test permanent disabled rerun (verify not changed)
firewalld:
protocol: ospf
permanent: true
state: disabled
register: result
- name: Assert firewalld protocol test permanent disabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld protocol test permanent disabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed

View file

@ -1,50 +1,38 @@
---
# Test playbook for the firewalld module
# (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)
- name: Ensure /run/firewalld exists
ansible.builtin.file:
file:
path: /run/firewalld
state: directory
mode: "0755"
# firewalld service operation test cases
- name: Include service test cases for firewalld module
ansible.builtin.include_tasks: service_test_cases.yml
- include_tasks: service_test_cases.yml
# firewalld protocol operation test cases
- name: Include protocol test cases for firewalld module
ansible.builtin.include_tasks: protocol_test_cases.yml
- include_tasks: protocol_test_cases.yml
# firewalld port operation test cases
- name: Include port test cases for firewalld module
ansible.builtin.include_tasks: port_test_cases.yml
- include_tasks: port_test_cases.yml
# firewalld source operation test cases
- name: Include source test cases for firewalld module
ansible.builtin.include_tasks: source_test_cases.yml
- include_tasks: source_test_cases.yml
# firewalld zone operation test cases
- name: Include zone test cases for firewalld module
ansible.builtin.include_tasks: zone_test_cases.yml
- include_tasks: zone_test_cases.yml
# firewalld zone target operation test cases
- name: Include zone target test cases for firewalld module
ansible.builtin.include_tasks: zone_target_test_cases.yml
- include_tasks: zone_target_test_cases.yml
# firewalld port forwarding operation test cases
- name: Include port forward target test cases for firewalld module
ansible.builtin.include_tasks: port_forward_test_cases.yml
- include_tasks: port_forward_test_cases.yml
# firewalld masquerade operation test cases
- name: Include masquerade target test cases for firewalld module
ansible.builtin.include_tasks: masquerade_test_cases.yml
- include_tasks: masquerade_test_cases.yml
# firewalld icmp block inversion operation test cases
- name: Include icmp block inversion target test cases for firewalld module
ansible.builtin.include_tasks: icmp_block_inversion_test_cases.yml
- include_tasks: icmp_block_inversion_test_cases.yml
# firewalld interface operation test cases
- name: Include interface target test cases for firewalld module
ansible.builtin.include_tasks: interface_test_cases.yml
- include_tasks: interface_test_cases.yml

View file

@ -1,4 +1,3 @@
---
# Test playbook for the firewalld module - service operations
# (c) 2017, Adam Miller <admiller@redhat.com>
@ -17,50 +16,50 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Firewalld service test permanent enabled
ansible.posix.firewalld:
- name: firewalld service test permanent enabled
firewalld:
service: https
permanent: true
state: enabled
register: result
- name: Assert firewalld service test permanent enabled worked
ansible.builtin.assert:
- name: assert firewalld service test permanent enabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld service test permanent enabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld service test permanent enabled rerun (verify not changed)
firewalld:
service: https
permanent: true
state: enabled
register: result
- name: Assert firewalld service test permanent enabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld service test permanent enabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld service test permanent disabled
ansible.posix.firewalld:
- name: firewalld service test permanent disabled
firewalld:
service: https
permanent: true
state: disabled
register: result
- name: Assert firewalld service test permanent disabled worked
ansible.builtin.assert:
- name: assert firewalld service test permanent disabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld service test permanent disabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld service test permanent disabled rerun (verify not changed)
firewalld:
service: https
permanent: true
state: disabled
register: result
- name: Assert firewalld service test permanent disabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld service test permanent disabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed

View file

@ -1,4 +1,3 @@
---
# Test playbook for the firewalld module - source operations
# (c) 2019, Hideki Saito <saito@fgrep.org>
@ -17,71 +16,70 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Firewalld source test permanent enabled
ansible.posix.firewalld:
- name: firewalld source test permanent enabled
firewalld:
source: 192.0.2.0/24
zone: internal
permanent: true
permanent: True
state: enabled
register: result
- name: Assert firewalld source test permanent enabled worked
ansible.builtin.assert:
- name: assert firewalld source test permanent enabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld source test permanent enabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld source test permanent enabled rerun (verify not changed)
firewalld:
source: 192.0.2.0/24
zone: internal
permanent: true
permanent: True
state: enabled
register: result
- name: Assert firewalld source test permanent enabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld source test permanent enabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld source test permanent disabled
ansible.posix.firewalld:
- name: firewalld source test permanent disabled
firewalld:
source: 192.0.2.0/24
zone: internal
permanent: true
permanent: True
state: disabled
register: result
- name: Assert firewalld source test permanent disabled worked
ansible.builtin.assert:
- name: assert firewalld source test permanent disabled worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld source test permanent disabled rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld source test permanent disabled rerun (verify not changed)
firewalld:
source: 192.0.2.0/24
zone: internal
permanent: true
permanent: True
state: disabled
register: result
- name: Assert firewalld source test permanent disabled rerun worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld source test permanent disabled rerun worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld source test permanent enabled is exclusive (verify exclusive error)
ansible.posix.firewalld:
- name: firewalld source test permanent enabled is exclusive (verify exclusive error)
firewalld:
source: 192.0.2.0/24
port: 8081/tcp
zone: internal
permanent: true
permanent: True
state: enabled
register: result
ignore_errors: true
- name: Assert firewalld source test permanent enabled is exclusive (verify exclusive error)
ansible.builtin.assert:
- name: assert firewalld source test permanent enabled is exclusive (verify exclusive error)
assert:
that:
- 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 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'"

View file

@ -1,4 +1,3 @@
---
# Test playbook for the firewalld module - source operations
# (c) 2020, Adam Miller <admiller@redhat.com>
@ -17,106 +16,106 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Firewalld dmz zone target DROP
ansible.posix.firewalld:
- name: firewalld dmz zone target DROP
firewalld:
zone: dmz
permanent: true
permanent: True
state: present
target: DROP
register: result
- name: Assert firewalld dmz zone target DROP present worked
ansible.builtin.assert:
- name: assert firewalld dmz zone target DROP present worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld dmz zone target DROP rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld dmz zone target DROP rerun (verify not changed)
firewalld:
zone: dmz
permanent: true
permanent: True
state: present
target: DROP
register: result
- name: Assert firewalld dmz zone target DROP present worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld dmz zone target DROP present worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld dmz zone target DROP absent
ansible.posix.firewalld:
- name: firewalld dmz zone target DROP absent
firewalld:
zone: dmz
permanent: true
permanent: True
state: absent
target: DROP
register: result
- name: Assert firewalld dmz zone target DROP absent worked
ansible.builtin.assert:
- name: assert firewalld dmz zone target DROP absent worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld dmz zone target DROP rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld dmz zone target DROP rerun (verify not changed)
firewalld:
zone: dmz
permanent: true
permanent: True
state: absent
target: DROP
register: result
- name: Assert firewalld dmz zone target DROP present worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld dmz zone target DROP present worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld dmz zone target %%REJECT%%
ansible.posix.firewalld:
- name: firewalld dmz zone target %%REJECT%%
firewalld:
zone: dmz
permanent: true
permanent: True
state: present
target: "%%REJECT%%"
target: '%%REJECT%%'
register: result
- name: Assert firewalld dmz zone target %%REJECT%% present worked
ansible.builtin.assert:
- name: assert firewalld dmz zone target %%REJECT%% present worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld dmz zone target %%REJECT%% rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld dmz zone target %%REJECT%% rerun (verify not changed)
firewalld:
zone: dmz
permanent: true
permanent: True
state: present
target: "%%REJECT%%"
target: '%%REJECT%%'
register: result
- name: Assert firewalld dmz zone target %%REJECT%% present worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld dmz zone target %%REJECT%% present worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld dmz zone target %%REJECT%% absent
ansible.posix.firewalld:
- name: firewalld dmz zone target %%REJECT%% absent
firewalld:
zone: dmz
permanent: true
permanent: True
state: absent
target: "%%REJECT%%"
target: '%%REJECT%%'
register: result
- name: Assert firewalld dmz zone target %%REJECT%% absent worked
ansible.builtin.assert:
- name: assert firewalld dmz zone target %%REJECT%% absent worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld dmz zone target %%REJECT%% rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld dmz zone target %%REJECT%% rerun (verify not changed)
firewalld:
zone: dmz
permanent: true
permanent: True
state: absent
target: "%%REJECT%%"
target: '%%REJECT%%'
register: result
- name: Assert firewalld dmz zone target %%REJECT%% present worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld dmz zone target %%REJECT%% present worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed

View file

@ -1,48 +1,47 @@
---
- name: Firewalld create zone custom
ansible.posix.firewalld:
- name: firewalld create zone custom
firewalld:
zone: custom
permanent: true
permanent: True
state: present
register: result
- name: Assert firewalld custom zone created worked
ansible.builtin.assert:
- name: assert firewalld custom zone created worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld create zone custom rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld create zone custom rerun (verify not changed)
firewalld:
zone: custom
permanent: true
permanent: True
state: present
register: result
- name: Assert firewalld custom zone created worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld custom zone created worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed
- name: Firewalld remove zone custom
ansible.posix.firewalld:
- name: firewalld remove zone custom
firewalld:
zone: custom
permanent: true
permanent: True
state: absent
register: result
- name: Assert firewalld custom zone removed worked
ansible.builtin.assert:
- name: assert firewalld custom zone removed worked
assert:
that:
- result is changed
- result is changed
- name: Firewalld remove custom zone rerun (verify not changed)
ansible.posix.firewalld:
- name: firewalld remove custom zone rerun (verify not changed)
firewalld:
zone: custom
permanent: true
permanent: True
state: absent
register: result
- name: Assert firewalld custom zone removed worked (verify not changed)
ansible.builtin.assert:
- name: assert firewalld custom zone removed worked (verify not changed)
assert:
that:
- result is not changed
- result is not changed

View file

@ -1,53 +1,52 @@
---
# Test playbook for the firewalld_info module
# (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)
# This test is based on the integration test playbook for firewalld module.
- 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)
block:
- name: Ensure firewalld is installed
ansible.builtin.package:
package:
name: firewalld
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: Check to make sure the firewalld python module is available.
ansible.builtin.command: "{{ ansible_python.executable }} -c 'import firewall'"
changed_when: false
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.
ansible.builtin.command: "{{ ansible_python.executable }} -c 'import dbus'"
changed_when: false
shell: "{{ansible_python.executable}} -c 'import dbus'"
register: check_output_dbus
ignore_errors: true
- name: Test Online Operations
block:
- name: Start firewalld
ansible.builtin.service:
- name: start firewalld
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
- 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
ansible.builtin.service:
- name: stop firewalld
service:
name: firewalld
state: stopped
- name: Import test tasks from run_tests_in_stopped.yml
ansible.builtin.import_tasks: run_tests_in_stopped.yml
- import_tasks: run_tests_in_stopped.yml
when:
- check_output_firewall.rc == 0
- check_output_dbus.rc == 0
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)

View file

@ -1,33 +1,32 @@
---
# Test playbook for the firewalld_info module
# (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)
- name: Ensure firewalld_info without options
ansible.posix.firewalld_info:
firewalld_info:
register: result
- name: Assert collected_zones and undefined_zones
ansible.builtin.assert:
assert:
that:
- result.collected_zones and not result.undefined_zones
- 'result.collected_zones and not result.undefined_zones'
- name: Ensure firewalld_info with active_zones
ansible.posix.firewalld_info:
active_zones: true
firewalld_info:
active_zones: yes
register: result
- name: Assert turn active_zones true
ansible.builtin.assert:
assert:
that:
- name: Ensure firewalld_zones with zone list
ansible.posix.firewalld_info:
firewalld_info:
zones:
- public
- invalid_zone
register: result
- name: Assert specified zones
ansible.builtin.assert:
assert:
that:

View file

@ -1,41 +1,40 @@
---
# Test playbook for the firewalld_info module
# (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)
- name: Ensure firewalld_info without options
ansible.posix.firewalld_info:
firewalld_info:
register: result
ignore_errors: true
ignore_errors: yes
- name: Assert firewalld_info fails if firewalld is not running.
ansible.builtin.assert:
assert:
that:
- result.failed
- "'firewalld probably not be running,' in result.msg"
- name: Ensure firewalld_info with active_zones
ansible.posix.firewalld_info:
active_zones: true
firewalld_info:
active_zones: yes
register: result
ignore_errors: true
ignore_errors: yes
- name: Assert firewalld_info with active_zones fails if firewalld is not running.
ansible.builtin.assert:
assert:
that:
- result.failed
- "'firewalld probably not be running,' in result.msg"
- name: Ensure firewalld_zones with zone list
ansible.posix.firewalld_info:
firewalld_info:
zones:
- public
- invalid_zone
register: result
ignore_errors: true
ignore_errors: yes
- name: Assert firewalld_info with zones list fails if firewalld is not running.
ansible.builtin.assert:
assert:
that:
- result.failed
- "'firewalld probably not be running,' in result.msg"

File diff suppressed because it is too large Load diff

View file

@ -1,147 +1,124 @@
---
- name: Ensure idempotency installed
ansible.builtin.package:
- name: ensure idempotency installed
package:
name: patch
when: ansible_distribution != "MacOSX"
- name: Create a directory for the result
ansible.builtin.file:
dest: "{{ output_dir }}/patch"
- name: create a directory for the result
file:
dest: '{{ output_dir }}/patch'
state: directory
mode: "0755"
register: result
- name: Assert the directory was created
ansible.builtin.assert:
- name: assert the directory was created
assert:
that:
- result.state == 'directory'
- name: Copy the origin file
ansible.builtin.copy:
- result.state == 'directory'
- name: copy the origin file
copy:
src: ./origin.txt
dest: "{{ output_dir }}/patch/workfile.txt"
mode: "0644"
dest: '{{ output_dir }}/patch/workfile.txt'
register: result
- name: Patch the origin file in check mode
- name: patch the origin file in check mode
check_mode: true
register: result
ansible.posix.patch:
patch:
src: result.patch
dest: "{{ output_dir }}/patch/workfile.txt"
- name: Verify patch the origin file in check mode
ansible.builtin.assert:
dest: '{{ output_dir }}/patch/workfile.txt'
- name: verify patch the origin file in check mode
assert:
that:
- result is changed
- name: Patch the origin file
- result is changed
- name: patch the origin file
register: result
ansible.posix.patch:
patch:
src: result.patch
dest: "{{ output_dir }}/patch/workfile.txt"
- name: Verify patch the origin file
ansible.builtin.assert:
dest: '{{ output_dir }}/patch/workfile.txt'
- name: verify patch the origin file
assert:
that:
- result is changed
- name: Test patch the origin file idempotency
- result is changed
- name: test patch the origin file idempotency
register: result
ansible.posix.patch:
patch:
src: result.patch
dest: "{{ output_dir }}/patch/workfile.txt"
- name: Verify test patch the origin file idempotency
ansible.builtin.assert:
dest: '{{ output_dir }}/patch/workfile.txt'
- name: verify test patch the origin file idempotency
assert:
that:
- result is not changed
- name: Verify the resulted file matches expectations
ansible.builtin.copy:
- result is not changed
- name: verify the resulted file matches expectations
copy:
src: ./result.txt
dest: "{{ output_dir }}/patch/workfile.txt"
mode: "0644"
dest: '{{ output_dir }}/patch/workfile.txt'
register: result
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
register: result
ansible.posix.patch:
patch:
src: result.patch
dest: "{{ output_dir }}/patch/workfile.txt"
dest: '{{ output_dir }}/patch/workfile.txt'
state: absent
- name: Verify patch the workfile file in check mode state absent
ansible.builtin.assert:
- name: verify patch the workfile file in check mode state absent
assert:
that:
- result is changed
- name: Patch the workfile file state absent
- result is changed
- name: patch the workfile file state absent
register: result
ansible.posix.patch:
patch:
src: result.patch
dest: "{{ output_dir }}/patch/workfile.txt"
dest: '{{ output_dir }}/patch/workfile.txt'
state: absent
- name: Verify patch the workfile file state absent
ansible.builtin.assert:
- name: verify patch the workfile file state absent
assert:
that:
- result is changed
- name: Patch the workfile file state absent idempotency
- result is changed
- name: patch the workfile file state absent idempotency
register: result
ansible.posix.patch:
patch:
src: result.patch
dest: "{{ output_dir }}/patch/workfile.txt"
dest: '{{ output_dir }}/patch/workfile.txt'
state: absent
- name: Verify patch the workfile file state absent idempotency
ansible.builtin.assert:
- name: verify patch the workfile file state absent idempotency
assert:
that:
- result is not changed
- name: Verify the resulted file matches expectations
ansible.builtin.copy:
- result is not changed
- name: verify the resulted file matches expectations
copy:
src: ./origin.txt
dest: "{{ output_dir }}/patch/workfile.txt"
mode: "0644"
dest: '{{ output_dir }}/patch/workfile.txt'
register: result
failed_when: result is changed
- name: Copy the origin file whitespace
ansible.builtin.copy:
- name: copy the origin file whitespace
copy:
src: ./origin.txt
dest: "{{ output_dir }}/patch/workfile_whitespace.txt"
mode: "0644"
dest: '{{ output_dir }}/patch/workfile_whitespace.txt'
register: result
- name: Patch the origin file
- name: patch the origin file
register: result
ansible.posix.patch:
patch:
src: result_whitespace.patch
dest: "{{ output_dir }}/patch/workfile_whitespace.txt"
ignore_whitespace: true
- name: Verify patch the origin file
ansible.builtin.assert:
dest: '{{ output_dir }}/patch/workfile_whitespace.txt'
ignore_whitespace: yes
- name: verify patch the origin file
assert:
that:
- result is changed
- result is changed
- name: Test patch the origin file idempotency
- name: test patch the origin file idempotency
register: result
ansible.posix.patch:
patch:
src: result_whitespace.patch
dest: "{{ output_dir }}/patch/workfile_whitespace.txt"
ignore_whitespace: true
- name: Verify test patch the origin file idempotency
ansible.builtin.assert:
dest: '{{ output_dir }}/patch/workfile_whitespace.txt'
ignore_whitespace: yes
- name: verify test patch the origin file idempotency
assert:
that:
- result is not changed
- result is not changed
- name: Verify the resulted file matches expectations
ansible.builtin.copy:
- name: verify the resulted file matches expectations
copy:
src: ./result_whitespace.txt
dest: "{{ output_dir }}/patch/workfile_whitespace.txt"
mode: "0644"
dest: '{{ output_dir }}/patch/workfile_whitespace.txt'
register: result
failed_when: result is changed

View file

@ -1,4 +1,3 @@
---
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
# This file is part of Ansible
@ -16,9 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Include_tasks for when SELinux is enabled
ansible.builtin.include_tasks: seboolean.yml
- include_tasks: seboolean.yml
when:
- ansible_selinux is defined
- ansible_selinux
- ansible_selinux != False
- ansible_selinux.status == 'enabled'

View file

@ -1,4 +1,3 @@
---
# (c) 2017, Martin Krizek <mkrizek@redhat.com>
# This file is part of Ansible
@ -16,89 +15,69 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Install requirements for RHEL 7 and earlier
ansible.builtin.package:
- name: install requirements for RHEL 7 and earlier
package:
name: policycoreutils-python
when:
- ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('7', '<=')
- name: Install requirements for RHEL 8 and later
ansible.builtin.package:
- name: install requirements for RHEL 8 and later
package:
name: policycoreutils-python-utils
when:
- 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
ansible.builtin.shell:
cmd: set -o pipefail && setsebool -P httpd_can_network_connect 0
executable: /bin/bash
changed_when: getsebool_output_preflight.stdout.startswith('httpd_can_network_connect --> on')
- name: Set flag and don't keep it persistent
ansible.posix.seboolean:
shell: setsebool -P httpd_can_network_connect 0
##########################################################################################
- name: set flag and don't keep it persistent
seboolean:
name: httpd_can_network_connect
state: true
state: yes
register: output
- name: Get getsebool output
ansible.builtin.shell:
cmd: set -o pipefail && semanage boolean -l | grep 'httpd_can_network_connect\W'
executable: /bin/bash
changed_when: false
- name: get getsebool output
shell: semanage boolean -l | grep 'httpd_can_network_connect\W'
register: getsebool_output
- name: Check output
ansible.builtin.assert:
- name: check output
assert:
that:
- output is changed
- output is not failed
- output.name == 'httpd_can_network_connect'
- getsebool_output.stdout.startswith('httpd_can_network_connect (on , off)')
##########################################################################################
- name: Unset flag
ansible.posix.seboolean:
- name: unset flag
seboolean:
name: httpd_can_network_connect
state: false
state: no
- name: Get getsebool output
ansible.builtin.shell:
cmd: set -o pipefail && semanage boolean -l | grep 'httpd_can_network_connect\W'
executable: /bin/bash
changed_when: false
- name: get getsebool output
shell: semanage boolean -l | grep 'httpd_can_network_connect\W'
register: getsebool_output
- name: Check output
ansible.builtin.assert:
- name: check output
assert:
that:
- output is changed
- output is not failed
- output.name == 'httpd_can_network_connect'
- getsebool_output.stdout.startswith('httpd_can_network_connect (off , off)')
##########################################################################################
- name: Set flag and keep it persistent
ansible.posix.seboolean:
- name: set flag and keep it persistent
seboolean:
name: httpd_can_network_connect
state: true
persistent: true
state: yes
persistent: yes
register: output
- name: Get getsebool output
ansible.builtin.shell:
cmd: set -o pipefail && semanage boolean -l | grep 'httpd_can_network_connect\W'
executable: /bin/bash
changed_when: false
- name: get getsebool output
shell: semanage boolean -l | grep 'httpd_can_network_connect\W'
register: getsebool_output
- name: Check output
ansible.builtin.assert:
- name: check output
assert:
that:
- output is changed
- output is not failed

View file

@ -1,4 +1,3 @@
---
# (c) 2017, Sam Doran <sdoran@redhat.com>
# This file is part of Ansible
@ -16,26 +15,22 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Debug message for when SELinux is disabled
ansible.builtin.debug:
- debug:
msg: SELinux is disabled
when: ansible_selinux is defined and not ansible_selinux
when: ansible_selinux is defined and ansible_selinux == False
- name: Debug message for when SELinux is enabled and not disabled
ansible.builtin.debug:
- debug:
msg: SELinux is {{ ansible_selinux.status }}
when: ansible_selinux is defined and ansible_selinux
when: ansible_selinux is defined and ansible_selinux != False
- name: Include_tasks for when SELinux is enabled
ansible.builtin.include_tasks: selinux.yml
- include_tasks: selinux.yml
when:
- ansible_selinux is defined
- ansible_selinux
- ansible_selinux != False
- ansible_selinux.status == 'enabled'
- name: Include tasks for selogin when SELinux is enabled
ansible.builtin.include_tasks: selogin.yml
- include_tasks: selogin.yml
when:
- ansible_selinux is defined
- ansible_selinux
- ansible_selinux != False
- ansible_selinux.status == 'enabled'

View file

@ -1,4 +1,3 @@
---
# (c) 2017, Sam Doran <sdoran@redhat.com>
# This file is part of Ansible
@ -15,67 +14,67 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# First Test
# ##############################################################################
# Test changing the state, which requires a reboot
- name: TEST 1 | Make sure grubby is present
ansible.builtin.package:
package:
name: grubby
state: present
- name: TEST 1 | Get current SELinux config file contents
ansible.builtin.slurp:
slurp:
src: /etc/sysconfig/selinux
register: selinux_config_original_base64
- name: TEST 1 | Register SELinux config and SELinux status
ansible.builtin.set_fact:
set_fact:
selinux_config_original_raw: "{{ selinux_config_original_base64.content | b64decode }}"
before_test_sestatus: "{{ ansible_selinux }}"
- name: TEST 1 | Split by line and register original config
ansible.builtin.set_fact:
set_fact:
selinux_config_original: "{{ selinux_config_original_raw.split('\n') }}"
- name: TEST 1 | Debug selinux_config_original, before_test_sestatus, and ansible_selinux
ansible.builtin.debug:
- debug:
var: "{{ item }}"
verbosity: 1
loop:
with_items:
- selinux_config_original
- before_test_sestatus
- ansible_selinux
- name: TEST 1 | Setup SELinux configuration for tests
ansible.posix.selinux:
selinux:
state: enforcing
policy: targeted
- name: TEST 1 | Disable SELinux
ansible.posix.selinux:
selinux:
state: disabled
policy: targeted
register: _disable_test1
- name: TEST 1 | Debug _disable_test1
ansible.builtin.debug:
- debug:
var: _disable_test1
verbosity: 1
- name: Before gathering the fact
ansible.builtin.debug:
debug:
msg: "{{ ansible_selinux }}"
- name: TEST 1 | Re-gather facts
ansible.builtin.setup:
setup:
- name: After gathering the fact
ansible.builtin.debug:
debug:
msg: "{{ ansible_selinux }}"
- name: TEST 1 | Assert that status was changed, reboot_required is True, a warning was displayed, and SELinux is configured properly
ansible.builtin.assert:
assert:
that:
- _disable_test1 is changed
- _disable_test1.reboot_required
@ -83,56 +82,53 @@
- ansible_selinux.config_mode == 'disabled'
- ansible_selinux.type == 'targeted'
- name: TEST 1 | Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
verbosity: 1
- name: TEST 1 | Disable SELinux again
ansible.posix.selinux:
selinux:
state: disabled
policy: targeted
register: _disable_test2
- name: Test 1 | Debug _disable_test2
ansible.builtin.debug:
- debug:
var: _disable_test2
verbosity: 1
- name: TEST 1 | Assert that no change is reported, a warning was displayed, and reboot_required is True
ansible.builtin.assert:
assert:
that:
- _disable_test2 is not changed
- (_disable_test1.warnings | length ) >= 1
- _disable_test2.reboot_required
- name: TEST 1 | Get modified config file
ansible.builtin.slurp:
slurp:
src: /etc/sysconfig/selinux
register: selinux_config_after_base64
- name: TEST 1 | Register modified config
ansible.builtin.set_fact:
set_fact:
selinux_config_after_raw: "{{ selinux_config_after_base64.content | b64decode }}"
- name: TEST 1 | Split by line and register modified config
ansible.builtin.set_fact:
set_fact:
selinux_config_after: "{{ selinux_config_after_raw.split('\n') }}"
- name: TEST 1 | Debug selinux_config_after
ansible.builtin.debug:
- debug:
var: selinux_config_after
verbosity: 1
- name: TEST 1 | Ensure SELinux config file is properly formatted
ansible.builtin.assert:
assert:
that:
- 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('SELINUXTYPE=targeted')] is search("^SELINUXTYPE=\w+$")
- name: TEST 1 | Disable SELinux again, with kernel arguments update
ansible.posix.selinux:
selinux:
state: disabled
policy: targeted
update_kernel_param: true
@ -140,76 +136,72 @@
- name: Check kernel command-line arguments
ansible.builtin.command: grubby --info=DEFAULT
changed_when: false
register: _grubby_test1
- name: TEST 1 | Assert that kernel cmdline contains selinux=0
ansible.builtin.assert:
assert:
that:
- "' selinux=0' in _grubby_test1.stdout"
- name: TEST 1 | Enable SELinux, without kernel arguments update
ansible.posix.selinux:
selinux:
state: disabled
policy: targeted
register: _disable_test2
- name: Check kernel command-line arguments
ansible.builtin.command: grubby --info=DEFAULT
changed_when: false
register: _grubby_test1
- name: TEST 1 | Assert that kernel cmdline still contains selinux=0
ansible.builtin.assert:
assert:
that:
- "' selinux=0' in _grubby_test1.stdout"
- name: TEST 1 | Reset SELinux configuration for next test (also kernel args)
ansible.posix.selinux:
selinux:
state: enforcing
update_kernel_param: true
policy: targeted
- name: Check kernel command-line arguments
ansible.builtin.command: grubby --info=DEFAULT
changed_when: false
register: _grubby_test2
- name: TEST 1 | Assert that kernel cmdline doesn't contain selinux=0
ansible.builtin.assert:
assert:
that:
- "' selinux=0' not in _grubby_test2.stdout"
# Second Test
# ##############################################################################
# Test changing only the policy, which does not require a reboot
- name: TEST 2 | Make sure the policy is present
ansible.builtin.package:
package:
name: selinux-policy-mls
state: present
- name: TEST 2 | Set SELinux policy
ansible.posix.selinux:
selinux:
state: enforcing
policy: mls
register: _state_test1
- name: TEST 2 | Debug _state_test1
ansible.builtin.debug:
- debug:
var: _state_test1
verbosity: 1
- name: TEST 2 | Re-gather facts
ansible.builtin.setup:
setup:
- name: TEST 2 | Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
tags: debug
- name: TEST 2 | Assert that status was changed, reboot_required is False, no warnings were displayed, and SELinux is configured properly
ansible.builtin.assert:
assert:
that:
- _state_test1 is changed
- not _state_test1.reboot_required
@ -218,79 +210,76 @@
- ansible_selinux.type == 'mls'
- name: TEST 2 | Set SELinux policy again
ansible.posix.selinux:
selinux:
state: enforcing
policy: mls
register: _state_test2
- name: TEST 2 | Debug _state_test2
ansible.builtin.debug:
- debug:
var: _state_test2
verbosity: 1
- name: TEST 2 | Assert that no change was reported, no warnings were displayed, and reboot_required is False
ansible.builtin.assert:
assert:
that:
- _state_test2 is not changed
- _state_test2.warnings is not defined
- not _state_test2.reboot_required
- name: TEST 2 | Get modified config file
ansible.builtin.slurp:
slurp:
src: /etc/sysconfig/selinux
register: selinux_config_after_base64
- name: TEST 2 | Register modified config
ansible.builtin.set_fact:
set_fact:
selinux_config_after_raw: "{{ selinux_config_after_base64.content | b64decode }}"
- name: TEST 2 | Split by line and register modified config
ansible.builtin.set_fact:
set_fact:
selinux_config_after: "{{ selinux_config_after_raw.split('\n') }}"
- name: TEST 2 | Debug selinux_config_after
ansible.builtin.debug:
- debug:
var: selinux_config_after
verbosity: 1
- name: TEST 2 | Ensure SELinux config file is properly formatted
ansible.builtin.assert:
assert:
that:
- 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('SELINUXTYPE=mls')] is search("^SELINUXTYPE=\w+$")
- name: TEST 2 | Reset SELinux configuration for next test
ansible.posix.selinux:
selinux:
state: enforcing
policy: targeted
# Third Test
# ##############################################################################
# Test changing non-existing policy
- name: TEST 3 | Set SELinux policy
ansible.posix.selinux:
selinux:
state: enforcing
policy: non-existing-selinux-policy
register: _state_test1
ignore_errors: true
ignore_errors: yes
- name: TEST 3 | Debug _state_test1
ansible.builtin.debug:
- debug:
var: _state_test1
verbosity: 1
- name: TEST 3 | Re-gather facts
ansible.builtin.setup:
setup:
- name: TEST3 | Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
tags: debug
- name: TEST 3 | Assert that status was not changed, the task failed, the msg contains proper information and SELinux was not changed
ansible.builtin.assert:
assert:
that:
- _state_test1 is not changed
- _state_test1 is failed
@ -298,40 +287,40 @@
- ansible_selinux.config_mode == 'enforcing'
- ansible_selinux.type == 'targeted'
# Fourth Test
# ##############################################################################
# Test if check mode returns correct changed values and
# doesn't make any changes
- name: TEST 4 | Set SELinux to enforcing
ansible.posix.selinux:
selinux:
state: enforcing
policy: targeted
register: _check_mode_test1
- name: TEST 4 | Debug _check_mode_test1
ansible.builtin.debug:
- debug:
var: _check_mode_test1
verbosity: 1
- name: TEST 4 | Set SELinux to enforcing in check mode
ansible.posix.selinux:
selinux:
state: enforcing
policy: targeted
register: _check_mode_test1
check_mode: true
check_mode: yes
- name: TEST 4 | Re-gather facts
ansible.builtin.setup:
setup:
- name: TEST 4| Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
verbosity: 1
tags: debug
- name: TEST 4 | Assert that check mode is idempotent
ansible.builtin.assert:
assert:
that:
- _check_mode_test1 is success
- not _check_mode_test1.reboot_required
@ -339,23 +328,22 @@
- ansible_selinux.type == 'targeted'
- name: TEST 4 | Set SELinux to permissive in check mode
ansible.posix.selinux:
selinux:
state: permissive
policy: targeted
register: _check_mode_test2
check_mode: true
check_mode: yes
- name: TEST 4 | Re-gather facts
ansible.builtin.setup:
setup:
- name: TEST 4 | Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
verbosity: 1
tags: debug
- name: TEST 4 | Assert that check mode doesn't set state permissive and returns changed
ansible.builtin.assert:
assert:
that:
- _check_mode_test2 is changed
- not _check_mode_test2.reboot_required
@ -363,22 +351,21 @@
- ansible_selinux.type == 'targeted'
- name: TEST 4 | Disable SELinux in check mode
ansible.posix.selinux:
selinux:
state: disabled
register: _check_mode_test3
check_mode: true
check_mode: yes
- name: TEST 4 | Re-gather facts
ansible.builtin.setup:
setup:
- name: TEST 4 | Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
verbosity: 1
tags: debug
- name: TEST 4 | Assert that check mode didn't change anything, status is changed, reboot_required is True, a warning was displayed
ansible.builtin.assert:
assert:
that:
- _check_mode_test3 is changed
- _check_mode_test3.reboot_required
@ -387,33 +374,31 @@
- ansible_selinux.type == 'targeted'
- name: TEST 4 | Set SELinux to permissive
ansible.posix.selinux:
selinux:
state: permissive
policy: targeted
register: _check_mode_test4
- name: TEST 4 | Debug _check_mode_test4
ansible.builtin.debug:
- debug:
var: _check_mode_test4
verbosity: 1
- name: TEST 4 | Disable SELinux in check mode
ansible.posix.selinux:
selinux:
state: disabled
register: _check_mode_test4
check_mode: true
check_mode: yes
- name: TEST 4 | Re-gather facts
ansible.builtin.setup:
setup:
- name: TEST 4 | Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
verbosity: 1
tags: debug
- name: TEST 4 | Assert that check mode didn't change anything, status is changed, reboot_required is True, a warning was displayed
ansible.builtin.assert:
assert:
that:
- _check_mode_test4 is changed
- _check_mode_test4.reboot_required
@ -422,38 +407,36 @@
- ansible_selinux.type == 'targeted'
- name: TEST 4 | Set SELinux to enforcing
ansible.posix.selinux:
selinux:
state: enforcing
policy: targeted
register: _check_mode_test5
- name: TEST 4 | Debug _check_mode_test5
ansible.builtin.debug:
- debug:
var: _check_mode_test5
verbosity: 1
- name: TEST 4 | Disable SELinux
ansible.posix.selinux:
selinux:
state: disabled
register: _check_mode_test5
- name: TEST 4 | Disable SELinux in check mode
ansible.posix.selinux:
selinux:
state: disabled
register: _check_mode_test5
check_mode: true
check_mode: yes
- name: TEST 4 | Re-gather facts
ansible.builtin.setup:
setup:
- name: TEST 4 | Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
verbosity: 1
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
ansible.builtin.assert:
assert:
that:
- _check_mode_test5 is success
- _check_mode_test5.reboot_required
@ -467,34 +450,32 @@
# sure the module re-adds the expected lines
- name: TEST 5 | Remove SELINUX key from /etc/selinux/config
ansible.builtin.lineinfile:
lineinfile:
path: /etc/selinux/config
regexp: ^SELINUX=
regexp: '^SELINUX='
state: absent
backup: true
backup: yes
register: _lineinfile_out1
- name: TEST 5 | Debug _lineinfile_out1
ansible.builtin.debug:
- debug:
var: _lineinfile_out1
verbosity: 1
- name: TEST 5 | Set SELinux to enforcing
ansible.posix.selinux:
selinux:
state: enforcing
policy: targeted
register: _set_enforcing1
- name: TEST 5 | Re-gather facts
ansible.builtin.setup:
setup:
- name: TEST 5 | Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
verbosity: 1
- name: TEST 5 | Assert that SELINUX key is populated
ansible.builtin.assert:
assert:
that:
- _set_enforcing1 is success
- _set_enforcing1 is changed
@ -502,33 +483,31 @@
- ansible_selinux.config_mode == 'enforcing'
- name: TEST 5 | Remove SELINUXTYPE key from /etc/selinux/config
ansible.builtin.lineinfile:
lineinfile:
path: /etc/selinux/config
regexp: ^SELINUXTYPE=
regexp: '^SELINUXTYPE='
state: absent
register: _lineinfile_out2
- name: TEST 5 | Debug _lineinfile_out2
ansible.builtin.debug:
- debug:
var: _lineinfile_out2
verbosity: 1
- name: TEST 5 | Set SELinux Policy to targeted
ansible.posix.selinux:
selinux:
state: enforcing
policy: targeted
register: _set_policy2
- name: TEST 5 | Re-gather facts
ansible.builtin.setup:
setup:
- name: TEST 5 | Debug ansible_selinux
ansible.builtin.debug:
- debug:
var: ansible_selinux
verbosity: 1
- name: TEST 5 | Assert that SELINUXTYPE key is populated
ansible.builtin.assert:
assert:
that:
- _set_policy2 is success
- _set_policy2 is changed
@ -536,8 +515,7 @@
- ansible_selinux.type == 'targeted'
- name: TEST 5 | Restore original SELinux config file /etc/selinux/config
ansible.builtin.copy:
copy:
dest: /etc/selinux/config
src: "{{ _lineinfile_out1['backup'] }}"
remote_src: true
mode: "0644"
remote_src: yes

View file

@ -1,71 +1,70 @@
---
- name: Create user for testing
ansible.builtin.user:
- name: create user for testing
user:
name: seuser
- name: Attempt to add mapping without 'seuser'
- name: attempt to add mapping without 'seuser'
register: selogin_error
ignore_errors: true
community.general.system.selogin:
login: seuser
- name: Verify failure
ansible.builtin.assert:
- name: verify failure
assert:
that:
- selogin_error is failed
- name: Map login to SELinux user
- selogin_error is failed
- name: map login to SELinux user
register: selogin_new_mapping
check_mode: "{{ item }}"
check_mode: '{{ item }}'
with_items:
- true
- false
- true
- false
- true
- false
- true
- false
community.general.system.selogin:
login: seuser
seuser: staff_u
- name: New mapping- verify functionality and check_mode
ansible.builtin.assert:
- name: new mapping- verify functionality and check_mode
assert:
that:
- selogin_new_mapping.results[0] is changed
- selogin_new_mapping.results[1] is changed
- selogin_new_mapping.results[2] is not changed
- selogin_new_mapping.results[3] is not changed
- name: Change SELinux user login mapping
- selogin_new_mapping.results[0] is changed
- selogin_new_mapping.results[1] is changed
- selogin_new_mapping.results[2] is not changed
- selogin_new_mapping.results[3] is not changed
- name: change SELinux user login mapping
register: selogin_mod_mapping
check_mode: "{{ item }}"
check_mode: '{{ item }}'
with_items:
- true
- false
- true
- false
- true
- false
- true
- false
community.general.system.selogin:
login: seuser
seuser: user_u
- name: Changed mapping- verify functionality and check_mode
ansible.builtin.assert:
- name: changed mapping- verify functionality and check_mode
assert:
that:
- selogin_mod_mapping.results[0] is changed
- selogin_mod_mapping.results[1] is changed
- selogin_mod_mapping.results[2] is not changed
- selogin_mod_mapping.results[3] is not changed
- name: Remove SELinux user mapping
- selogin_mod_mapping.results[0] is changed
- selogin_mod_mapping.results[1] is changed
- selogin_mod_mapping.results[2] is not changed
- selogin_mod_mapping.results[3] is not changed
- name: remove SELinux user mapping
register: selogin_del_mapping
check_mode: "{{ item }}"
check_mode: '{{ item }}'
with_items:
- true
- false
- true
- false
- true
- false
- true
- false
community.general.system.selogin:
login: seuser
state: absent
- name: Delete mapping- verify functionality and check_mode
ansible.builtin.assert:
- name: delete mapping- verify functionality and check_mode
assert:
that:
- selogin_del_mapping.results[0] is changed
- selogin_del_mapping.results[1] is changed
- selogin_del_mapping.results[2] is not changed
- selogin_del_mapping.results[3] is not changed
- name: Remove test user
ansible.builtin.user:
- selogin_del_mapping.results[0] is changed
- selogin_del_mapping.results[1] is changed
- selogin_del_mapping.results[2] is not changed
- selogin_del_mapping.results[3] is not changed
- name: remove test user
user:
name: seuser
state: absent

View file

@ -4,16 +4,14 @@
# and should not be used as examples of how to write Ansible roles #
####################################################################
- name: Set pkg_mgr and ansible_pkg_mgr on FreeBSD
ansible.builtin.set_fact:
- set_fact:
pkg_mgr: community.general.pkgng
ansible_pkg_mgr: community.general.pkgng
cacheable: true
cacheable: yes
when: ansible_os_family == "FreeBSD"
- name: Set pkg_mgr and ansible_pkg_mgr on Suse
ansible.builtin.set_fact:
- set_fact:
pkg_mgr: community.general.zypper
ansible_pkg_mgr: community.general.zypper
cacheable: true
cacheable: yes
when: ansible_os_family == "Suse"

View file

@ -1,3 +1,2 @@
---
dependencies:
- prepare_tests

View file

@ -1,350 +1,310 @@
---
- name: Install rsync
ansible.builtin.package:
- name: install rsync
package:
name: rsync
when: ansible_distribution != "MacOSX"
- name: Clean up the working disrectory and files
ansible.builtin.file:
path: "{{ output_dir }}"
- name: Clean up the working directory and files
file:
path: '{{ output_dir }}'
state: absent
- name: Create the working directory
ansible.builtin.file:
path: "{{ output_dir }}"
file:
path: '{{ output_dir }}'
state: directory
mode: "0755"
- name: create test new files
copy:
dest: '{{output_dir}}/{{item}}'
mode: '0644'
content: 'hello world'
with_items:
- foo.txt
- bar.txt
- name: Create test new files
ansible.builtin.copy:
dest: "{{ output_dir }}/{{ item }}"
mode: "0644"
content: hello world
loop:
- foo.txt
- bar.txt
- name: Synchronize file to new filename
ansible.posix.synchronize:
src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/foo.result"
- name: synchronize file to new filename
synchronize:
src: '{{output_dir}}/foo.txt'
dest: '{{output_dir}}/foo.result'
register: sync_result
delegate_to: "{{ inventory_hostname }}"
- name: Check that the file was copied over correctly
ansible.builtin.assert:
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\n')"
- '''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: Test that the file was really copied over
ansible.builtin.stat:
path: "{{ output_dir }}/foo.result"
'')'
- name: test that the file was really copied over
stat:
path: '{{ output_dir }}/foo.result'
register: stat_result
- name: Test that the file was really copied over
ansible.builtin.assert:
- assert:
that:
- stat_result.stat.exists == True
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
- stat_result.stat.exists == True
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
- name: Test that the file is not copied a second time
ansible.posix.synchronize:
src: "'{{ output_dir }}/foo.txt'"
dest: "'{{ output_dir }}/foo.result'"
- name: test that the file is not copied a second time
synchronize:
src='{{output_dir}}/foo.txt'
dest='{{output_dir}}/foo.result'
register: sync_result
delegate_to: "{{ inventory_hostname }}"
- name: Test that no change occurred
ansible.builtin.assert:
delegate_to: '{{ inventory_hostname }}'
- assert:
that:
- not sync_result.changed
- sync_result.changed == False
- name: Cleanup
ansible.builtin.file:
file:
state: absent
path: "{{ output_dir }}/{{ item }}"
loop:
- foo.result
- bar.result
path: '{{output_dir}}/{{item}}'
with_items:
- foo.result
- bar.result
- name: Synchronize using the mode=push param
ansible.posix.synchronize:
src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/foo.result"
synchronize:
src: '{{output_dir}}/foo.txt'
dest: '{{output_dir}}/foo.result'
mode: push
register: sync_result
delegate_to: "{{ inventory_hostname }}"
- name: Check that the file was copied over correctly mode=push
ansible.builtin.assert:
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\n')"
- '''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: Test that the file was really copied over
ansible.builtin.stat:
path: "{{ output_dir }}/foo.result"
'')'
- name: test that the file was really copied over
stat:
path: '{{ output_dir }}/foo.result'
register: stat_result
- name: Ensure file exists and checksum matches
ansible.builtin.assert:
- assert:
that:
- stat_result.stat.exists == True
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
- stat_result.stat.exists == True
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
- name: Test that the file is not copied a second time
ansible.posix.synchronize:
src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/foo.result"
- name: test that the file is not copied a second time
synchronize:
src: '{{output_dir}}/foo.txt'
dest: '{{output_dir}}/foo.result'
mode: push
register: sync_result
delegate_to: "{{ inventory_hostname }}"
- name: Ensure no change occorred
ansible.builtin.assert:
delegate_to: '{{ inventory_hostname }}'
- assert:
that:
- sync_result.changed == False
- sync_result.changed == False
- name: Cleanup
ansible.builtin.file:
file:
state: absent
path: "{{ output_dir }}/{{ item }}"
loop:
- foo.result
- bar.result
path: '{{output_dir}}/{{item}}'
with_items:
- foo.result
- bar.result
- name: Synchronize using the mode=pull param
ansible.posix.synchronize:
src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/foo.result"
synchronize:
src: '{{output_dir}}/foo.txt'
dest: '{{output_dir}}/foo.result'
mode: pull
register: sync_result
delegate_to: "{{ inventory_hostname }}"
- name: Check that the file was copied over correctly mode=pull
ansible.builtin.assert:
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\n')"
- '''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: Test that the file was really copied over
ansible.builtin.stat:
path: "{{ output_dir }}/foo.result"
'')'
- name: test that the file was really copied over
stat:
path: '{{ output_dir }}/foo.result'
register: stat_result
- name: Ensure file exists and checksum matches
ansible.builtin.assert:
- assert:
that:
- stat_result.stat.exists == True
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
- stat_result.stat.exists == True
- stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
- name: Test that the file is not copied a second time
ansible.posix.synchronize:
src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/foo.result"
- name: test that the file is not copied a second time
synchronize:
src: '{{output_dir}}/foo.txt'
dest: '{{output_dir}}/foo.result'
mode: pull
register: sync_result
delegate_to: "{{ inventory_hostname }}"
- name: Ensure no change occorred
ansible.builtin.assert:
delegate_to: '{{ inventory_hostname }}'
- assert:
that:
- sync_result.changed == False
- sync_result.changed == False
- name: Cleanup
ansible.builtin.file:
file:
state: absent
path: "{{ output_dir }}/{{ item }}"
loop:
- foo.result
- bar.result
path: '{{output_dir}}/{{item}}'
with_items:
- foo.result
- bar.result
- name: Synchronize files using with_items (issue#5965)
ansible.posix.synchronize:
src: "{{ output_dir }}/{{ item }}"
dest: "{{ output_dir }}/{{ item }}.result"
- name: synchronize files using with_items (issue#5965)
synchronize:
src: '{{output_dir}}/{{item}}'
dest: '{{output_dir}}/{{item}}.result'
with_items:
- foo.txt
- bar.txt
register: sync_result
delegate_to: '{{ inventory_hostname }}'
- assert:
that:
- sync_result.changed
- sync_result.msg == 'All items completed'
- '''results'' in sync_result'
- sync_result.results|length == 2
- 'sync_result.results[0].msg.endswith(''+ foo.txt
'')'
- 'sync_result.results[1].msg.endswith(''+ bar.txt
'')'
- name: Cleanup
file:
state: absent
path: '{{output_dir}}/{{item}}.result'
with_items:
- foo.txt
- bar.txt
- name: synchronize files using rsync_path (issue#7182)
synchronize:
src: '{{output_dir}}/foo.txt'
dest: '{{output_dir}}/foo.rsync_path'
rsync_path: 'sudo rsync'
register: sync_result
delegate_to: '{{ inventory_hostname }}'
- assert:
that:
- '''changed'' in sync_result'
- sync_result.changed == true
- '''cmd'' in sync_result'
- '''rsync'' in sync_result.cmd'
- '''rsync_path'' in sync_result.cmd'
- '''msg'' in sync_result'
- sync_result.msg.startswith('>f+')
- 'sync_result.msg.endswith(''+ foo.txt
'')'
- name: Cleanup
file:
state: absent
path: '{{output_dir}}/{{item}}'
with_items:
- foo.rsync_path
- name: add subdirectories for link-dest test
file:
path: '{{output_dir}}/{{item}}/'
state: directory
mode: '0755'
with_items:
- directory_a
- directory_b
- name: copy foo.txt into the first directory
synchronize:
src: '{{output_dir}}/foo.txt'
dest: '{{output_dir}}/{{item}}/foo.txt'
with_items:
- directory_a
delegate_to: '{{ inventory_hostname }}'
- name: synchronize files using link_dest
synchronize:
src: '{{output_dir}}/directory_a/foo.txt'
dest: '{{output_dir}}/directory_b/foo.txt'
link_dest:
- '{{output_dir}}/directory_a'
register: sync_result
delegate_to: '{{ inventory_hostname }}'
- name: get stat information for directory_a
stat:
path: '{{ output_dir }}/directory_a/foo.txt'
register: stat_result_a
- name: get stat information for directory_b
stat:
path: '{{ output_dir }}/directory_b/foo.txt'
register: stat_result_b
- assert:
that:
- '''changed'' in sync_result'
- sync_result.changed == true
- stat_result_a.stat.inode == stat_result_b.stat.inode
- name: synchronize files using link_dest that would be recursive
synchronize:
src: '{{output_dir}}/foo.txt'
dest: '{{output_dir}}/foo.result'
link_dest:
- '{{output_dir}}'
register: sync_result
ignore_errors: true
delegate_to: '{{ inventory_hostname }}'
- assert:
that:
- sync_result is not changed
- sync_result is failed
- name: Cleanup
file:
state: absent
path: '{{output_dir}}/{{item}}'
with_items:
- directory_b/foo.txt
- directory_a/foo.txt
- directory_a
- directory_b
- name: setup - test for source with working dir with spaces in path
file:
state: directory
path: '{{output_dir}}/{{item}}'
delegate_to: '{{ inventory_hostname }}'
with_items:
- 'directory a'
- 'directory b'
- name: setup - create test new files
copy:
dest: '{{output_dir}}/directory a/{{item}}'
mode: '0644'
content: 'hello world'
with_items:
- foo.txt
- bar.txt
register: sync_result
delegate_to: "{{ inventory_hostname }}"
- name: Validate syncrhonize with_items
ansible.builtin.assert:
that:
- sync_result.changed
- sync_result.msg == 'All items completed'
- "'results' in sync_result"
- sync_result.results|length == 2
- "sync_result.results[0].msg.endswith('+ foo.txt\n')"
- "sync_result.results[1].msg.endswith('+ bar.txt\n')"
- name: Cleanup
ansible.builtin.file:
state: absent
path: "{{ output_dir }}/{{ item }}.result"
loop:
- foo.txt
- bar.txt
- name: Synchronize files using rsync_path (issue#7182)
ansible.posix.synchronize:
src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/foo.rsync_path"
rsync_path: sudo rsync
register: sync_result
delegate_to: "{{ inventory_hostname }}"
- name: Validate syncrhonize using rsync_path (issue#7182)
ansible.builtin.assert:
that:
- "'changed' in sync_result"
- sync_result.changed == true
- "'cmd' in sync_result"
- "'rsync' in sync_result.cmd"
- "'rsync_path' in sync_result.cmd"
- "'msg' in sync_result"
- sync_result.msg.startswith('>f+')
- "sync_result.msg.endswith('+ foo.txt\n')"
- name: Cleanup
ansible.builtin.file:
state: absent
path: "{{ output_dir }}/{{ item }}"
loop:
- foo.rsync_path
- name: Add subdirectories for link-dest test
ansible.builtin.file:
path: "{{ output_dir }}/{{ item }}/"
state: directory
mode: "0755"
loop:
- directory_a
- directory_b
- name: Copy foo.txt into the first directory
ansible.posix.synchronize:
src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/{{ item }}/foo.txt"
loop:
- directory_a
delegate_to: "{{ inventory_hostname }}"
- name: Synchronize files using link_dest
ansible.posix.synchronize:
src: "{{ output_dir }}/directory_a/foo.txt"
dest: "{{ output_dir }}/directory_b/foo.txt"
link_dest:
- "{{ output_dir }}/directory_a"
register: sync_result
delegate_to: "{{ inventory_hostname }}"
- name: Get stat information for directory_a
ansible.builtin.stat:
path: "{{ output_dir }}/directory_a/foo.txt"
register: stat_result_a
- name: Get stat information for directory_b
ansible.builtin.stat:
path: "{{ output_dir }}/directory_b/foo.txt"
register: stat_result_b
- name: Ensure file exists and inode matches
ansible.builtin.assert:
that:
- "'changed' in sync_result"
- sync_result.changed == true
- stat_result_a.stat.inode == stat_result_b.stat.inode
- name: Synchronize files using link_dest that would be recursive
ansible.posix.synchronize:
src: "{{ output_dir }}/foo.txt"
dest: "{{ output_dir }}/foo.result"
link_dest:
- "{{ output_dir }}"
delegate_to: '{{ inventory_hostname }}'
- name: copy source with spaces in dir path
synchronize:
src: '{{output_dir}}/directory a/foo.txt'
dest: '{{output_dir}}/directory b/'
delegate_to: '{{ inventory_hostname }}'
register: sync_result
ignore_errors: true
delegate_to: "{{ inventory_hostname }}"
- name: Ensure no change occorred and failed
ansible.builtin.assert:
that:
- sync_result is not changed
- sync_result is failed
- name: Cleanup
ansible.builtin.file:
state: absent
path: "{{ output_dir }}/{{ item }}"
loop:
- directory_b/foo.txt
- directory_a/foo.txt
- directory_a
- directory_b
- name: Setup - test for source with working dir with spaces in path
ansible.builtin.file:
state: directory
path: "{{ output_dir }}/{{ item }}"
mode: "0755"
delegate_to: "{{ inventory_hostname }}"
loop:
- directory a
- directory b
- name: Setup - create test new files
ansible.builtin.copy:
dest: "{{ output_dir }}/directory a/{{ item }}"
mode: "0644"
content: hello world
loop:
- foo.txt
delegate_to: "{{ inventory_hostname }}"
- name: Copy source with spaces in dir path
ansible.posix.synchronize:
src: "{{ output_dir }}/directory a/foo.txt"
dest: "{{ output_dir }}/directory b/"
delegate_to: "{{ inventory_hostname }}"
register: sync_result
ignore_errors: true
- name: Get stat information for directory_b
ansible.builtin.stat:
path: "{{ output_dir }}/directory b/foo.txt"
- name: get stat information for directory_b
stat:
path: '{{ output_dir }}/directory b/foo.txt'
register: stat_result_b
- name: Ensure file exists and checksum matches
ansible.builtin.assert:
- assert:
that:
- "'changed' in sync_result"
- '''changed'' in sync_result'
- sync_result.changed == true
- stat_result_b.stat.exists == True
- stat_result_b.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
- name: Cleanup
ansible.builtin.file:
file:
state: absent
path: "{{ output_dir }}/{{ item }}"
loop:
- directory b/foo.txt
- directory a/foo.txt
- directory a
- directory b
path: '{{output_dir}}/{{item}}'
with_items:
- 'directory b/foo.txt'
- 'directory a/foo.txt'
- 'directory a'
- 'directory b'

View file

@ -1,3 +1,2 @@
---
dependencies:
- prepare_tests

View file

@ -1,4 +1,3 @@
---
# Test code for the sysctl module.
# (c) 2017, James Tanner <tanner.jc@gmail.com>
@ -25,91 +24,79 @@
when:
- ansible_facts.virtualization_type == 'docker' or ansible_facts.virtualization_type == 'container'
block:
- name: Set output_dir_test fact
ansible.builtin.set_fact:
- set_fact:
output_dir_test: "{{ output_dir }}/test_sysctl"
- name: Make sure our testing sub-directory does not exist
ansible.builtin.file:
- name: make sure our testing sub-directory does not exist
file:
path: "{{ output_dir_test }}"
state: absent
- name: Create our testing sub-directory
ansible.builtin.file:
- name: create our testing sub-directory
file:
path: "{{ output_dir_test }}"
state: directory
mode: "0755"
##
## sysctl - file manipulation
##
- name: Copy the example conf to the test dir
ansible.builtin.copy:
- name: copy the example conf to the test dir
copy:
src: sysctl.conf
dest: "{{ output_dir_test }}"
mode: "0644"
- name: Set vm.swappiness to 5
ansible.posix.sysctl:
sysctl:
name: vm.swappiness
value: 5
state: present
reload: false
reload: no
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
register: sysctl_test0
- name: Debug sysctl_test0
ansible.builtin.debug:
- debug:
var: sysctl_test0
verbosity: 1
- name: Get file content
ansible.builtin.shell:
cmd: set -o pipefail && cat {{ output_dir_test }}/sysctl.conf | egrep -v ^\#
executable: /bin/bash
changed_when: false
- name: get file content
shell: "cat {{ output_dir_test }}/sysctl.conf | egrep -v ^\\#"
register: sysctl_content0
- name: Debug sysctl_content0
ansible.builtin.debug:
- debug:
var: sysctl_content0
verbosity: 1
- name: Set vm.swappiness to 5 again
ansible.posix.sysctl:
name: vm.swappiness
value: 5
state: present
reload: false
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
sysctl:
name: vm.swappiness
value: 5
state: present
reload: no
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
register: sysctl_test1
- name: Validate results
ansible.builtin.assert:
that:
- sysctl_test0 is changed
- sysctl_test1 is not changed
- sysctl_content0.stdout_lines[sysctl_content0.stdout_lines.index("vm.swappiness=5")] == "vm.swappiness=5"
- name: validate results
assert:
that:
- sysctl_test0 is changed
- sysctl_test1 is not changed
- 'sysctl_content0.stdout_lines[sysctl_content0.stdout_lines.index("vm.swappiness=5")] == "vm.swappiness=5"'
- name: Remove kernel.panic
ansible.posix.sysctl:
sysctl:
name: kernel.panic
value: 2
reload: false
reload: no
state: absent
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
register: sysctl_test2
- name: Get file content
ansible.builtin.shell:
cmd: set -o pipefail && cat {{ output_dir_test }}/sysctl.conf | egrep -v ^\#
executable: /bin/bash
changed_when: false
- name: get file content
shell: "cat {{ output_dir_test }}/sysctl.conf | egrep -v ^\\#"
register: sysctl_content2
- name: Debug sysctl_test2 sysctl_content2
ansible.builtin.debug:
- debug:
var: item
verbosity: 1
with_items:
@ -117,39 +104,38 @@
- "{{ sysctl_content2 }}"
- name: Validate results for key removal
ansible.builtin.assert:
assert:
that:
- sysctl_test2 is changed
- "'kernel.panic' not in sysctl_content2.stdout_lines"
- name: Test remove kernel.panic again
ansible.posix.sysctl:
sysctl:
name: kernel.panic
value: 2
state: absent
reload: false
reload: no
sysctl_file: "{{ output_dir_test }}/sysctl.conf"
register: sysctl_test2_change_test
- name: Assert that no change was made
ansible.builtin.assert:
assert:
that:
- sysctl_test2_change_test is not changed
- name: Try sysctl with an invalid name
ansible.posix.sysctl:
sysctl:
name: test.invalid
value: 1
register: sysctl_test3
ignore_errors: true
ignore_errors: yes
- name: Debug sysctl_test3
ansible.builtin.debug:
- debug:
var: sysctl_test3
verbosity: 1
- name: Validate results for test 3
ansible.builtin.assert:
- name: validate results for test 3
assert:
that:
- sysctl_test3 is failed
@ -157,79 +143,77 @@
## sysctl - sysctl_set
##
- name: Set net.ipv4.ip_forward
ansible.posix.sysctl:
- name: set net.ipv4.ip_forward
sysctl:
name: net.ipv4.ip_forward
value: 1
sysctl_set: true
reload: false
sysctl_set: yes
reload: no
register: sysctl_test3
- name: Check with sysctl command
ansible.builtin.command: sysctl net.ipv4.ip_forward
changed_when: false
- name: check with sysctl command
shell: sysctl net.ipv4.ip_forward
register: sysctl_check3
- name: Debug sysctl_test3 sysctl_check3
ansible.builtin.debug:
- debug:
var: item
verbosity: 1
with_items:
- "{{ sysctl_test3 }}"
- "{{ sysctl_check3 }}"
- name: Validate results for test 3
ansible.builtin.assert:
- name: validate results for test 3
assert:
that:
- 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
ansible.posix.sysctl:
sysctl:
name: ""
value: 1
sysctl_set: true
ignore_errors: true
sysctl_set: yes
ignore_errors: True
register: sysctl_no_name
- name: Validate nameless results
ansible.builtin.assert:
- name: validate nameless results
assert:
that:
- 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
ansible.posix.sysctl:
sysctl:
name: Foo
value:
sysctl_set: true
ignore_errors: true
sysctl_set: yes
ignore_errors: True
register: sysctl_no_value
- name: Validate nameless results
ansible.builtin.assert:
- name: validate nameless results
assert:
that:
- 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
ansible.posix.sysctl:
sysctl:
name: test.invalid
value: 1
sysctl_set: true
sysctl_set: yes
register: sysctl_test4
ignore_errors: true
ignore_errors: yes
- name: Debug sysctl_test4
ansible.builtin.debug:
- debug:
var: sysctl_test4
verbosity: 1
- name: Validate results for test 4
ansible.builtin.assert:
- name: validate results for test 4
assert:
that:
- sysctl_test4 is failed
- name: Test on RHEL VMs
when:
- ansible_facts.virtualization_type != 'docker'
@ -237,37 +221,34 @@
block:
# Test reload: yes
- name: Set sysctl property using module
ansible.posix.sysctl:
sysctl:
name: vm.swappiness
value: "22"
value: '22'
state: present
reload: true
reload: yes
register: sysctl_set1
- name: Change sysctl property using command
ansible.builtin.command: sysctl vm.swappiness=33
changed_when: true
command: sysctl vm.swappiness=33
- name: Set sysctl property using module
ansible.posix.sysctl:
sysctl:
name: vm.swappiness
value: "22"
value: '22'
state: present
reload: true
reload: yes
register: sysctl_set2
- name: Read /etc/sysctl.conf
ansible.builtin.command: egrep -v ^# /etc/sysctl.conf
changed_when: false
command: 'egrep -v ^# /etc/sysctl.conf'
register: sysctl_conf_content
- name: Get current value of vm.swappiness
ansible.builtin.command: sysctl -n vm.swappiness
changed_when: false
command: sysctl -n vm.swappiness
register: sysctl_current_vm_swappiness
- name: Ensure changes were made appropriately
ansible.builtin.assert:
assert:
that:
- sysctl_set1 is changed
- sysctl_set2 is changed
@ -276,35 +257,33 @@
# Test reload: yes in check mode
- name: Set the same value using module in check mode
ansible.posix.sysctl:
sysctl:
name: vm.swappiness
value: "22"
value: '22'
state: present
reload: true
check_mode: true
reload: yes
check_mode: yes
register: sysctl_check_mode1
- name: Set a different value using module in check mode
ansible.posix.sysctl:
sysctl:
name: vm.swappiness
value: "44"
value: '44'
state: present
reload: true
check_mode: true
reload: yes
check_mode: yes
register: sysctl_check_mode2
- name: Read /etc/sysctl.conf
ansible.builtin.command: egrep -v ^# /etc/sysctl.conf
changed_when: false
command: 'egrep -v ^# /etc/sysctl.conf'
register: sysctl_check_mode_conf_content
- name: Get current value of vm.swappiness
ansible.builtin.command: sysctl -n vm.swappiness
changed_when: false
command: sysctl -n vm.swappiness
register: sysctl_check_mode_current_vm_swappiness
- name: Ensure no changes were made in check mode
ansible.builtin.assert:
assert:
that:
- sysctl_check_mode1 is success
- sysctl_check_mode2 is changed
@ -313,22 +292,21 @@
# Test sysctl: invalid value
- name: Set invalid sysctl property using module
ansible.posix.sysctl:
sysctl:
name: vm.mmap_rnd_bits
value: "1024"
value: '1024'
state: present
reload: true
sysctl_set: true
ignore_errors: true
reload: yes
sysctl_set: True
ignore_errors: True
register: sysctl_invalid_set1
- name: Read /etc/sysctl.conf
ansible.builtin.command: cat /etc/sysctl.conf
changed_when: false
command: 'cat /etc/sysctl.conf'
register: sysctl_invalid_conf_content
- name: Ensure changes were not made
ansible.builtin.assert:
assert:
that:
- sysctl_invalid_set1 is failed
- "'vm.mmap_rnd_bits' not in sysctl_invalid_conf_content.stdout"

View file

@ -1,2 +1,8 @@
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/timing.py shebang

View file

@ -1,2 +1,8 @@
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/timing.py shebang

View file

@ -1 +1,7 @@
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

View file

@ -1 +1,7 @@
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

View file

@ -0,0 +1,8 @@
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

View file

@ -1,18 +1,17 @@
---
fixtures:
taskvars_in: taskvars_in.json
taskvars_out: taskvars_out.json
taskvars_in: taskvars_in.json
taskvars_out: taskvars_out.json
connection:
transport: ssh
transport: 'ssh'
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'local'
- self._play_context.shell == 'sh'
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'local'"
- "self._play_context.shell == 'sh'"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"

View file

@ -1,40 +1,39 @@
---
task_args:
src: /tmp/deleteme
dest: /tmp/deleteme
# rsync_path: rsync
src: /tmp/deleteme
dest: /tmp/deleteme
#rsync_path: rsync
_task:
become: true
become_method: None
become: True
become_method: None
fixtures:
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
connection:
transport: ssh
transport: 'ssh'
_play_context:
become: true
become_method: sudo
remote_addr: el6host
remote_user: root
become: True
become_method: sudo
remote_addr: el6host
remote_user: root
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'local'
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
# this is a crucial aspect of this scenario ...
# note: become_user None -> root
- self.final_module_args['rsync_path'] == 'sudo -u root rsync'
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
- self.task.become == True
- self.task.become_user == None
- self._play_context.shell == 'sh'
- self._play_context.remote_addr == 'el6host'
- self._play_context.remote_user == 'root'
- self._play_context.become == False
- self._play_context.become_user == 'root'
- self._play_context.password == None
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'local'"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
# this is a crucial aspect of this scenario ...
# note: become_user None -> root
- "self.final_module_args['rsync_path'] == 'sudo -u root rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
- "self.task.become == True"
- "self.task.become_user == None"
- "self._play_context.shell == 'sh'"
- "self._play_context.remote_addr == 'el6host'"
- "self._play_context.remote_user == 'root'"
- "self._play_context.become == False"
- "self._play_context.become_user == 'root'"
- "self._play_context.password == None"

View file

@ -1,40 +1,39 @@
---
task_args:
src: /tmp/deleteme
dest: /tmp/deleteme
# rsync_path: rsync
src: /tmp/deleteme
dest: /tmp/deleteme
#rsync_path: rsync
_task:
become: None
become_method: None
become: None
become_method: None
fixtures:
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
connection:
transport: ssh
transport: 'ssh'
_play_context:
become: true
become_method: sudo
remote_addr: el6host
remote_user: root
become: True
become_method: sudo
remote_addr: el6host
remote_user: root
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'local'
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
# this is a crucial aspect of this scenario ...
# note: become_user None -> root
- self.final_module_args['rsync_path'] == 'sudo -u root rsync'
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
- self.task.become == None
- self.task.become_user == None
- self._play_context.shell == 'sh'
- self._play_context.remote_addr == 'el6host'
- self._play_context.remote_user == 'root'
- self._play_context.become == False
- self._play_context.become_user == 'root'
- self._play_context.password == None
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'local'"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
# this is a crucial aspect of this scenario ...
# note: become_user None -> root
- "self.final_module_args['rsync_path'] == 'sudo -u root rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
- "self.task.become == None"
- "self.task.become_user == None"
- "self._play_context.shell == 'sh'"
- "self._play_context.remote_addr == 'el6host'"
- "self._play_context.remote_user == 'root'"
- "self._play_context.become == False"
- "self._play_context.become_user == 'root'"
- "self._play_context.password == None"

View file

@ -1,30 +1,29 @@
---
task_args:
src: /tmp/deleteme
dest: /tmp/deleteme
src: /tmp/deleteme
dest: /tmp/deleteme
fixtures:
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
connection:
transport: ssh
transport: 'ssh'
_play_context:
remote_addr: 127.0.0.1
remote_user: vagrant
remote_addr: '127.0.0.1'
remote_user: vagrant
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'local'
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
- self.final_module_args['dest_port'] == 2202
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'
- self._play_context.shell == 'sh'
- self._play_context.remote_addr == '127.0.0.1'
- self._play_context.remote_user == 'vagrant'
- self._play_context.become == False
- self._play_context.become_user == 'root'
- self._play_context.password == None
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'local'"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['dest_port'] == 2202"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'"
- "self._play_context.shell == 'sh'"
- "self._play_context.remote_addr == '127.0.0.1'"
- "self._play_context.remote_user == 'vagrant'"
- "self._play_context.become == False"
- "self._play_context.become_user == 'root'"
- "self._play_context.password == None"

View file

@ -1,33 +1,32 @@
---
task:
# become: None
#become: None
task_args:
src: /tmp/deleteme
dest: /tmp/deleteme
src: /tmp/deleteme
dest: /tmp/deleteme
fixtures:
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
connection:
transport: ssh
transport: 'ssh'
_play_context:
become: true
remote_addr: 127.0.0.1
remote_user: vagrant
become: True
remote_addr: '127.0.0.1'
remote_user: vagrant
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'local'
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
- self.final_module_args['dest_port'] == 2202
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'
- self._play_context.shell == 'sh'
- self._play_context.remote_addr == '127.0.0.1'
- self._play_context.remote_user == 'vagrant'
- self._play_context.become == False
- self._play_context.become_user == 'root'
- self._play_context.password == None
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'local'"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['dest_port'] == 2202"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'"
- "self._play_context.shell == 'sh'"
- "self._play_context.remote_addr == '127.0.0.1'"
- "self._play_context.remote_user == 'vagrant'"
- "self._play_context.become == False"
- "self._play_context.become_user == 'root'"
- "self._play_context.password == None"

View file

@ -1,30 +1,29 @@
---
task_args:
src: /tmp/deleteme
dest: /tmp/deleteme
src: /tmp/deleteme
dest: /tmp/deleteme
fixtures:
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
connection:
transport: ssh
transport: 'ssh'
_play_context:
remote_addr: 127.0.0.1
remote_user: vagrant
remote_addr: '127.0.0.1'
remote_user: vagrant
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'local'
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
- self.final_module_args['dest_port'] == 2202
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'
- self._play_context.shell == 'sh'
- self._play_context.remote_addr == '127.0.0.1'
- self._play_context.remote_user == 'vagrant'
- self._play_context.become == False
- self._play_context.become_user == 'root'
- self._play_context.password == None
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'local'"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['dest_port'] == 2202"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'vagrant@127.0.0.1:/tmp/deleteme'"
- "self._play_context.shell == 'sh'"
- "self._play_context.remote_addr == '127.0.0.1'"
- "self._play_context.remote_user == 'vagrant'"
- "self._play_context.become == False"
- "self._play_context.become_user == 'root'"
- "self._play_context.password == None"

View file

@ -1,26 +1,25 @@
---
fixtures:
taskvars_in: taskvars_in.json
taskvars_out: taskvars_out.json
taskvars_in: taskvars_in.json
taskvars_out: taskvars_out.json
connection:
transport: ssh
transport: 'ssh'
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
_play_context:
private_key_file: ~/test.pem
private_key_file: ~/test.pem
task_args:
private_key: ~/.ssh/id_rsa
dest: /tmp/deleteme
src: /tmp/deleteme
private_key: ~/.ssh/id_rsa
dest: /tmp/deleteme
src: /tmp/deleteme
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'local'
- self._play_context.shell == 'sh'
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
- self.final_module_args['private_key'] == '~/.ssh/id_rsa'
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'local'"
- "self._play_context.shell == 'sh'"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
- "self.final_module_args['private_key'] == '~/.ssh/id_rsa'"

View file

@ -1,27 +1,26 @@
---
fixtures:
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
task_args:
src: /tmp/deleteme
dest: /tmp/deleteme
src: /tmp/deleteme
dest: /tmp/deleteme
_task:
delegate_to: u1404
delegate_to: u1404
_play_context:
shell: None
remote_addr: u1404
remote_user: root
shell: None
remote_addr: u1404
remote_user: root
connection:
transport: ssh
transport: 'ssh'
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'ssh'
- self._play_context.shell == None
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'ssh'"
- "self._play_context.shell == None"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"

View file

@ -1,29 +1,28 @@
---
fixtures:
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
task_args:
src: /tmp/deleteme
dest: /tmp/deleteme
src: /tmp/deleteme
dest: /tmp/deleteme
_task:
delegate_to: u1404
delegate_to: u1404
_play_context:
shell: None
remote_addr: u1404
remote_user: root
private_key_file: ~/test.pem
shell: None
remote_addr: u1404
remote_user: root
private_key_file: ~/test.pem
connection:
transport: ssh
transport: 'ssh'
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'ssh'
- self._play_context.shell == None
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
- self.final_module_args['private_key'] == '~/test.pem'
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'ssh'"
- "self._play_context.shell == None"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
- "self.final_module_args['private_key'] == '~/test.pem'"

View file

@ -1,34 +1,33 @@
---
fixtures:
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
task_args:
src: /tmp/deleteme
dest: /tmp/deleteme
src: /tmp/deleteme
dest: /tmp/deleteme
_task:
delegate_to: u1404
delegate_to: u1404
_play_context:
become: true
become_user: None # if ! None|root, different testcase
become_method: su
shell: None
remote_addr: u1404
remote_user: root
become: True
become_user: None #if ! None|root, different testcase
become_method: su
shell: None
remote_addr: u1404
remote_user: root
connection:
transport: ssh
transport: 'ssh'
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'ssh'
- self._play_context.shell == None
- self._play_context.remote_addr == 'u1404'
- self._play_context.remote_user == 'root'
- not self._play_context.become
- self._play_context.become_method == 'su'
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'ssh'"
- "self._play_context.shell == None"
- "self._play_context.remote_addr == 'u1404'"
- "self._play_context.remote_user == 'root'"
- "not self._play_context.become"
- "self._play_context.become_method == 'su'"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"

View file

@ -1,30 +1,29 @@
---
fixtures:
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
taskvars_in: task_vars_in.json
taskvars_out: task_vars_out.json
task_args:
src: /tmp/deleteme
dest: /tmp/deleteme
private_key: ~/.ssh/id_rsa
src: /tmp/deleteme
dest: /tmp/deleteme
private_key: ~/.ssh/id_rsa
_task:
delegate_to: u1404
delegate_to: u1404
_play_context:
shell: None
remote_addr: u1404
remote_user: root
private_key_file: ~/test.pem
shell: None
remote_addr: u1404
remote_user: root
private_key_file: ~/test.pem
connection:
transport: ssh
transport: 'ssh'
hostvars:
127.0.0.1: {}
::1: {}
localhost: {}
'127.0.0.1': {}
'::1': {}
'localhost': {}
asserts:
- hasattr(SAM._connection, 'ismock')
- SAM._connection.transport == 'ssh'
- self._play_context.shell == None
- self.execute_called
- self.final_module_args['_local_rsync_path'] == 'rsync'
- self.final_module_args['src'] == '/tmp/deleteme'
- self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'
- self.final_module_args['private_key'] == '~/.ssh/id_rsa'
- "hasattr(SAM._connection, 'ismock')"
- "SAM._connection.transport == 'ssh'"
- "self._play_context.shell == None"
- "self.execute_called"
- "self.final_module_args['_local_rsync_path'] == 'rsync'"
- "self.final_module_args['src'] == '/tmp/deleteme'"
- "self.final_module_args['dest'] == 'root@el6host:/tmp/deleteme'"
- "self.final_module_args['private_key'] == '~/.ssh/id_rsa'"

View file

@ -1,3 +1,3 @@
---
collections:
- community.general
- community.general