Merge branch 'main' into last_wins

This commit is contained in:
Adam Miller 2024-01-10 08:41:00 -06:00 committed by GitHub
commit f392e407f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
125 changed files with 4879 additions and 2388 deletions

View file

@ -1,3 +1,4 @@
---
trigger: trigger:
batch: true batch: true
branches: branches:
@ -13,7 +14,7 @@ pr:
- stable-* - stable-*
schedules: schedules:
- cron: 0 9 * * * - cron: "0 9 * * *"
displayName: Nightly displayName: Nightly
always: true always: true
branches: branches:
@ -36,13 +37,68 @@ variables:
resources: resources:
containers: containers:
- container: default - container: default
image: quay.io/ansible/azure-pipelines-test-container:1.9.0 image: quay.io/ansible/azure-pipelines-test-container:main
pool: Standard pool: Standard
stages: stages:
- stage: Sanity_devel
## Docker displayName: Ansible devel sanity
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: devel/{0}
targets:
- name: Sanity
test: sanity
- name: Units
test: units
- name: Lint
test: lint
- stage: Sanity_2_16
displayName: Ansible 2.16 sanity
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{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: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.15/{0}
targets:
- name: Sanity
test: sanity
- name: Units
test: units
- stage: Sanity_2_14
displayName: Ansible 2.14 sanity
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.14/{0}
targets:
- name: Sanity
test: sanity
- name: Units
test: units
## Docker
- stage: Docker_devel - stage: Docker_devel
displayName: Docker devel displayName: Docker devel
dependsOn: [] dependsOn: []
@ -51,136 +107,67 @@ stages:
parameters: parameters:
testFormat: devel/linux/{0}/1 testFormat: devel/linux/{0}/1
targets: targets:
- name: CentOS 7 - name: Fedora 39
test: centos7 test: fedora39
- name: Fedora 34
test: fedora34
- name: Fedora 35
test: fedora35
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 18.04
test: ubuntu1804
- name: Ubuntu 20.04 - name: Ubuntu 20.04
test: ubuntu2004 test: ubuntu2004
- stage: Docker_2_13 - name: Ubuntu 22.04
displayName: Docker 2.13 test: ubuntu2204
- stage: Docker_2_16
displayName: Docker 2.16
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.13/linux/{0}/1 testFormat: 2.16/linux/{0}/1
targets: targets:
- name: CentOS 7 - name: CentOS 7
test: centos7 test: centos7
- name: Fedora 34 - name: Fedora 38
test: fedora34 test: fedora38
- name: Fedora 35
test: fedora35
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 18.04
test: ubuntu1804
- name: Ubuntu 20.04 - name: Ubuntu 20.04
test: ubuntu2004 test: ubuntu2004
- stage: Docker_2_12 - name: Ubuntu 22.04
displayName: Docker 2.12 test: ubuntu2204
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.12/linux/{0}/1
targets:
- name: CentOS 6
test: centos6
- name: CentOS 7
test: centos7
- name: Fedora 33
test: fedora33
- name: Fedora 34
test: fedora34
- name: openSUSE 15 py2
test: opensuse15py2
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 18.04
test: ubuntu1804
- name: Ubuntu 20.04
test: ubuntu2004
- stage: Docker_2_11
displayName: Docker 2.11
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.11/linux/{0}/1
targets:
- name: CentOS 6
test: centos6
- name: CentOS 7
test: centos7
- name: Fedora 32
test: fedora32
- name: Fedora 33
test: fedora33
- name: openSUSE 15 py2
test: opensuse15py2
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 18.04
test: ubuntu1804
- name: Ubuntu 20.04
test: ubuntu2004
- stage: Docker_2_10
displayName: Docker 2.10
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.10/linux/{0}/1
targets:
- name: CentOS 6
test: centos6
- name: CentOS 7
test: centos7
- name: Fedora 30
test: fedora30
- name: Fedora 31
test: fedora31
- name: openSUSE 15 py2
test: opensuse15py2
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 16.04
test: ubuntu1604
- name: Ubuntu 18.04
test: ubuntu1804
- 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: Fedora 30
test: fedora30
- name: Fedora 31
test: fedora31
- 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 - stage: Docker_2_15
displayName: Docker 2.15
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.15/linux/{0}/1
targets:
- name: CentOS 7
test: centos7
- name: Fedora 37
test: fedora37
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 20.04
test: ubuntu2004
- name: Ubuntu 22.04
test: ubuntu2204
- stage: Docker_2_14
displayName: Docker 2.14
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.14/linux/{0}/1
targets:
- name: CentOS 7
test: centos7
- name: Fedora 36
test: fedora36
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 20.04
test: ubuntu2004
- name: Ubuntu 22.04
test: ubuntu2204
## Remote
- stage: Remote_devel - stage: Remote_devel
displayName: Remote devel displayName: Remote devel
dependsOn: [] dependsOn: []
@ -189,122 +176,71 @@ stages:
parameters: parameters:
testFormat: devel/{0}/1 testFormat: devel/{0}/1
targets: targets:
- name: MacOS 12.0 - name: RHEL 9.3
test: macos/12.0 test: rhel/9.3
- name: RHEL 7.9 - name: FreeBSD 13.2
test: rhel/7.9 test: freebsd/13.2
- name: RHEL 8.5 - stage: Remote_2_16
test: rhel/8.5 displayName: Remote 2.16
- name: FreeBSD 12.3
test: freebsd/12.3
- name: FreeBSD 13.0
test: freebsd/13.0
- stage: Remote_2_13
displayName: Remote 2.13
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.13/{0}/1 testFormat: 2.16/{0}/1
targets: targets:
- name: MacOS 12.0 - name: RHEL 8.8
test: macos/12.0 test: rhel/8.8
- name: RHEL 7.9 - name: RHEL 9.2
test: rhel/7.9 test: rhel/9.2
- name: RHEL 8.5 - name: FreeBSD 13.2
test: rhel/8.5 test: freebsd/13.2
- name: FreeBSD 12.3
test: freebsd/12.3
- name: FreeBSD 13.0
test: freebsd/13.0
- stage: Remote_2_12
displayName: Remote 2.12
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.12/{0}/1
targets:
- name: MacOS 11.1
test: macos/11.1
- name: RHEL 7.9
test: rhel/7.9
- name: RHEL 8.4
test: rhel/8.4
- name: FreeBSD 12.2
test: freebsd/12.2
- name: FreeBSD 13.0
test: freebsd/13.0
- stage: Remote_2_11
displayName: Remote 2.11
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.11/{0}/1
targets:
- name: MacOS 11.1
test: macos/11.1
- name: RHEL 7.9
test: rhel/7.9
- name: RHEL 8.3
test: rhel/8.3
- name: FreeBSD 11.4
test: freebsd/11.4
- name: FreeBSD 12.2
test: freebsd/12.2
- stage: Remote_2_10
displayName: Remote 2.10
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.10/{0}/1
targets:
- name: OS X 10.11
test: osx/10.11
- name: RHEL 7.9
test: rhel/7.9
- name: RHEL 8.2
test: rhel/8.2
- name: FreeBSD 11.1
test: freebsd/11.1
- name: FreeBSD 12.1
test: freebsd/12.1
- stage: Remote_2_9 - stage: Remote_2_15
displayName: Remote 2.9 displayName: Remote 2.15
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.9/{0}/1 testFormat: 2.15/{0}/1
targets: targets:
- name: OS X 10.11
test: osx/10.11
- name: RHEL 7.9 - name: RHEL 7.9
test: rhel/7.9 test: rhel/7.9
- name: RHEL 8.1 - name: RHEL 8.7
test: rhel/8.1 test: rhel/8.7
- name: FreeBSD 11.1 - name: RHEL 9.1
test: freebsd/11.1 test: rhel/9.1
- name: FreeBSD 12.0 - name: FreeBSD 13.2
test: freebsd/12.0 test: freebsd/13.2
## Finally - stage: Remote_2_14
displayName: Remote 2.14
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.14/{0}/1
targets:
- name: RHEL 7.9
test: rhel/7.9
- name: RHEL 8.6
test: rhel/8.6
- name: FreeBSD 13.2
test: freebsd/13.2
## Finally
- stage: Summary - stage: Summary
condition: succeededOrFailed() condition: succeededOrFailed()
dependsOn: dependsOn:
- Remote_2_9 - Sanity_2_14
- Docker_2_9 - Remote_2_14
- Remote_2_10 - Docker_2_14
- Docker_2_10 - Sanity_2_15
- Remote_2_11 - Remote_2_15
- Docker_2_11 - Docker_2_15
- Remote_2_12 - Sanity_2_16
- Docker_2_12 - Remote_2_16
- Remote_2_13 - Docker_2_16
- Docker_2_13 - Sanity_devel
- Remote_devel - Remote_devel
- Docker_devel - Docker_devel
jobs: jobs:

1
.github/BOTMETA.yml vendored
View file

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

View file

@ -5,6 +5,68 @@ ansible.posix Release Notes
.. contents:: Topics .. contents:: Topics
v1.5.4
======
Minor Changes
-------------
- json and jsonl - Add the ``ANSIBLE_JSON_INDENT`` parameter
- json and jsonl - Add the ``path`` attribute into the play and task output
Bugfixes
--------
- Fix sysctl integration test failing on newer versions of core. Previously NoneType was allowable, now it fails to convert to a str type.
- Support new sanity test for the ansible-core devel branch CI test (https://github.com/ansible-collections/ansible.posix/issues/446).
- firewall - Fix issue where adding an interface to a zone would fail when the daemon is offline
- firewall - Fix issue where opening a specific port resulted in opening the whole protocol of the specified port
- firewalld - Consider value of masquerade and icmp_block_inversion parameters when a boolean like value is passed
v1.5.2
======
Release Summary
---------------
This is the minor release of the ``ansible.posix`` collection.
This changelog contains all changes to the modules and plugins
in this collection that have been added after the release of
``ansible.posix`` 1.5.1.
Minor Changes
-------------
- Add jsonl callback plugin to ansible.posix collection
- firewalld - add `protocol` parameter
Bugfixes
--------
- Fixed a bug where firewalld module fails to create/remove zones when the daemon is stopped
- rhel_facts - Call exit_json with all keyword arguments
v1.5.1
======
Minor Changes
-------------
- mount - Add ``absent_from_fstab`` state (https://github.com/ansible-collections/ansible.posix/pull/166).
- mount - Add ``ephemeral`` value for the ``state`` parameter, that allows to mount a filesystem without altering the ``fstab`` file (https://github.com/ansible-collections/ansible.posix/pull/267).
- r4e_rpm_ostree - new module for validating package state on RHEL for Edge
- rhel_facts - new facts module to handle RHEL specific facts
- rhel_rpm_ostree - new module to handle RHEL rpm-ostree specific package management functionality
- rpm_ostree_upgrade - new module to automate rpm-ostree upgrades
- rpm_ostree_upgrade - new module to manage upgrades for rpm-ostree based systems
Bugfixes
--------
- Removed contentious terminology to match reference documentation in profile_tasks.
- firewall - Fixed to output a more complete missing library message.
- synchronize - Fixed hosts involved in rsync require the same password
v1.4.0 v1.4.0
====== ======

View file

@ -11,13 +11,7 @@ An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and de
<!--start requires_ansible--> <!--start requires_ansible-->
## Ansible version compatibility ## Ansible version compatibility
This collection has been tested against following Ansible versions: **>=2.9**. This collection has been tested against following Ansible versions: **>=2.14**.
For collections that support Ansible 2.9, please ensure you update your `network_os` to use the
fully qualified collection name (for example, `cisco.ios.ios`).
Plugins and modules within a collection may be tested with only specific Ansible versions.
A collection may contain metadata that identifies these versions.
PEP440 is the schema used to describe the versions of Ansible.
<!--end requires_ansible--> <!--end requires_ansible-->
## Included content ## Included content
@ -33,6 +27,9 @@ Name | Description
[ansible.posix.firewalld_info](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.firewalld_info_module.rst)|Gather information about firewalld [ansible.posix.firewalld_info](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.firewalld_info_module.rst)|Gather information about firewalld
[ansible.posix.mount](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.mount_module.rst)|Control active and configured mount points [ansible.posix.mount](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.mount_module.rst)|Control active and configured mount points
[ansible.posix.patch](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.patch_module.rst)|Apply patch files using the GNU patch tool [ansible.posix.patch](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.patch_module.rst)|Apply patch files using the GNU patch tool
[ansible.posix.rhel_facts](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.rhel_facts_module.rst)|Facts module to set or override RHEL specific facts.
[ansible.posix.rhel_rpm_ostree](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.rhel_rpm_ostree_module.rst)|Ensure packages exist in a RHEL for Edge rpm-ostree based system
[ansible.posix.rpm_ostree_upgrade](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.rpm_ostree_upgrade_module.rst)|Manage rpm-ostree upgrade transactions
[ansible.posix.seboolean](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.seboolean_module.rst)|Toggles SELinux booleans [ansible.posix.seboolean](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.seboolean_module.rst)|Toggles SELinux booleans
[ansible.posix.selinux](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.selinux_module.rst)|Change policy and state of SELinux [ansible.posix.selinux](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.selinux_module.rst)|Change policy and state of SELinux
[ansible.posix.synchronize](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.synchronize_module.rst)|A wrapper around rsync to make common tasks in your playbooks quick and easy [ansible.posix.synchronize](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.synchronize_module.rst)|A wrapper around rsync to make common tasks in your playbooks quick and easy
@ -60,8 +57,6 @@ collections:
See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details. See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details.
**NOTE**: For Ansible 2.9, you may not see deprecation warnings when you run your playbooks with this collection. Use this documentation to track when a module is deprecated.
## Contributing to this collection ## Contributing to this collection
<!--Describe how the community can contribute to your collection. At a minimum, include how and where users can create issues to report problems or request features for this collection. List contribution requirements, including preferred workflows and necessary testing, so you can benefit from community PRs. If you are following general Ansible contributor guidelines, you can link to - [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html). --> <!--Describe how the community can contribute to your collection. At a minimum, include how and where users can create issues to report problems or request features for this collection. List contribution requirements, including preferred workflows and necessary testing, so you can benefit from community PRs. If you are following general Ansible contributor guidelines, you can link to - [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html). -->
@ -88,12 +83,10 @@ None
<!-- List the versions of Ansible the collection has been tested with. Must match what is in galaxy.yml. --> <!-- List the versions of Ansible the collection has been tested with. Must match what is in galaxy.yml. -->
- ansible-core 2.14 (devel) - ansible-core 2.17 (devel)
- ansible-core 2.13 (stable) - ansible-core 2.16 (stable)
- ansible-core 2.12 (stable) - ansible-core 2.15 (stable)
- ansible-core 2.11 (stable) - ansible-core 2.14 (stable)
- ansible-base 2.10 (stable)
- ansible 2.9 (stable)
## Roadmap ## Roadmap

View file

@ -1,4 +1,4 @@
# This is a cross-platform list tracking distribution packages needed by tests; # This is a cross-platform list tracking distribution packages needed by tests;
# see https://docs.openstack.org/infra/bindep/ for additional information. # see https://docs.openstack.org/infra/bindep/ for additional information.
rsync [platform:rhel-8 platform:rhel-9] rsync [platform:redhat]

View file

@ -260,3 +260,90 @@ releases:
- sanity_fixes.yml - sanity_fixes.yml
- shell_escape_full_path_for_rsync.yml - shell_escape_full_path_for_rsync.yml
release_date: '2022-05-23' release_date: '2022-05-23'
1.5.1:
changes:
bugfixes:
- Removed contentious terminology to match reference documentation in profile_tasks.
- firewall - Fixed to output a more complete missing library message.
- synchronize - Fixed hosts involved in rsync require the same password
minor_changes:
- mount - Add ``absent_from_fstab`` state (https://github.com/ansible-collections/ansible.posix/pull/166).
- mount - Add ``ephemeral`` value for the ``state`` parameter, that allows to
mount a filesystem without altering the ``fstab`` file (https://github.com/ansible-collections/ansible.posix/pull/267).
- r4e_rpm_ostree - new module for validating package state on RHEL for Edge
- rhel_facts - new facts module to handle RHEL specific facts
- rhel_rpm_ostree - new module to handle RHEL rpm-ostree specific package management
functionality
- rpm_ostree_upgrade - new module to automate rpm-ostree upgrades
- rpm_ostree_upgrade - new module to manage upgrades for rpm-ostree based systems
fragments:
- 166_mount_absent_fstab.yml
- 267_mount_ephemeral.yml
- 366_update_version_number_for_galaxy.yml
- 371_refactoring_ci_process_202206.yml
- 373_firewall_fix_missing_library_message.yml
- 375_update_azp_container.yml
- 380_update_usage_profile_tasks.yml
- 386_follow_ci_testing_rules.yml
- 389_ci_add_stable_214.yml
- 390_hosts_involved_same_password.yml
- 393-rpm-ostree.yml
- 393_rhel_for_edge.yml
- 400-fix-boolean-values-in-docs.yml
- 401_document_module_default_values.yml
- 407_fix_firewalld_port_test.yml
- 409_update_azp_matrix.yml
release_date: '2023-01-20'
1.5.2:
changes:
bugfixes:
- Fixed a bug where firewalld module fails to create/remove zones when the daemon
is stopped
- rhel_facts - Call exit_json with all keyword arguments
minor_changes:
- Add jsonl callback plugin to ansible.posix collection
- firewalld - add `protocol` parameter
release_summary: 'This is the minor release of the ``ansible.posix`` collection.
This changelog contains all changes to the modules and plugins
in this collection that have been added after the release of
``ansible.posix`` 1.5.1.'
fragments:
- 1.5.2.yml
- 399_firewalld_create_remove_zone_when_offline.yml
- 413-synchronize-seealso.yml
- 417-add-protocol-parameter.yml
- 419-fix-patch-doc.yml
- 425-support_test-sanity-docker-devel.yml
- 426-firewalld_info-doc-update.yml
- 434-fix-rhel_facts-exit_json.yml
- 535-add-jsonl-callback.yml
release_date: '2023-04-07'
1.5.4:
changes:
bugfixes:
- Fix sysctl integration test failing on newer versions of core. Previously
NoneType was allowable, now it fails to convert to a str type.
- Support new sanity test for the ansible-core devel branch CI test (https://github.com/ansible-collections/ansible.posix/issues/446).
- firewall - Fix issue where adding an interface to a zone would fail when the
daemon is offline
- firewall - Fix issue where opening a specific port resulted in opening the
whole protocol of the specified port
- firewalld - Consider value of masquerade and icmp_block_inversion parameters
when a boolean like value is passed
minor_changes:
- json and jsonl - Add the ``ANSIBLE_JSON_INDENT`` parameter
- json and jsonl - Add the ``path`` attribute into the play and task output
fragments:
- 343-fix-profile_tasks-callback-documentation.yml
- 402_firewall_fix_offline_interface_add.yml
- 404_firewalld_masquerade_icmp_block_inversion_bugfixes.yml
- 440-json-add-path-field.yaml
- 441-json-add-indent-parameter.yaml
- 445_ci_support_stable-215.yml
- 448_support_new_sanity_test.yml
- 451_firewall_fix_protocol_parameter.yml
- 456_sysctl_fix_nonetype.yml
release_date: '2023-05-10'

View file

@ -0,0 +1,10 @@
---
minor_changes:
- "seboolean - respawn module to use the system python interpreter when the ``selinux`` python module is not available for ``ansible_python_interpreter``
(https://github.com/ansible-collections/ansible.posix/pull/460)."
- "selinux - respawn module to use the system python interpreter when the ``selinux`` python module is not available for ``ansible_python_interpreter``
(https://github.com/ansible-collections/ansible.posix/pull/460)."
- "firewalld - respawn module to use the system python interpreter when the ``firewall`` python module is not available for ``ansible_python_interpreter``
(https://github.com/ansible-collections/ansible.posix/pull/460)."
- "firewalld_info - respawn module to use the system python interpreter when the ``firewall`` python module is not available for ``ansible_python_interpreter``
(https://github.com/ansible-collections/ansible.posix/pull/460)."

View file

@ -0,0 +1,2 @@
trivial:
- "Fix integration tests so they work with ansible-core devel / 2.16 (https://github.com/ansible-collections/ansible.posix/pull/466)."

View file

@ -0,0 +1,3 @@
---
trivial:
- "Drop Python3.9 and update versions of RHEL,Fedora and FreeBSD for ansible-core:devel test(https://github.com/ansible-collections/ansible.posix/issues/476)."

View file

@ -0,0 +1,2 @@
minor_changes:
- firewalld - added offline flag implementation (https://github.com/ansible-collections/ansible.posix/pull/484)

View file

@ -0,0 +1,3 @@
---
trivial:
- "Drop FreeBSD12.4 from CI for ansible-core:devel(https://github.com/ansible-collections/ansible.posix/issues/486)."

View file

@ -0,0 +1,2 @@
minor_changes:
- firewalld_info - Only warn about ignored zones, when there are zones ignored.

View file

@ -0,0 +1,3 @@
---
trivial:
- "Refactoring remote CI targets."

View file

@ -0,0 +1,3 @@
---
trivial:
- "Replace Fedora 38 with 39 for container test(https://github.com/ansible-collections/ansible.posix/issues/509)."

View file

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

View file

@ -0,0 +1,2 @@
trivial:
- "Move Galaxy test requirements from old transitional format in tests/requirements.yml to standard Ansible Galaxy requirements files in tests/integration/requirements.yml and tests/unit/requirements.yml."

View file

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

View file

@ -49,8 +49,8 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>If the target is a directory, setting this to <code>yes</code> will make it the default ACL for entities created inside the directory.</div> <div>If the target is a directory, setting this to <code>true</code> will make it the default ACL for entities created inside the directory.</div>
<div>Setting <code>default</code> to <code>yes</code> causes an error if the path is a file.</div> <div>Setting <code>default</code> to <code>true</code> causes an error if the path is a file.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -63,6 +63,7 @@ Parameters
</div> </div>
</td> </td>
<td> <td>
<b>Default:</b><br/><div style="color: blue">""</div>
</td> </td>
<td> <td>
<div>The actual user or group that the ACL applies to when matching entity types user or group are selected.</div> <div>The actual user or group that the ACL applies to when matching entity types user or group are selected.</div>
@ -285,7 +286,7 @@ Examples
entity: joe entity: joe
etype: user etype: user
permissions: rw permissions: rw
default: yes default: true
state: present state: present
- name: Same as previous but using entry shorthand - name: Same as previous but using entry shorthand

View file

@ -171,7 +171,7 @@ Examples
command: ls -d / >/dev/null command: ls -d / >/dev/null
count: 20 count: 20
units: minutes units: minutes
unique: yes unique: true

View file

@ -139,8 +139,8 @@ Parameters
</td> </td>
<td> <td>
<div>Whether this module should manage the directory of the authorized key file.</div> <div>Whether this module should manage the directory of the authorized key file.</div>
<div>If set to <code>yes</code>, the module will create the directory, as well as set the owner and permissions of an existing directory.</div> <div>If set to <code>true</code>, the module will create the directory, as well as set the owner and permissions of an existing directory.</div>
<div>Be sure to set <code>manage_dir=no</code> if you are using an alternate directory for authorized_keys, as set with <code>path</code>, since you could lock yourself out of SSH access.</div> <div>Be sure to set <code>manage_dir=false</code> if you are using an alternate directory for authorized_keys, as set with <code>path</code>, since you could lock yourself out of SSH access.</div>
<div>See the example below.</div> <div>See the example below.</div>
</td> </td>
</tr> </tr>
@ -212,9 +212,9 @@ Parameters
</td> </td>
<td> <td>
<div>This only applies if using a https url as the source of the keys.</div> <div>This only applies if using a https url as the source of the keys.</div>
<div>If set to <code>no</code>, the SSL certificates will not be validated.</div> <div>If set to <code>false</code>, the SSL certificates will not be validated.</div>
<div>This should only set to <code>no</code> used on personally controlled sites using self-signed certificates as it avoids verifying the source site.</div> <div>This should only set to <code>false</code> used on personally controlled sites using self-signed certificates as it avoids verifying the source site.</div>
<div>Prior to 2.1 the code worked as if this was set to <code>yes</code>.</div> <div>Prior to 2.1 the code worked as if this was set to <code>true</code>.</div>
</td> </td>
</tr> </tr>
</table> </table>
@ -252,7 +252,7 @@ Examples
state: present state: present
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
path: /etc/ssh/authorized_keys/charlie path: /etc/ssh/authorized_keys/charlie
manage_dir: False manage_dir: false
- name: Set up multiple authorized keys - name: Set up multiple authorized keys
ansible.posix.authorized_key: ansible.posix.authorized_key:
@ -275,14 +275,14 @@ Examples
user: charlie user: charlie
state: present state: present
key: https://github.com/user.keys key: https://github.com/user.keys
validate_certs: False validate_certs: false
- name: Set authorized key, removing all the authorized keys already set - name: Set authorized key, removing all the authorized keys already set
ansible.posix.authorized_key: ansible.posix.authorized_key:
user: root user: root
key: "{{ lookup('file', 'public_keys/doe-jane') }}" key: "{{ lookup('file', 'public_keys/doe-jane') }}"
state: present state: present
exclusive: True exclusive: true
- name: Set authorized key for user ubuntu copying it from current user - name: Set authorized key for user ubuntu copying it from current user
ansible.posix.authorized_key: ansible.posix.authorized_key:
@ -460,7 +460,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
</td> </td>
<td>success</td> <td>success</td>
<td> <td>
<div>This only applies if using a https url as the source of the keys. If set to <code>no</code>, the SSL certificates will not be validated.</div> <div>This only applies if using a https url as the source of the keys. If set to <code>false</code>, the SSL certificates will not be validated.</div>
<br/> <br/>
<div style="font-size: smaller"><b>Sample:</b></div> <div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">True</div> <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">True</div>

View file

@ -89,7 +89,12 @@ Examples
- name: Gather information about active zones - name: Gather information about active zones
ansible.posix.firewalld_info: ansible.posix.firewalld_info:
active_zones: yes active_zones: true
register: result
- name: Print default zone for debugging
ansible.builtin.debug:
var: result.firewalld_info.default_zone
- name: Gather information about specific zones - name: Gather information about specific zones
ansible.posix.firewalld_info: ansible.posix.firewalld_info:
@ -97,6 +102,7 @@ Examples
- public - public
- external - external
- internal - internal
register: result
@ -163,7 +169,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<td class="elbow-placeholder">&nbsp;</td> <td class="elbow-placeholder">&nbsp;</td>
<td colspan="3"> <td colspan="3">
<div class="ansibleOptionAnchor" id="return-"></div> <div class="ansibleOptionAnchor" id="return-"></div>
<b>default_zones</b> <b>default_zone</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a> <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small"> <div style="font-size: small">
<span style="color: purple">string</span> <span style="color: purple">string</span>

View file

@ -155,7 +155,7 @@ Parameters
<td> <td>
<div>Should this configuration be in the running firewalld configuration or persist across reboots.</div> <div>Should this configuration be in the running firewalld configuration or persist across reboots.</div>
<div>As of Ansible 2.3, permanent operations can operate on firewalld configs when it is not running (requires firewalld &gt;= 0.3.9).</div> <div>As of Ansible 2.3, permanent operations can operate on firewalld configs when it is not running (requires firewalld &gt;= 0.3.9).</div>
<div>Note that if this is <code>no</code>, immediate is assumed <code>yes</code>.</div> <div>Note that if this is <code>false</code>, immediate is assumed <code>true</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -262,6 +262,21 @@ Parameters
</td> </td>
</tr> </tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>protocol</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
</td>
<td>
<div>Name of a protocol to add/remove to/from firewalld.</div>
</td>
</tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div> <div class="ansibleOptionAnchor" id="parameter-"></div>
@ -414,29 +429,35 @@ Examples
- name: permit traffic in default zone for https service - name: permit traffic in default zone for https service
ansible.posix.firewalld: ansible.posix.firewalld:
service: https service: https
permanent: yes permanent: true
state: enabled
- name: permit ospf traffic
ansible.posix.firewalld:
protocol: ospf
permanent: true
state: enabled state: enabled
- name: do not permit traffic in default zone on port 8081/tcp - name: do not permit traffic in default zone on port 8081/tcp
ansible.posix.firewalld: ansible.posix.firewalld:
port: 8081/tcp port: 8081/tcp
permanent: yes permanent: true
state: disabled state: disabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
port: 161-162/udp port: 161-162/udp
permanent: yes permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: dmz zone: dmz
service: http service: http
permanent: yes permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
rich_rule: rule service name="ftp" audit limit value="1/m" accept rich_rule: rule service name="ftp" audit limit value="1/m" accept
permanent: yes permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
@ -447,44 +468,44 @@ Examples
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: trusted zone: trusted
interface: eth2 interface: eth2
permanent: yes permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
masquerade: yes masquerade: true
state: enabled state: enabled
permanent: yes permanent: true
zone: dmz zone: dmz
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: custom zone: custom
state: present state: present
permanent: yes permanent: true
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: drop zone: drop
state: enabled state: enabled
permanent: yes permanent: true
icmp_block_inversion: yes icmp_block_inversion: true
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: drop zone: drop
state: enabled state: enabled
permanent: yes permanent: true
icmp_block: echo-request icmp_block: echo-request
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: internal zone: internal
state: present state: present
permanent: yes permanent: true
target: ACCEPT target: ACCEPT
- name: Redirect port 443 to 8443 with Rich Rule - name: Redirect port 443 to 8443 with Rich Rule
ansible.posix.firewalld: ansible.posix.firewalld:
rich_rule: rule family=ipv4 forward-port port=443 protocol=tcp to-port=8443 rich_rule: rule family=ipv4 forward-port port=443 protocol=tcp to-port=8443
zone: public zone: public
permanent: yes permanent: true
immediate: yes immediate: true
state: enabled state: enabled

View file

@ -73,6 +73,7 @@ Parameters
<div>For Solaris systems, <code>true</code> will set <code>yes</code> as the value of mount at boot in <em>/etc/vfstab</em>.</div> <div>For Solaris systems, <code>true</code> will set <code>yes</code> as the value of mount at boot in <em>/etc/vfstab</em>.</div>
<div>For Linux, FreeBSD, NetBSD and OpenBSD systems, <code>false</code> will add <code>noauto</code> to mount options in <em>/etc/fstab</em>.</div> <div>For Linux, FreeBSD, NetBSD and OpenBSD systems, <code>false</code> will add <code>noauto</code> to mount options in <em>/etc/fstab</em>.</div>
<div>To avoid mount option conflicts, if <code>noauto</code> specified in <code>opts</code>, mount module will ignore <code>boot</code>.</div> <div>To avoid mount option conflicts, if <code>noauto</code> specified in <code>opts</code>, mount module will ignore <code>boot</code>.</div>
<div>This parameter is ignored when <em>state</em> is set to <code>ephemeral</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -90,7 +91,7 @@ Parameters
<td> <td>
<div>Dump (see fstab(5)).</div> <div>Dump (see fstab(5)).</div>
<div>Note that if set to <code>null</code> and <em>state</em> set to <code>present</code>, it will cease to work and duplicate entries will be made with subsequent runs.</div> <div>Note that if set to <code>null</code> and <em>state</em> set to <code>present</code>, it will cease to work and duplicate entries will be made with subsequent runs.</div>
<div>Has no effect on Solaris systems.</div> <div>Has no effect on Solaris systems or when used with <code>ephemeral</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -110,6 +111,7 @@ Parameters
<div>This might be useful if you need to configure mountpoints in a chroot environment.</div> <div>This might be useful if you need to configure mountpoints in a chroot environment.</div>
<div>OpenBSD does not allow specifying alternate fstab files with mount so do not use this on OpenBSD with any state that operates on the live filesystem.</div> <div>OpenBSD does not allow specifying alternate fstab files with mount so do not use this on OpenBSD with any state that operates on the live filesystem.</div>
<div>This parameter defaults to /etc/fstab or /etc/vfstab on Solaris.</div> <div>This parameter defaults to /etc/fstab or /etc/vfstab on Solaris.</div>
<div>This parameter is ignored when <em>state</em> is set to <code>ephemeral</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -125,7 +127,7 @@ Parameters
</td> </td>
<td> <td>
<div>Filesystem type.</div> <div>Filesystem type.</div>
<div>Required when <em>state</em> is <code>present</code> or <code>mounted</code>.</div> <div>Required when <em>state</em> is <code>present</code>, <code>mounted</code> or <code>ephemeral</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -158,7 +160,7 @@ Parameters
<td> <td>
<div>Passno (see fstab(5)).</div> <div>Passno (see fstab(5)).</div>
<div>Note that if set to <code>null</code> and <em>state</em> set to <code>present</code>, it will cease to work and duplicate entries will be made with subsequent runs.</div> <div>Note that if set to <code>null</code> and <em>state</em> set to <code>present</code>, it will cease to work and duplicate entries will be made with subsequent runs.</div>
<div>Deprecated on Solaris systems.</div> <div>Deprecated on Solaris systems. Has no effect when used with <code>ephemeral</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -192,7 +194,7 @@ Parameters
</td> </td>
<td> <td>
<div>Device (or NFS volume, or something else) to be mounted on <em>path</em>.</div> <div>Device (or NFS volume, or something else) to be mounted on <em>path</em>.</div>
<div>Required when <em>state</em> set to <code>present</code> or <code>mounted</code>.</div> <div>Required when <em>state</em> set to <code>present</code>, <code>mounted</code> or <code>ephemeral</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -208,18 +210,22 @@ Parameters
<td> <td>
<ul style="margin: 0; padding: 0"><b>Choices:</b> <ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>absent</li> <li>absent</li>
<li>absent_from_fstab</li>
<li>mounted</li> <li>mounted</li>
<li>present</li> <li>present</li>
<li>unmounted</li> <li>unmounted</li>
<li>remounted</li> <li>remounted</li>
<li>ephemeral</li>
</ul> </ul>
</td> </td>
<td> <td>
<div>If <code>mounted</code>, the device will be actively mounted and appropriately configured in <em>fstab</em>. If the mount point is not present, the mount point will be created.</div> <div>If <code>mounted</code>, the device will be actively mounted and appropriately configured in <em>fstab</em>. If the mount point is not present, the mount point will be created.</div>
<div>If <code>unmounted</code>, the device will be unmounted without changing <em>fstab</em>.</div> <div>If <code>unmounted</code>, the device will be unmounted without changing <em>fstab</em>.</div>
<div><code>present</code> only specifies that the device is to be configured in <em>fstab</em> and does not trigger or require a mount.</div> <div><code>present</code> only specifies that the device is to be configured in <em>fstab</em> and does not trigger or require a mount.</div>
<div><code>ephemeral</code> only specifies that the device is to be mounted, without changing <em>fstab</em>. If it is already mounted, a remount will be triggered. This will always return changed=True. If the mount point <em>path</em> has already a device mounted on, and its source is different than <em>src</em>, the module will fail to avoid unexpected unmount or mount point override. If the mount point is not present, the mount point will be created. The <em>fstab</em> is completely ignored. This option is added in version 1.5.0.</div>
<div><code>absent</code> specifies that the device mount&#x27;s entry will be removed from <em>fstab</em> and will also unmount the device and remove the mount point.</div> <div><code>absent</code> specifies that the device mount&#x27;s entry will be removed from <em>fstab</em> and will also unmount the device and remove the mount point.</div>
<div><code>remounted</code> specifies that the device will be remounted for when you want to force a refresh on the mount itself (added in 2.9). This will always return changed=true. If <em>opts</em> is set, the options will be applied to the remount, but will not change <em>fstab</em>. Additionally, if <em>opts</em> is set, and the remount command fails, the module will error to prevent unexpected mount changes. Try using <code>mounted</code> instead to work around this issue.</div> <div><code>remounted</code> specifies that the device will be remounted for when you want to force a refresh on the mount itself (added in 2.9). This will always return changed=true. If <em>opts</em> is set, the options will be applied to the remount, but will not change <em>fstab</em>. Additionally, if <em>opts</em> is set, and the remount command fails, the module will error to prevent unexpected mount changes. Try using <code>mounted</code> instead to work around this issue. <code>remounted</code> expects the mount point to be present in the <em>fstab</em>. To remount a mount point not registered in <em>fstab</em>, use <code>ephemeral</code> instead, especially with BSD nodes.</div>
<div><code>absent_from_fstab</code> specifies that the device mount&#x27;s entry will be removed from <em>fstab</em>. This option does not unmount it or delete the mountpoint.</div>
</td> </td>
</tr> </tr>
</table> </table>
@ -304,10 +310,18 @@ Examples
src: 192.168.1.100:/nfs/ssd/shared_data src: 192.168.1.100:/nfs/ssd/shared_data
path: /mnt/shared_data path: /mnt/shared_data
opts: rw,sync,hard opts: rw,sync,hard
boot: no boot: false
state: mounted state: mounted
fstype: nfs fstype: nfs
- name: Mount ephemeral SMB volume
ansible.posix.mount:
src: //192.168.1.200/share
path: /mnt/smb_share
opts: "rw,vers=3,file_mode=0600,dir_mode=0700,dom={{ ad_domain }},username={{ ad_username }},password={{ ad_password }}"
fstype: cifs
state: ephemeral

View file

@ -84,9 +84,9 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>Setting to <code>yes</code> will disable patch&#x27;s heuristic for transforming CRLF line endings into LF.</div> <div>Setting to <code>true</code> will disable patch&#x27;s heuristic for transforming CRLF line endings into LF.</div>
<div>Line endings of src and dest must match.</div> <div>Line endings of src and dest must match.</div>
<div>If set to <code>no</code>, <code>patch</code> will replace CRLF in <code>src</code> files on POSIX.</div> <div>If set to <code>false</code>, <code>patch</code> will replace CRLF in <code>src</code> files on POSIX.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -122,7 +122,7 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>Setting to <code>yes</code> will ignore white space changes between patch and input..</div> <div>Setting to <code>true</code> will ignore white space changes between patch and input.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -141,7 +141,7 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>If <code>no</code>, it will search for src at originating/controller machine, if <code>yes</code> it will go to the remote/target machine for the <code>src</code>.</div> <div>If <code>false</code>, it will search for src at originating/controller machine, if <code>true</code> it will go to the remote/target machine for the <code>src</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -157,7 +157,7 @@ Parameters
<td> <td>
</td> </td>
<td> <td>
<div>Path of the patch file as accepted by the GNU patch tool. If <code>remote_src</code> is &#x27;no&#x27;, the patch source file is looked up from the module&#x27;s <em>files</em> directory.</div> <div>Path of the patch file as accepted by the GNU patch tool. If <code>remote_src</code> is <code>false</code>, the patch source file is looked up from the module&#x27;s <em>files</em> directory.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: patchfile</div> <div style="font-size: small; color: darkgreen"><br/>aliases: patchfile</div>
</td> </td>
</tr> </tr>

View file

@ -0,0 +1,103 @@
.. _ansible.posix.rhel_facts_module:
************************
ansible.posix.rhel_facts
************************
**Facts module to set or override RHEL specific facts.**
Version added: 1.5.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Compatibility layer for using the "package" module for rpm-ostree based systems via setting the "pkg_mgr" fact correctly.
Requirements
------------
The below requirements are needed on the host that executes this module.
- rpm-ostree
See Also
--------
.. seealso::
:ref:`ansible.builtin.package_module`
The official documentation on the **ansible.builtin.package** module.
Examples
--------
.. code-block:: yaml
- name: Playbook to use the package module on all RHEL footprints
vars:
ansible_facts_modules:
- setup # REQUIRED to be run before all custom fact modules
- ansible.posix.rhel_facts
tasks:
- name: Ensure packages are installed
ansible.builtin.package:
name:
- htop
- ansible
state: present
Returned Facts
--------------
Facts returned by this module are added/updated in the ``hostvars`` host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.
.. raw:: html
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="1">Fact</th>
<th>Returned</th>
<th width="100%">Description</th>
</tr>
<tr>
<td colspan="1" colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>pkg_mgr</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this fact"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>when needed</td>
<td>
<div>System-level package manager override
</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">{&#x27;pkg_mgr&#x27;: &#x27;ansible.posix.rhel_facts&#x27;}</div>
</td>
</tr>
</table>
<br/><br/>
Status
------
Authors
~~~~~~~
- Adam Miller (@maxamillion)

View file

@ -0,0 +1,156 @@
.. _ansible.posix.rhel_rpm_ostree_module:
*****************************
ansible.posix.rhel_rpm_ostree
*****************************
**Ensure packages exist in a RHEL for Edge rpm-ostree based system**
Version added: 1.5.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Compatibility layer for using the "package" module for RHEL for Edge systems utilizing the RHEL System Roles.
Requirements
------------
The below requirements are needed on the host that executes this module.
- rpm-ostree
Parameters
----------
.. raw:: html
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="1">Parameter</th>
<th>Choices/<font color="blue">Defaults</font></th>
<th width="100%">Comments</th>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>name</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
/ <span style="color: purple">elements=string</span>
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>A package name or package specifier with version, like <code>name-1.0</code>.</div>
<div>Comparison operators for package version are valid here <code>&gt;</code>, <code>&lt;</code>, <code>&gt;=</code>, <code>&lt;=</code>. Example - <code>name&gt;=1.0</code></div>
<div>If a previous version is specified, the task also needs to turn <code>allow_downgrade</code> on. See the <code>allow_downgrade</code> documentation for caveats with downgrading packages.</div>
<div>When using state=latest, this can be <code>&#x27;*&#x27;</code> which means run <code>yum -y update</code>.</div>
<div>You can also pass a url or a local path to a rpm file (using state=present). To operate on several packages this can accept a comma separated string of packages or (as of 2.0) a list of packages.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: pkg</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>state</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>absent</li>
<li>installed</li>
<li>latest</li>
<li>present</li>
<li>removed</li>
</ul>
</td>
<td>
<div>Whether to install (<code>present</code> or <code>installed</code>, <code>latest</code>), or remove (<code>absent</code> or <code>removed</code>) a package.</div>
<div><code>present</code> and <code>installed</code> will simply ensure that a desired package is installed.</div>
<div><code>latest</code> will update the specified package if it&#x27;s not of the latest available version.</div>
<div><code>absent</code> and <code>removed</code> will remove the specified package.</div>
<div>Default is <code>None</code>, however in effect the default action is <code>present</code> unless the <code>autoremove</code> option is enabled for this module, then <code>absent</code> is inferred.</div>
</td>
</tr>
</table>
<br/>
Notes
-----
.. note::
- This module does not support installing or removing packages to/from an overlay as this is not supported by RHEL for Edge, packages needed should be defined in the osbuild Blueprint and provided to Image Builder at build time. This module exists only for ``package`` module compatibility.
Examples
--------
.. code-block:: yaml
- name: Ensure htop and ansible are installed on rpm-ostree based RHEL
ansible.posix.rhel_rpm_ostree:
name:
- htop
- ansible
state: present
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
.. raw:: html
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="1">Key</th>
<th>Returned</th>
<th width="100%">Description</th>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>msg</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>always</td>
<td>
<div>status of rpm transaction</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">No changes made.</div>
</td>
</tr>
</table>
<br/><br/>
Status
------
Authors
~~~~~~~
- Adam Miller (@maxamillion)

View file

@ -0,0 +1,175 @@
.. _ansible.posix.rpm_ostree_upgrade_module:
********************************
ansible.posix.rpm_ostree_upgrade
********************************
**Manage rpm-ostree upgrade transactions**
Version added: 1.5.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Manage an rpm-ostree upgrade transactions.
Requirements
------------
The below requirements are needed on the host that executes this module.
- rpm-ostree
Parameters
----------
.. raw:: html
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="1">Parameter</th>
<th>Choices/<font color="blue">Defaults</font></th>
<th width="100%">Comments</th>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>allow_downgrade</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Allow for the upgrade to be a chronologically older tree.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>cache_only</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Perform the transaction using only pre-cached data, do not download.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>os</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">""</div>
</td>
<td>
<div>The OSNAME upon which to operate.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>peer</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Force peer-to-peer connection instead of using a system message bus.</div>
</td>
</tr>
</table>
<br/>
Examples
--------
.. code-block:: yaml
- name: Upgrade the rpm-ostree image without options, accept all defaults
ansible.posix.rpm_ostree_upgrade:
- name: Upgrade the rpm-ostree image allowing downgrades
ansible.posix.rpm_ostree_upgrade:
allow_downgrade: true
Return Values
-------------
Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
.. raw:: html
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="1">Key</th>
<th>Returned</th>
<th width="100%">Description</th>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>msg</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>always</td>
<td>
<div>The command standard output</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">No upgrade available.</div>
</td>
</tr>
</table>
<br/><br/>
Status
------
Authors
~~~~~~~
- Adam Miller (@maxamillion)

View file

@ -92,7 +92,7 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>Set to <code>yes</code> if the boolean setting should survive a reboot.</div> <div>Set to <code>true</code> if the boolean setting should survive a reboot.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -135,8 +135,8 @@ Examples
- name: Set httpd_can_network_connect flag on and keep it persistent across reboots - name: Set httpd_can_network_connect flag on and keep it persistent across reboots
ansible.posix.seboolean: ansible.posix.seboolean:
name: httpd_can_network_connect name: httpd_can_network_connect
state: yes state: true
persistent: yes persistent: true

View file

@ -150,7 +150,7 @@ Parameters
</td> </td>
<td> <td>
<div>Delete files in <em>dest</em> that do not exist (after transfer, not before) in the <em>src</em> path.</div> <div>Delete files in <em>dest</em> that do not exist (after transfer, not before) in the <em>src</em> path.</div>
<div>This option requires <em>recursive=yes</em>.</div> <div>This option requires <em>recursive=true</em>.</div>
<div>This option ignores excluded files and behaves like the rsync opt <code>--delete-after</code>.</div> <div>This option ignores excluded files and behaves like the rsync opt <code>--delete-after</code>.</div>
</td> </td>
</tr> </tr>
@ -465,7 +465,7 @@ Parameters
</td> </td>
<td> <td>
<div>Put user@ for the remote paths.</div> <div>Put user@ for the remote paths.</div>
<div>If you have a custom ssh config to define the remote user for a host that does not match the inventory user, you should set this parameter to <code>no</code>.</div> <div>If you have a custom ssh config to define the remote user for a host that does not match the inventory user, you should set this parameter to <code>false</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -502,8 +502,8 @@ Parameters
</td> </td>
<td> <td>
<div>SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections. This is accomplished by setting the SSH <code>ControlSocket</code> to <code>none</code>.</div> <div>SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections. This is accomplished by setting the SSH <code>ControlSocket</code> to <code>none</code>.</div>
<div>Set this option to <code>yes</code> to allow multiplexing and reduce SSH connection overhead.</div> <div>Set this option to <code>true</code> to allow multiplexing and reduce SSH connection overhead.</div>
<div>Note that simply setting this option to <code>yes</code> is not enough; You must also configure SSH connection multiplexing in your SSH client config by setting values for <code>ControlMaster</code>, <code>ControlPersist</code> and <code>ControlPath</code>.</div> <div>Note that simply setting this option to <code>true</code> is not enough; You must also configure SSH connection multiplexing in your SSH client config by setting values for <code>ControlMaster</code>, <code>ControlPersist</code> and <code>ControlPath</code>.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -595,8 +595,8 @@ See Also
.. seealso:: .. seealso::
:ref:`copy_module` :ref:`ansible.builtin.copy_module`
The official documentation on the **copy** module. The official documentation on the **ansible.builtin.copy** module.
:ref:`community.windows.win_robocopy_module` :ref:`community.windows.win_robocopy_module`
The official documentation on the **community.windows.win_robocopy** module. The official documentation on the **community.windows.win_robocopy** module.
@ -639,27 +639,27 @@ Examples
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
archive: no archive: false
- name: Synchronization with --archive options enabled except for --recursive - name: Synchronization with --archive options enabled except for --recursive
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
recursive: no recursive: false
- name: Synchronization with --archive options enabled except for --times, with --checksum option enabled - name: Synchronization with --archive options enabled except for --times, with --checksum option enabled
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
checksum: yes checksum: true
times: no times: false
- name: Synchronization without --archive options enabled except use --links - name: Synchronization without --archive options enabled except use --links
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
archive: no archive: false
links: yes links: true
- name: Synchronization of two paths both on the control machine - name: Synchronization of two paths both on the control machine
ansible.posix.synchronize: ansible.posix.synchronize:
@ -689,8 +689,8 @@ Examples
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
delete: yes delete: true
recursive: yes recursive: true
# This specific command is granted su privileges on the destination # This specific command is granted su privileges on the destination
- name: Synchronize using an alternate rsync command - name: Synchronize using an alternate rsync command

View file

@ -85,7 +85,7 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>If <code>yes</code>, performs a <em>/sbin/sysctl -p</em> if the <code>sysctl_file</code> is updated. If <code>no</code>, does not reload <em>sysctl</em> even if the <code>sysctl_file</code> is updated.</div> <div>If <code>true</code>, performs a <em>/sbin/sysctl -p</em> if the <code>sysctl_file</code> is updated. If <code>false</code>, does not reload <em>sysctl</em> even if the <code>sysctl_file</code> is updated.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -139,7 +139,7 @@ Parameters
</ul> </ul>
</td> </td>
<td> <td>
<div>Verify token value with the sysctl command and set with -w if necessary</div> <div>Verify token value with the sysctl command and set with -w if necessary.</div>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -186,21 +186,21 @@ Examples
name: kernel.panic name: kernel.panic
value: '3' value: '3'
sysctl_file: /tmp/test_sysctl.conf sysctl_file: /tmp/test_sysctl.conf
reload: no reload: false
# Set ip forwarding on in /proc and verify token value with the sysctl command # Set ip forwarding on in /proc and verify token value with the sysctl command
- ansible.posix.sysctl: - ansible.posix.sysctl:
name: net.ipv4.ip_forward name: net.ipv4.ip_forward
value: '1' value: '1'
sysctl_set: yes sysctl_set: true
# Set ip forwarding on in /proc and in the sysctl file and reload if necessary # Set ip forwarding on in /proc and in the sysctl file and reload if necessary
- ansible.posix.sysctl: - ansible.posix.sysctl:
name: net.ipv4.ip_forward name: net.ipv4.ip_forward
value: '1' value: '1'
sysctl_set: yes sysctl_set: true
state: present state: present
reload: yes reload: true

View file

@ -1,6 +1,7 @@
---
namespace: ansible namespace: ansible
name: posix name: posix
version: 1.4.0 version: 1.5.4
readme: README.md readme: README.md
authors: authors:
- Ansible (github.com/ansible) - Ansible (github.com/ansible)

View file

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

View file

@ -177,7 +177,7 @@ class ActionModule(ActionBase):
# Store remote connection type # Store remote connection type
self._remote_transport = self._connection.transport self._remote_transport = self._connection.transport
use_ssh_args = _tmp_args.pop('use_ssh_args', None) use_ssh_args = _tmp_args.pop('use_ssh_args', False)
if use_ssh_args and self._connection.transport == 'ssh': if use_ssh_args and self._connection.transport == 'ssh':
ssh_args = [ ssh_args = [
@ -185,7 +185,7 @@ class ActionModule(ActionBase):
self._connection.get_option('ssh_common_args'), self._connection.get_option('ssh_common_args'),
self._connection.get_option('ssh_extra_args'), self._connection.get_option('ssh_extra_args'),
] ]
_tmp_args['ssh_args'] = ' '.join([a for a in ssh_args if a]) _tmp_args['_ssh_args'] = ' '.join([a for a in ssh_args if a])
# Handle docker connection options # Handle docker connection options
if self._remote_transport in DOCKER: if self._remote_transport in DOCKER:
@ -225,7 +225,6 @@ class ActionModule(ActionBase):
# Parameter name needed by the ansible module # Parameter name needed by the ansible module
_tmp_args['_local_rsync_path'] = task_vars.get('ansible_rsync_path') or 'rsync' _tmp_args['_local_rsync_path'] = task_vars.get('ansible_rsync_path') or 'rsync'
_tmp_args['_local_rsync_password'] = task_vars.get('ansible_ssh_pass') or task_vars.get('ansible_password')
# rsync thinks that one end of the connection is localhost and the # rsync thinks that one end of the connection is localhost and the
# other is the host we're running the task for (Note: We use # other is the host we're running the task for (Note: We use
@ -333,8 +332,9 @@ class ActionModule(ActionBase):
if src is None or dest is None: if src is None or dest is None:
return dict(failed=True, msg="synchronize requires both src and dest parameters are set") return dict(failed=True, msg="synchronize requires both src and dest parameters are set")
# Determine if we need a user@ # Determine if we need a user@ and a password
user = None user = None
password = task_vars.get('ansible_ssh_pass', None) or task_vars.get('ansible_password', None)
if not dest_is_local: if not dest_is_local:
# Src and dest rsync "path" handling # Src and dest rsync "path" handling
if boolean(_tmp_args.get('set_remote_user', 'yes'), strict=False): if boolean(_tmp_args.get('set_remote_user', 'yes'), strict=False):
@ -344,10 +344,12 @@ class ActionModule(ActionBase):
user = task_vars.get('ansible_user') or self._play_context.remote_user user = task_vars.get('ansible_user') or self._play_context.remote_user
if not user: if not user:
user = C.DEFAULT_REMOTE_USER user = C.DEFAULT_REMOTE_USER
else: else:
user = task_vars.get('ansible_user') or self._play_context.remote_user user = task_vars.get('ansible_user') or self._play_context.remote_user
if self._templar is not None:
user = self._templar.template(user)
# Private key handling # Private key handling
# Use the private_key parameter if passed else use context private_key_file # Use the private_key parameter if passed else use context private_key_file
_tmp_args['private_key'] = _tmp_args.get('private_key', self._play_context.private_key_file) _tmp_args['private_key'] = _tmp_args.get('private_key', self._play_context.private_key_file)
@ -361,12 +363,17 @@ class ActionModule(ActionBase):
# src is a local path, dest is a remote path: <user>@<host> # src is a local path, dest is a remote path: <user>@<host>
src = self._process_origin(src_host, src, user) src = self._process_origin(src_host, src, user)
dest = self._process_remote(_tmp_args, dest_host, dest, user, inv_port in localhost_ports) dest = self._process_remote(_tmp_args, dest_host, dest, user, inv_port in localhost_ports)
password = dest_host_inventory_vars.get('ansible_ssh_pass', None) or dest_host_inventory_vars.get('ansible_password', None)
if self._templar is not None:
password = self._templar.template(password)
else: else:
# Still need to munge paths (to account for roles) even if we aren't # Still need to munge paths (to account for roles) even if we aren't
# copying files between hosts # copying files between hosts
src = self._get_absolute_path(path=src) src = self._get_absolute_path(path=src)
dest = self._get_absolute_path(path=dest) dest = self._get_absolute_path(path=dest)
_tmp_args['_local_rsync_password'] = password
_tmp_args['src'] = src _tmp_args['src'] = src
_tmp_args['dest'] = dest _tmp_args['dest'] = dest

View file

@ -25,6 +25,16 @@ DOCUMENTATION = '''
- key: show_custom_stats - key: show_custom_stats
section: defaults section: defaults
type: bool type: bool
json_indent:
name: Use indenting for the JSON output
description: 'If specified, use this many spaces for indenting in the JSON output. If <= 0, write to a single line.'
default: 4
env:
- name: ANSIBLE_JSON_INDENT
ini:
- key: json_indent
section: defaults
type: integer
notes: notes:
- When using a strategy such as free, host_pinned, or a custom strategy, host results will - When using a strategy such as free, host_pinned, or a custom strategy, host results will
be added to new task results in ``.plays[].tasks[]``. As such, there will exist duplicate be added to new task results in ``.plays[].tasks[]``. As such, there will exist duplicate
@ -61,12 +71,19 @@ class CallbackModule(CallbackBase):
self._task_map = {} self._task_map = {}
self._is_lockstep = False self._is_lockstep = False
self.set_options()
self._json_indent = self.get_option('json_indent')
if self._json_indent <= 0:
self._json_indent = None
def _new_play(self, play): def _new_play(self, play):
self._is_lockstep = play.strategy in LOCKSTEP_CALLBACKS self._is_lockstep = play.strategy in LOCKSTEP_CALLBACKS
return { return {
'play': { 'play': {
'name': play.get_name(), 'name': play.get_name(),
'id': to_text(play._uuid), 'id': to_text(play._uuid),
'path': to_text(play.get_path()),
'duration': { 'duration': {
'start': current_time() 'start': current_time()
} }
@ -79,6 +96,7 @@ class CallbackModule(CallbackBase):
'task': { 'task': {
'name': task.get_name(), 'name': task.get_name(),
'id': to_text(task._uuid), 'id': to_text(task._uuid),
'path': to_text(task.get_path()),
'duration': { 'duration': {
'start': current_time() 'start': current_time()
} }
@ -143,7 +161,7 @@ class CallbackModule(CallbackBase):
'global_custom_stats': global_custom_stats, 'global_custom_stats': global_custom_stats,
} }
self._display.display(json.dumps(output, cls=AnsibleJSONEncoder, indent=4, sort_keys=True)) self._display.display(json.dumps(output, cls=AnsibleJSONEncoder, indent=self._json_indent, sort_keys=True))
def _record_task_result(self, on_info, result, **kwargs): def _record_task_result(self, on_info, result, **kwargs):
"""This function is used as a partial to add failed/skipped info in a single method""" """This function is used as a partial to add failed/skipped info in a single method"""

214
plugins/callback/jsonl.py Normal file
View file

@ -0,0 +1,214 @@
# (c) 2016, Matt Martz <matt@sivel.net>
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
name: jsonl
short_description: Ansible screen output as JSONL (lines in json format)
description:
- This callback converts all events into JSON output to stdout
- This callback in contrast with ansible.posix.json uses less memory, because it doesn't store results.
type: stdout
requirements:
- Set as stdout in config
options:
show_custom_stats:
name: Show custom stats
description: 'This adds the custom stats set via the set_stats plugin to the play recap'
default: False
env:
- name: ANSIBLE_SHOW_CUSTOM_STATS
ini:
- key: show_custom_stats
section: defaults
type: bool
json_indent:
name: Use indenting for the JSON output
description: 'If specified, use this many spaces for indenting in the JSON output. If not specified or <= 0, write to a single line.'
default: 0
env:
- name: ANSIBLE_JSON_INDENT
ini:
- key: json_indent
section: defaults
type: integer
notes:
- When using a strategy such as free, host_pinned, or a custom strategy, host results will
be added to new task results in ``.plays[].tasks[]``. As such, there will exist duplicate
task objects indicated by duplicate task IDs at ``.plays[].tasks[].task.id``, each with an
individual host result for the task.
'''
import datetime
import json
import copy
from functools import partial
from ansible.inventory.host import Host
from ansible.module_utils._text import to_text
from ansible.parsing.ajson import AnsibleJSONEncoder
from ansible.plugins.callback import CallbackBase
LOCKSTEP_CALLBACKS = frozenset(('linear', 'debug'))
def current_time():
return '%sZ' % datetime.datetime.utcnow().isoformat()
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'stdout'
CALLBACK_NAME = 'ansible.posix.jsonl'
def __init__(self, display=None):
super(CallbackModule, self).__init__(display)
self.results = []
self._task_map = {}
self._is_lockstep = False
self.set_options()
self._json_indent = self.get_option('json_indent')
if self._json_indent <= 0:
self._json_indent = None
def _new_play(self, play):
self._is_lockstep = play.strategy in LOCKSTEP_CALLBACKS
return {
'play': {
'name': play.get_name(),
'id': to_text(play._uuid),
'path': to_text(play.get_path()),
'duration': {
'start': current_time()
}
},
'tasks': []
}
def _new_task(self, task):
return {
'task': {
'name': task.get_name(),
'id': to_text(task._uuid),
'path': to_text(task.get_path()),
'duration': {
'start': current_time()
}
},
'hosts': {}
}
def _find_result_task(self, host, task):
key = (host.get_name(), task._uuid)
return self._task_map.get(
key,
self.results[-1]['tasks'][-1]
)
def v2_playbook_on_play_start(self, play):
play_result = self._new_play(play)
self.results.append(play_result)
self._write_event('v2_playbook_on_play_start', play_result)
def v2_runner_on_start(self, host, task):
if self._is_lockstep:
return
key = (host.get_name(), task._uuid)
task_result = self._new_task(task)
self._task_map[key] = task_result
self.results[-1]['tasks'].append(task_result)
self._write_event('v2_runner_on_start', task_result)
def v2_playbook_on_task_start(self, task, is_conditional):
if not self._is_lockstep:
return
task_result = self._new_task(task)
self.results[-1]['tasks'].append(task_result)
self._write_event('v2_playbook_on_task_start', task_result)
def v2_playbook_on_handler_task_start(self, task):
if not self._is_lockstep:
return
task_result = self._new_task(task)
self.results[-1]['tasks'].append(task_result)
self._write_event('v2_playbook_on_handler_task_start', task_result)
def _convert_host_to_name(self, key):
if isinstance(key, (Host,)):
return key.get_name()
return key
def v2_playbook_on_stats(self, stats):
"""Display info about playbook statistics"""
hosts = sorted(stats.processed.keys())
summary = {}
for h in hosts:
s = stats.summarize(h)
summary[h] = s
custom_stats = {}
global_custom_stats = {}
if self.get_option('show_custom_stats') and stats.custom:
custom_stats.update(dict((self._convert_host_to_name(k), v) for k, v in stats.custom.items()))
global_custom_stats.update(custom_stats.pop('_run', {}))
output = {
'stats': summary,
'custom_stats': custom_stats,
'global_custom_stats': global_custom_stats,
}
self._write_event('v2_playbook_on_stats', output)
def _write_event(self, event_name, output):
output['_event'] = event_name
output['_timestamp'] = current_time()
self._display.display(json.dumps(output, cls=AnsibleJSONEncoder, indent=self._json_indent, separators=',:', sort_keys=True))
def _record_task_result(self, event_name, on_info, result, **kwargs):
"""This function is used as a partial to add failed/skipped info in a single method"""
host = result._host
task = result._task
result_copy = result._result.copy()
result_copy.update(on_info)
result_copy['action'] = task.action
task_result = self._find_result_task(host, task)
end_time = current_time()
task_result['task']['duration']['end'] = end_time
self.results[-1]['play']['duration']['end'] = end_time
task_result_copy = copy.deepcopy(task_result)
task_result_copy['hosts'][host.name] = result_copy
if not self._is_lockstep:
key = (host.get_name(), task._uuid)
del self._task_map[key]
self._write_event(event_name, task_result_copy)
def __getattribute__(self, name):
"""Return ``_record_task_result`` partial with a dict containing skipped/failed if necessary"""
if name not in ('v2_runner_on_ok', 'v2_runner_on_failed', 'v2_runner_on_unreachable', 'v2_runner_on_skipped'):
return object.__getattribute__(self, name)
on = name.rsplit('_', 1)[1]
on_info = {}
if on in ('failed', 'skipped'):
on_info[on] = True
return partial(self._record_task_result, name, on_info)

View file

@ -17,11 +17,11 @@ DOCUMENTATION = '''
- Ansible callback plugin for timing individual tasks and overall execution time. - Ansible callback plugin for timing individual tasks and overall execution time.
- "Mashup of 2 excellent original works: https://github.com/jlafon/ansible-profile, - "Mashup of 2 excellent original works: https://github.com/jlafon/ansible-profile,
https://github.com/junaid18183/ansible_home/blob/master/ansible_plugins/callback_plugins/timestamp.py.old" https://github.com/junaid18183/ansible_home/blob/master/ansible_plugins/callback_plugins/timestamp.py.old"
- "Format: C(<task start timestamp> (<length of previous task>) <current elapsed playbook execution time>)" - "Format: C(<task start timestamp>) C(<length of previous task>) C(<current elapsed playbook execution time>)"
- It also lists the top/bottom time consuming tasks in the summary (configurable) - It also lists the top/bottom time consuming tasks in the summary (configurable)
- Before 2.4 only the environment variables were available for configuration. - Before 2.4 only the environment variables were available for configuration.
requirements: requirements:
- whitelisting in configuration - see examples section below for details. - enable in configuration - see examples section below for details.
options: options:
output_limit: output_limit:
description: Number of tasks to display in the summary description: Number of tasks to display in the summary
@ -46,7 +46,7 @@ EXAMPLES = '''
example: > example: >
To enable, add this to your ansible.cfg file in the defaults block To enable, add this to your ansible.cfg file in the defaults block
[defaults] [defaults]
callback_whitelist = ansible.posix.profile_tasks callbacks_enabled=ansible.posix.profile_tasks
sample output: > sample output: >
# #
# TASK: [ensure messaging security group exists] ******************************** # TASK: [ensure messaging security group exists] ********************************

View file

@ -0,0 +1,45 @@
# Copyright (c) 2023 Maxwell G <maxwell@gtmx.me>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""
Helpers to respawn a module to run using the system interpreter
"""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
try:
from ansible.module_utils.common import respawn
except ImportError:
HAS_RESPAWN_UTIL = False
else:
HAS_RESPAWN_UTIL = True
SYSTEM_PYTHON_INTERPRETERS = (
"/usr/bin/libexec/platform-python",
"/usr/bin/python3",
"/usr/bin/python2",
"/usr/bin/python",
)
def respawn_module(module):
"""
Respawn an ansible module to using the first interpreter in
SYSTEM_PYTHON_INTERPRETERS that contains `module`.
Args:
module (str): Name of python module to search for
Returns:
Returns None if the module cannot be respawned.
"""
if respawn.has_respawned():
return
interpreter = respawn.probe_interpreters_for_module(
SYSTEM_PYTHON_INTERPRETERS, module
)
if interpreter:
respawn.respawn_module(interpreter)

View file

@ -5,6 +5,8 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
from ansible_collections.ansible.posix.plugins.module_utils.version import LooseVersion from ansible_collections.ansible.posix.plugins.module_utils.version import LooseVersion
from ansible_collections.ansible.posix.plugins.module_utils._respawn import respawn_module, HAS_RESPAWN_UTIL
from ansible.module_utils.basic import missing_required_lib
__metaclass__ = type __metaclass__ = type
@ -313,7 +315,8 @@ class FirewallTransaction(object):
installed version (%s) likely too old. Requires firewalld >= 0.2.11" % FW_VERSION) installed version (%s) likely too old. Requires firewalld >= 0.2.11" % FW_VERSION)
if import_failure: if import_failure:
if HAS_RESPAWN_UTIL:
respawn_module("firewall")
module.fail_json( module.fail_json(
msg='Python Module not found: firewalld and its python module are required for this module, \ msg=missing_required_lib('firewall') + '. Version 0.2.11 or newer required (0.3.9 or newer for offline operations)'
version 0.2.11 or newer required (0.3.9 or newer for offline operations)'
) )

View file

@ -16,3 +16,5 @@ __metaclass__ = type
# from ansible.module_utils.compat.version import LooseVersion # from ansible.module_utils.compat.version import LooseVersion
from ._version import LooseVersion, StrictVersion from ._version import LooseVersion, StrictVersion
__all__ = ['LooseVersion', 'StrictVersion']

View file

@ -20,7 +20,7 @@ options:
description: description:
- The full path of the file or object. - The full path of the file or object.
type: path type: path
required: yes required: true
aliases: [ name ] aliases: [ name ]
state: state:
description: description:
@ -33,17 +33,18 @@ options:
description: description:
- Whether to follow symlinks on the path if a symlink is encountered. - Whether to follow symlinks on the path if a symlink is encountered.
type: bool type: bool
default: yes default: true
default: default:
description: description:
- If the target is a directory, setting this to C(yes) will make it the default ACL for entities created inside the directory. - If the target is a directory, setting this to C(true) will make it the default ACL for entities created inside the directory.
- Setting C(default) to C(yes) causes an error if the path is a file. - Setting C(default) to C(true) causes an error if the path is a file.
type: bool type: bool
default: no default: false
entity: entity:
description: description:
- The actual user or group that the ACL applies to when matching entity types user or group are selected. - The actual user or group that the ACL applies to when matching entity types user or group are selected.
type: str type: str
default: ""
etype: etype:
description: description:
- The entity type of the ACL to apply, see C(setfacl) documentation for more info. - The entity type of the ACL to apply, see C(setfacl) documentation for more info.
@ -69,13 +70,13 @@ options:
- Incompatible with C(state=query). - Incompatible with C(state=query).
- Alias C(recurse) added in version 1.3.0. - Alias C(recurse) added in version 1.3.0.
type: bool type: bool
default: no default: false
aliases: [ recurse ] aliases: [ recurse ]
use_nfsv4_acls: use_nfsv4_acls:
description: description:
- Use NFSv4 ACLs instead of POSIX ACLs. - Use NFSv4 ACLs instead of POSIX ACLs.
type: bool type: bool
default: no default: false
recalculate_mask: recalculate_mask:
description: description:
- Select if and when to recalculate the effective right masks of the files. - Select if and when to recalculate the effective right masks of the files.
@ -115,7 +116,7 @@ EXAMPLES = r'''
entity: joe entity: joe
etype: user etype: user
permissions: rw permissions: rw
default: yes default: true
state: present state: present
- name: Same as previous but using entry shorthand - name: Same as previous but using entry shorthand

View file

@ -44,7 +44,7 @@ options:
description: description:
- If a matching job is present a new job will not be added. - If a matching job is present a new job will not be added.
type: bool type: bool
default: no default: false
requirements: requirements:
- at - at
author: author:
@ -68,7 +68,7 @@ EXAMPLES = r'''
command: ls -d / >/dev/null command: ls -d / >/dev/null
count: 20 count: 20
units: minutes units: minutes
unique: yes unique: true
''' '''
import os import os

View file

@ -34,13 +34,13 @@ options:
manage_dir: manage_dir:
description: description:
- Whether this module should manage the directory of the authorized key file. - Whether this module should manage the directory of the authorized key file.
- If set to C(yes), the module will create the directory, as well as set the owner and permissions - If set to C(true), the module will create the directory, as well as set the owner and permissions
of an existing directory. of an existing directory.
- Be sure to set C(manage_dir=no) if you are using an alternate directory for authorized_keys, - Be sure to set C(manage_dir=false) if you are using an alternate directory for authorized_keys,
as set with C(path), since you could lock yourself out of SSH access. as set with C(path), since you could lock yourself out of SSH access.
- See the example below. - See the example below.
type: bool type: bool
default: yes default: true
state: state:
description: description:
- Whether the given key (with the given key_options) should or should not be in the file. - Whether the given key (with the given key_options) should or should not be in the file.
@ -58,15 +58,15 @@ options:
- This option is not loop aware, so if you use C(with_) , it will be exclusive per iteration of the loop. - This option is not loop aware, so if you use C(with_) , it will be exclusive per iteration of the loop.
- If you want multiple keys in the file you need to pass them all to C(key) in a single batch as mentioned above. - If you want multiple keys in the file you need to pass them all to C(key) in a single batch as mentioned above.
type: bool type: bool
default: no default: false
validate_certs: validate_certs:
description: description:
- This only applies if using a https url as the source of the keys. - This only applies if using a https url as the source of the keys.
- If set to C(no), the SSL certificates will not be validated. - If set to C(false), the SSL certificates will not be validated.
- This should only set to C(no) used on personally controlled sites using self-signed certificates as it avoids verifying the source site. - This should only set to C(false) used on personally controlled sites using self-signed certificates as it avoids verifying the source site.
- Prior to 2.1 the code worked as if this was set to C(yes). - Prior to 2.1 the code worked as if this was set to C(true).
type: bool type: bool
default: yes default: true
comment: comment:
description: description:
- Change the comment on the public key. - Change the comment on the public key.
@ -77,7 +77,7 @@ options:
description: description:
- Follow path symlink instead of replacing it. - Follow path symlink instead of replacing it.
type: bool type: bool
default: no default: false
author: Ansible Core Team author: Ansible Core Team
''' '''
@ -106,7 +106,7 @@ EXAMPLES = r'''
state: present state: present
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
path: /etc/ssh/authorized_keys/charlie path: /etc/ssh/authorized_keys/charlie
manage_dir: False manage_dir: false
- name: Set up multiple authorized keys - name: Set up multiple authorized keys
ansible.posix.authorized_key: ansible.posix.authorized_key:
@ -129,14 +129,14 @@ EXAMPLES = r'''
user: charlie user: charlie
state: present state: present
key: https://github.com/user.keys key: https://github.com/user.keys
validate_certs: False validate_certs: false
- name: Set authorized key, removing all the authorized keys already set - name: Set authorized key, removing all the authorized keys already set
ansible.posix.authorized_key: ansible.posix.authorized_key:
user: root user: root
key: "{{ lookup('file', 'public_keys/doe-jane') }}" key: "{{ lookup('file', 'public_keys/doe-jane') }}"
state: present state: present
exclusive: True exclusive: true
- name: Set authorized key for user ubuntu copying it from current user - name: Set authorized key for user ubuntu copying it from current user
ansible.posix.authorized_key: ansible.posix.authorized_key:
@ -150,7 +150,7 @@ exclusive:
description: If the key has been forced to be exclusive or not. description: If the key has been forced to be exclusive or not.
returned: success returned: success
type: bool type: bool
sample: False sample: false
key: key:
description: The key that the module was running against. description: The key that the module was running against.
returned: success returned: success
@ -170,7 +170,7 @@ manage_dir:
description: Whether this module managed the directory of the authorized key file. description: Whether this module managed the directory of the authorized key file.
returned: success returned: success
type: bool type: bool
sample: True sample: true
path: path:
description: Alternate path to the authorized_keys file description: Alternate path to the authorized_keys file
returned: success returned: success
@ -192,7 +192,7 @@ user:
type: str type: str
sample: user sample: user
validate_certs: validate_certs:
description: This only applies if using a https url as the source of the keys. If set to C(no), the SSL certificates will not be validated. description: This only applies if using a https url as the source of the keys. If set to C(false), the SSL certificates will not be validated.
returned: success returned: success
type: bool type: bool
sample: true sample: true
@ -347,6 +347,8 @@ def keyfile(module, user, write=False, path=None, manage_dir=True, follow=False)
basedir = os.path.dirname(keysfile) basedir = os.path.dirname(keysfile)
if not os.path.exists(basedir): if not os.path.exists(basedir):
os.makedirs(basedir) os.makedirs(basedir)
f = None
try: try:
f = open(keysfile, "w") # touches file so we can set ownership and perms f = open(keysfile, "w") # touches file so we can set ownership and perms
finally: finally:

View file

@ -19,6 +19,10 @@ options:
- Name of a service to add/remove to/from firewalld. - Name of a service to add/remove to/from firewalld.
- The service must be listed in output of firewall-cmd --get-services. - The service must be listed in output of firewall-cmd --get-services.
type: str type: str
protocol:
description:
- Name of a protocol to add/remove to/from firewalld.
type: str
port: port:
description: description:
- Name of a port or port range to add/remove to/from firewalld. - Name of a port or port range to add/remove to/from firewalld.
@ -80,15 +84,17 @@ options:
type: str type: str
permanent: permanent:
description: description:
- Should this configuration be in the running firewalld configuration or persist across reboots. - Whether to apply this change to the permanent firewalld configuration.
- As of Ansible 2.3, permanent operations can operate on firewalld configs when it is not running (requires firewalld >= 0.3.9). - As of Ansible 2.3, permanent operations can operate on firewalld configs when it is not running (requires firewalld >= 0.3.9).
- Note that if this is C(no), immediate is assumed C(yes). - Note that if this is C(false), I(immediate) defaults to C(true).
type: bool type: bool
default: false
immediate: immediate:
description: description:
- Should this configuration be applied immediately, if set as permanent. - Whether to apply this change to the runtime firewalld configuration.
- Defaults to C(true) if I(permanent=false).
type: bool type: bool
default: no default: false
state: state:
description: description:
- Enable or disable a setting. - Enable or disable a setting.
@ -108,8 +114,9 @@ options:
type: str type: str
offline: offline:
description: description:
- Whether to run this module even when firewalld is offline. - Ignores I(immediate) if I(permanent=true) and firewalld is not running.
type: bool type: bool
default: false
target: target:
description: description:
- firewalld Zone target - firewalld Zone target
@ -138,32 +145,46 @@ author:
''' '''
EXAMPLES = r''' EXAMPLES = r'''
- name: permanently enable https service, also enable it immediately if possible
ansible.posix.firewalld:
service: https
state: enabled
permanent: true
immediate: true
offline: true
- name: permit traffic in default zone for https service - name: permit traffic in default zone for https service
ansible.posix.firewalld: ansible.posix.firewalld:
service: https service: https
permanent: yes permanent: true
state: enabled
- name: permit ospf traffic
ansible.posix.firewalld:
protocol: ospf
permanent: true
state: enabled state: enabled
- name: do not permit traffic in default zone on port 8081/tcp - name: do not permit traffic in default zone on port 8081/tcp
ansible.posix.firewalld: ansible.posix.firewalld:
port: 8081/tcp port: 8081/tcp
permanent: yes permanent: true
state: disabled state: disabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
port: 161-162/udp port: 161-162/udp
permanent: yes permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: dmz zone: dmz
service: http service: http
permanent: yes permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
rich_rule: rule service name="ftp" audit limit value="1/m" accept rich_rule: rule service name="ftp" audit limit value="1/m" accept
permanent: yes permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
@ -174,44 +195,44 @@ EXAMPLES = r'''
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: trusted zone: trusted
interface: eth2 interface: eth2
permanent: yes permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - ansible.posix.firewalld:
masquerade: yes masquerade: true
state: enabled state: enabled
permanent: yes permanent: true
zone: dmz zone: dmz
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: custom zone: custom
state: present state: present
permanent: yes permanent: true
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: drop zone: drop
state: enabled state: enabled
permanent: yes permanent: true
icmp_block_inversion: yes icmp_block_inversion: true
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: drop zone: drop
state: enabled state: enabled
permanent: yes permanent: true
icmp_block: echo-request icmp_block: echo-request
- ansible.posix.firewalld: - ansible.posix.firewalld:
zone: internal zone: internal
state: present state: present
permanent: yes permanent: true
target: ACCEPT target: ACCEPT
- name: Redirect port 443 to 8443 with Rich Rule - name: Redirect port 443 to 8443 with Rich Rule
ansible.posix.firewalld: ansible.posix.firewalld:
rich_rule: rule family=ipv4 forward-port port=443 protocol=tcp to-port=8443 rich_rule: rule family=ipv4 forward-port port=443 protocol=tcp to-port=8443
zone: public zone: public
permanent: yes permanent: true
immediate: yes immediate: true
state: enabled state: enabled
''' '''
@ -343,6 +364,47 @@ class ServiceTransaction(FirewallTransaction):
self.update_fw_settings(fw_zone, fw_settings) self.update_fw_settings(fw_zone, fw_settings)
class ProtocolTransaction(FirewallTransaction):
"""
ProtocolTransaction
"""
def __init__(self, module, action_args=None, zone=None, desired_state=None, permanent=False, immediate=False):
super(ProtocolTransaction, self).__init__(
module, action_args=action_args, desired_state=desired_state, zone=zone, permanent=permanent, immediate=immediate
)
def get_enabled_immediate(self, protocol, timeout):
if protocol in self.fw.getProtocols(self.zone):
return True
else:
return False
def get_enabled_permanent(self, protocol, timeout):
fw_zone, fw_settings = self.get_fw_zone_settings()
if protocol in fw_settings.getProtocols():
return True
else:
return False
def set_enabled_immediate(self, protocol, timeout):
self.fw.addProtocol(self.zone, protocol, timeout)
def set_enabled_permanent(self, protocol, timeout):
fw_zone, fw_settings = self.get_fw_zone_settings()
fw_settings.addProtocol(protocol)
self.update_fw_settings(fw_zone, fw_settings)
def set_disabled_immediate(self, protocol, timeout):
self.fw.removeProtocol(self.zone, protocol)
def set_disabled_permanent(self, protocol, timeout):
fw_zone, fw_settings = self.get_fw_zone_settings()
fw_settings.removeProtocol(protocol)
self.update_fw_settings(fw_zone, fw_settings)
class MasqueradeTransaction(FirewallTransaction): class MasqueradeTransaction(FirewallTransaction):
""" """
MasqueradeTransaction MasqueradeTransaction
@ -469,6 +531,7 @@ class InterfaceTransaction(FirewallTransaction):
old_zone_obj = self.fw.config.get_zone(zone) old_zone_obj = self.fw.config.get_zone(zone)
if interface in old_zone_obj.interfaces: if interface in old_zone_obj.interfaces:
iface_zone_objs.append(old_zone_obj) iface_zone_objs.append(old_zone_obj)
if len(iface_zone_objs) > 1: if len(iface_zone_objs) > 1:
# Even it shouldn't happen, it's actually possible that # Even it shouldn't happen, it's actually possible that
# the same interface is in several zone XML files # the same interface is in several zone XML files
@ -478,18 +541,17 @@ class InterfaceTransaction(FirewallTransaction):
len(iface_zone_objs) len(iface_zone_objs)
) )
) )
old_zone_obj = iface_zone_objs[0] elif len(iface_zone_objs) == 1 and iface_zone_objs[0].name != self.zone:
if old_zone_obj.name != self.zone: old_zone_obj = iface_zone_objs[0]
old_zone_settings = FirewallClientZoneSettings( old_zone_config = self.fw.config.get_zone_config(old_zone_obj)
self.fw.config.get_zone_config(old_zone_obj) old_zone_settings = FirewallClientZoneSettings(list(old_zone_config))
)
old_zone_settings.removeInterface(interface) # remove from old old_zone_settings.removeInterface(interface) # remove from old
self.fw.config.set_zone_config( self.fw.config.set_zone_config(
old_zone_obj, old_zone_obj,
old_zone_settings.settings old_zone_settings.settings
) )
fw_settings.addInterface(interface) # add to new fw_settings.addInterface(interface) # add to new
self.fw.config.set_zone_config(fw_zone, fw_settings.settings) self.fw.config.set_zone_config(fw_zone, fw_settings.settings)
else: else:
old_zone_name = self.fw.config().getZoneOfInterface(interface) old_zone_name = self.fw.config().getZoneOfInterface(interface)
if old_zone_name != self.zone: if old_zone_name != self.zone:
@ -675,25 +737,33 @@ class ZoneTransaction(FirewallTransaction):
self.module.fail_json(msg=self.tx_not_permanent_error_msg) self.module.fail_json(msg=self.tx_not_permanent_error_msg)
def get_enabled_permanent(self): def get_enabled_permanent(self):
zones = self.fw.config().listZones() if self.fw_offline:
zone_names = [self.fw.config().getZone(z).get_property("name") for z in zones] zones = self.fw.config.get_zones()
if self.zone in zone_names: zone_names = [self.fw.config.get_zone(z).name for z in zones]
return True
else: else:
return False zones = self.fw.config().listZones()
zone_names = [self.fw.config().getZone(z).get_property("name") for z in zones]
return self.zone in zone_names
def set_enabled_immediate(self): def set_enabled_immediate(self):
self.module.fail_json(msg=self.tx_not_permanent_error_msg) self.module.fail_json(msg=self.tx_not_permanent_error_msg)
def set_enabled_permanent(self): def set_enabled_permanent(self):
self.fw.config().addZone(self.zone, FirewallClientZoneSettings()) if self.fw_offline:
self.fw.config.new_zone(self.zone, FirewallClientZoneSettings().settings)
else:
self.fw.config().addZone(self.zone, FirewallClientZoneSettings())
def set_disabled_immediate(self): def set_disabled_immediate(self):
self.module.fail_json(msg=self.tx_not_permanent_error_msg) self.module.fail_json(msg=self.tx_not_permanent_error_msg)
def set_disabled_permanent(self): def set_disabled_permanent(self):
zone_obj = self.fw.config().getZoneByName(self.zone) if self.fw_offline:
zone_obj.remove() zone = self.fw.config.get_zone(self.zone)
self.fw.config.remove_zone(zone)
else:
zone_obj = self.fw.config().getZoneByName(self.zone)
zone_obj.remove()
class ForwardPortTransaction(FirewallTransaction): class ForwardPortTransaction(FirewallTransaction):
@ -740,18 +810,19 @@ def main():
icmp_block=dict(type='str'), icmp_block=dict(type='str'),
icmp_block_inversion=dict(type='str'), icmp_block_inversion=dict(type='str'),
service=dict(type='str'), service=dict(type='str'),
protocol=dict(type='str'),
port=dict(type='str'), port=dict(type='str'),
port_forward=dict(type='list', elements='dict'), port_forward=dict(type='list', elements='dict'),
rich_rule=dict(type='str'), rich_rule=dict(type='str'),
zone=dict(type='str'), zone=dict(type='str'),
immediate=dict(type='bool', default=False), immediate=dict(type='bool', default=False),
source=dict(type='str'), source=dict(type='str'),
permanent=dict(type='bool'), permanent=dict(type='bool', default=False),
state=dict(type='str', required=True, choices=['absent', 'disabled', 'enabled', 'present']), state=dict(type='str', required=True, choices=['absent', 'disabled', 'enabled', 'present']),
timeout=dict(type='int', default=0), timeout=dict(type='int', default=0),
interface=dict(type='str'), interface=dict(type='str'),
masquerade=dict(type='str'), masquerade=dict(type='str'),
offline=dict(type='bool'), offline=dict(type='bool', default=False),
target=dict(type='str', choices=['default', 'ACCEPT', 'DROP', '%%REJECT%%']), target=dict(type='str', choices=['default', 'ACCEPT', 'DROP', '%%REJECT%%']),
), ),
supports_check_mode=True, supports_check_mode=True,
@ -761,7 +832,7 @@ def main():
source=('permanent',), source=('permanent',),
), ),
mutually_exclusive=[ mutually_exclusive=[
['icmp_block', 'icmp_block_inversion', 'service', 'port', 'port_forward', 'rich_rule', ['icmp_block', 'icmp_block_inversion', 'service', 'protocol', 'port', 'port_forward', 'rich_rule',
'interface', 'masquerade', 'source', 'target'] 'interface', 'masquerade', 'source', 'target']
], ],
) )
@ -772,38 +843,50 @@ def main():
timeout = module.params['timeout'] timeout = module.params['timeout']
interface = module.params['interface'] interface = module.params['interface']
masquerade = module.params['masquerade'] masquerade = module.params['masquerade']
offline = module.params['offline']
# Sanity checks # Sanity checks
FirewallTransaction.sanity_check(module) FirewallTransaction.sanity_check(module)
# If neither permanent or immediate is provided, assume immediate (as # `offline`, `immediate`, and `permanent` have a weird twisty relationship.
# written in the module's docs) if offline:
# specifying offline without permanent makes no sense
if not permanent:
module.fail_json(msg='offline cannot be enabled unless permanent changes are allowed')
# offline overrides immediate to false if firewalld is offline
if fw_offline:
immediate = False
# immediate defaults to true if permanent is not enabled
if not permanent and not immediate: if not permanent and not immediate:
immediate = True immediate = True
# Verify required params are provided
if immediate and fw_offline: if immediate and fw_offline:
module.fail_json(msg='firewall is not currently running, unable to perform immediate actions without a running firewall daemon') module.fail_json(msg='firewall is not currently running, unable to perform immediate actions without a running firewall daemon')
# Verify required params are provided
changed = False changed = False
msgs = [] msgs = []
icmp_block = module.params['icmp_block'] icmp_block = module.params['icmp_block']
icmp_block_inversion = module.params['icmp_block_inversion'] icmp_block_inversion = module.params['icmp_block_inversion']
service = module.params['service'] service = module.params['service']
protocol = module.params['protocol']
rich_rule = module.params['rich_rule'] rich_rule = module.params['rich_rule']
source = module.params['source'] source = module.params['source']
zone = module.params['zone'] zone = module.params['zone']
target = module.params['target'] target = module.params['target']
port = None
if module.params['port'] is not None: if module.params['port'] is not None:
if '/' in module.params['port']: if '/' in module.params['port']:
port, protocol = module.params['port'].strip().split('/') port, port_protocol = module.params['port'].strip().split('/')
else: else:
protocol = None port_protocol = None
if not protocol: if not port_protocol:
module.fail_json(msg='improper port format (missing protocol?)') module.fail_json(msg='improper port format (missing protocol?)')
else: else:
port = None port_protocol = None
port_forward_toaddr = '' port_forward_toaddr = ''
port_forward = None port_forward = None
@ -821,7 +904,7 @@ def main():
port_forward_toaddr = port_forward['toaddr'] port_forward_toaddr = port_forward['toaddr']
modification = False modification = False
if any([icmp_block, icmp_block_inversion, service, port, port_forward, rich_rule, if any([icmp_block, icmp_block_inversion, service, protocol, port, port_forward, rich_rule,
interface, masquerade, source, target]): interface, masquerade, source, target]):
modification = True modification = True
if modification and desired_state in ['absent', 'present'] and target is None: if modification and desired_state in ['absent', 'present'] and target is None:
@ -846,12 +929,21 @@ def main():
msgs.append("Changed icmp-block %s to %s" % (icmp_block, desired_state)) msgs.append("Changed icmp-block %s to %s" % (icmp_block, desired_state))
if icmp_block_inversion is not None: if icmp_block_inversion is not None:
# Type of icmp_block_inversion will be changed to boolean in a future release.
icmp_block_inversion_status = True
try:
icmp_block_inversion_status = boolean(icmp_block_inversion, True)
except TypeError:
module.warn('The value of the icmp_block_inversion option is "%s". '
'The type of the option will be changed from string to boolean in a future release. '
'To avoid unexpected behavior, please change the value to boolean.' % icmp_block_inversion)
expected_state = 'enabled' if (desired_state == 'enabled') == icmp_block_inversion_status else 'disabled'
transaction = IcmpBlockInversionTransaction( transaction = IcmpBlockInversionTransaction(
module, module,
action_args=(), action_args=(),
zone=zone, zone=zone,
desired_state=desired_state, desired_state=expected_state,
permanent=permanent, permanent=permanent,
immediate=immediate, immediate=immediate,
) )
@ -861,14 +953,6 @@ def main():
if changed is True: if changed is True:
msgs.append("Changed icmp-block-inversion %s to %s" % (icmp_block_inversion, desired_state)) msgs.append("Changed icmp-block-inversion %s to %s" % (icmp_block_inversion, desired_state))
# Type of icmp_block_inversion will be changed to boolean in a future release.
try:
boolean(icmp_block_inversion, True)
except TypeError:
module.warn('The value of the icmp_block_inversion option is "%s". '
'The type of the option will be changed from string to boolean in a future release. '
'To avoid unexpected behavior, please change the value to boolean.' % icmp_block_inversion)
if service is not None: if service is not None:
transaction = ServiceTransaction( transaction = ServiceTransaction(
@ -885,6 +969,22 @@ def main():
if changed is True: if changed is True:
msgs.append("Changed service %s to %s" % (service, desired_state)) msgs.append("Changed service %s to %s" % (service, desired_state))
if protocol is not None:
transaction = ProtocolTransaction(
module,
action_args=(protocol, timeout),
zone=zone,
desired_state=desired_state,
permanent=permanent,
immediate=immediate,
)
changed, transaction_msgs = transaction.run()
msgs = msgs + transaction_msgs
if changed is True:
msgs.append("Changed protocol %s to %s" % (protocol, desired_state))
if source is not None: if source is not None:
transaction = SourceTransaction( transaction = SourceTransaction(
@ -903,7 +1003,7 @@ def main():
transaction = PortTransaction( transaction = PortTransaction(
module, module,
action_args=(port, protocol, timeout), action_args=(port, port_protocol, timeout),
zone=zone, zone=zone,
desired_state=desired_state, desired_state=desired_state,
permanent=permanent, permanent=permanent,
@ -915,7 +1015,7 @@ def main():
if changed is True: if changed is True:
msgs.append( msgs.append(
"Changed port %s to %s" % ( "Changed port %s to %s" % (
"%s/%s" % (port, protocol), desired_state "%s/%s" % (port, port_protocol), desired_state
) )
) )
@ -973,12 +1073,21 @@ def main():
msgs = msgs + transaction_msgs msgs = msgs + transaction_msgs
if masquerade is not None: if masquerade is not None:
# Type of masquerade will be changed to boolean in a future release.
masquerade_status = True
try:
masquerade_status = boolean(masquerade, True)
except TypeError:
module.warn('The value of the masquerade option is "%s". '
'The type of the option will be changed from string to boolean in a future release. '
'To avoid unexpected behavior, please change the value to boolean.' % masquerade)
expected_state = 'enabled' if (desired_state == 'enabled') == masquerade_status else 'disabled'
transaction = MasqueradeTransaction( transaction = MasqueradeTransaction(
module, module,
action_args=(), action_args=(),
zone=zone, zone=zone,
desired_state=desired_state, desired_state=expected_state,
permanent=permanent, permanent=permanent,
immediate=immediate, immediate=immediate,
) )
@ -986,14 +1095,6 @@ def main():
changed, transaction_msgs = transaction.run() changed, transaction_msgs = transaction.run()
msgs = msgs + transaction_msgs msgs = msgs + transaction_msgs
# Type of masquerade will be changed to boolean in a future release.
try:
boolean(masquerade, True)
except TypeError:
module.warn('The value of the masquerade option is "%s". '
'The type of the option will be changed from string to boolean in a future release. '
'To avoid unexpected behavior, please change the value to boolean.' % masquerade)
if target is not None: if target is not None:
transaction = ZoneTargetTransaction( transaction = ZoneTargetTransaction(

View file

@ -17,7 +17,7 @@ options:
active_zones: active_zones:
description: Gather information about active zones. description: Gather information about active zones.
type: bool type: bool
default: no default: false
zones: zones:
description: description:
- Gather information about specific zones. - Gather information about specific zones.
@ -36,7 +36,12 @@ author:
EXAMPLES = r''' EXAMPLES = r'''
- name: Gather information about active zones - name: Gather information about active zones
ansible.posix.firewalld_info: ansible.posix.firewalld_info:
active_zones: yes active_zones: true
register: result
- name: Print default zone for debugging
ansible.builtin.debug:
var: result.firewalld_info.default_zone
- name: Gather information about specific zones - name: Gather information about specific zones
ansible.posix.firewalld_info: ansible.posix.firewalld_info:
@ -44,6 +49,7 @@ EXAMPLES = r'''
- public - public
- external - external
- internal - internal
register: result
''' '''
RETURN = r''' RETURN = r'''
@ -78,7 +84,7 @@ firewalld_info:
returned: success returned: success
type: str type: str
sample: 0.8.2 sample: 0.8.2
default_zones: default_zone:
description: description:
- The zone name of default zone. - The zone name of default zone.
returned: success returned: success
@ -204,8 +210,8 @@ firewalld_info:
''' '''
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.six import raise_from
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
from ansible_collections.ansible.posix.plugins.module_utils._respawn import respawn_module, HAS_RESPAWN_UTIL
from ansible_collections.ansible.posix.plugins.module_utils.version import StrictVersion from ansible_collections.ansible.posix.plugins.module_utils.version import StrictVersion
@ -317,6 +323,12 @@ def main():
) )
# Exit with failure message if requirements modules are not installed. # Exit with failure message if requirements modules are not installed.
if not HAS_DBUS and not HAS_FIREWALLD and HAS_RESPAWN_UTIL:
# Only respawn the module if both libraries are missing.
# If only one is available, then usage of the "wrong" (i.e. not the system one)
# python interpreter is likely not the problem.
respawn_module("firewall")
if not HAS_DBUS: if not HAS_DBUS:
module.fail_json(msg=missing_required_lib('python-dbus')) module.fail_json(msg=missing_required_lib('python-dbus'))
if not HAS_FIREWALLD: if not HAS_FIREWALLD:
@ -344,8 +356,9 @@ def main():
specified_zones = module.params['zones'] specified_zones = module.params['zones']
collect_zones = list(set(specified_zones) & set(all_zones)) collect_zones = list(set(specified_zones) & set(all_zones))
ignore_zones = list(set(specified_zones) - set(collect_zones)) ignore_zones = list(set(specified_zones) - set(collect_zones))
warn.append( if ignore_zones:
'Please note: zone:(%s) have been ignored in the gathering process.' % ','.join(ignore_zones)) warn.append(
'Please note: zone:(%s) have been ignored in the gathering process.' % ','.join(ignore_zones))
else: else:
collect_zones = get_all_zones(client) collect_zones = get_all_zones(client)

View file

@ -31,12 +31,12 @@ options:
src: src:
description: description:
- Device (or NFS volume, or something else) to be mounted on I(path). - Device (or NFS volume, or something else) to be mounted on I(path).
- Required when I(state) set to C(present) or C(mounted). - Required when I(state) set to C(present), C(mounted) or C(ephemeral).
type: path type: path
fstype: fstype:
description: description:
- Filesystem type. - Filesystem type.
- Required when I(state) is C(present) or C(mounted). - Required when I(state) is C(present), C(mounted) or C(ephemeral).
type: str type: str
opts: opts:
description: description:
@ -48,7 +48,7 @@ options:
- Note that if set to C(null) and I(state) set to C(present), - Note that if set to C(null) and I(state) set to C(present),
it will cease to work and duplicate entries will be made it will cease to work and duplicate entries will be made
with subsequent runs. with subsequent runs.
- Has no effect on Solaris systems. - Has no effect on Solaris systems or when used with C(ephemeral).
type: str type: str
default: '0' default: '0'
passno: passno:
@ -57,7 +57,7 @@ options:
- Note that if set to C(null) and I(state) set to C(present), - Note that if set to C(null) and I(state) set to C(present),
it will cease to work and duplicate entries will be made it will cease to work and duplicate entries will be made
with subsequent runs. with subsequent runs.
- Deprecated on Solaris systems. - Deprecated on Solaris systems. Has no effect when used with C(ephemeral).
type: str type: str
default: '0' default: '0'
state: state:
@ -68,6 +68,13 @@ options:
- If C(unmounted), the device will be unmounted without changing I(fstab). - If C(unmounted), the device will be unmounted without changing I(fstab).
- C(present) only specifies that the device is to be configured in - C(present) only specifies that the device is to be configured in
I(fstab) and does not trigger or require a mount. I(fstab) and does not trigger or require a mount.
- C(ephemeral) only specifies that the device is to be mounted, without changing
I(fstab). If it is already mounted, a remount will be triggered.
This will always return changed=True. If the mount point I(path)
has already a device mounted on, and its source is different than I(src),
the module will fail to avoid unexpected unmount or mount point override.
If the mount point is not present, the mount point will be created.
The I(fstab) is completely ignored. This option is added in version 1.5.0.
- C(absent) specifies that the device mount's entry will be removed from - C(absent) specifies that the device mount's entry will be removed from
I(fstab) and will also unmount the device and remove the mount I(fstab) and will also unmount the device and remove the mount
point. point.
@ -77,10 +84,15 @@ options:
applied to the remount, but will not change I(fstab). Additionally, applied to the remount, but will not change I(fstab). Additionally,
if I(opts) is set, and the remount command fails, the module will if I(opts) is set, and the remount command fails, the module will
error to prevent unexpected mount changes. Try using C(mounted) error to prevent unexpected mount changes. Try using C(mounted)
instead to work around this issue. instead to work around this issue. C(remounted) expects the mount point
to be present in the I(fstab). To remount a mount point not registered
in I(fstab), use C(ephemeral) instead, especially with BSD nodes.
- C(absent_from_fstab) specifies that the device mount's entry will be
removed from I(fstab). This option does not unmount it or delete the
mountpoint.
type: str type: str
required: true required: true
choices: [ absent, mounted, present, unmounted, remounted ] choices: [ absent, absent_from_fstab, mounted, present, unmounted, remounted, ephemeral ]
fstab: fstab:
description: description:
- File to use instead of C(/etc/fstab). - File to use instead of C(/etc/fstab).
@ -89,6 +101,7 @@ options:
- OpenBSD does not allow specifying alternate fstab files with mount so do not - OpenBSD does not allow specifying alternate fstab files with mount so do not
use this on OpenBSD with any state that operates on the live filesystem. use this on OpenBSD with any state that operates on the live filesystem.
- This parameter defaults to /etc/fstab or /etc/vfstab on Solaris. - This parameter defaults to /etc/fstab or /etc/vfstab on Solaris.
- This parameter is ignored when I(state) is set to C(ephemeral).
type: str type: str
boot: boot:
description: description:
@ -100,14 +113,15 @@ options:
to mount options in I(/etc/fstab). to mount options in I(/etc/fstab).
- To avoid mount option conflicts, if C(noauto) specified in C(opts), - To avoid mount option conflicts, if C(noauto) specified in C(opts),
mount module will ignore C(boot). mount module will ignore C(boot).
- This parameter is ignored when I(state) is set to C(ephemeral).
type: bool type: bool
default: yes default: true
backup: backup:
description: description:
- Create a backup file including the timestamp information so you can get - Create a backup file including the timestamp information so you can get
the original file back if you somehow clobbered it incorrectly. the original file back if you somehow clobbered it incorrectly.
type: bool type: bool
default: no default: false
notes: notes:
- As of Ansible 2.3, the I(name) option has been changed to I(path) as - As of Ansible 2.3, the I(name) option has been changed to I(path) as
default, but I(name) still works as well. default, but I(name) still works as well.
@ -181,9 +195,17 @@ EXAMPLES = r'''
src: 192.168.1.100:/nfs/ssd/shared_data src: 192.168.1.100:/nfs/ssd/shared_data
path: /mnt/shared_data path: /mnt/shared_data
opts: rw,sync,hard opts: rw,sync,hard
boot: no boot: false
state: mounted state: mounted
fstype: nfs fstype: nfs
- name: Mount ephemeral SMB volume
ansible.posix.mount:
src: //192.168.1.200/share
path: /mnt/smb_share
opts: "rw,vers=3,file_mode=0600,dir_mode=0700,dom={{ ad_domain }},username={{ ad_username }},password={{ ad_password }}"
fstype: cifs
state: ephemeral
''' '''
import errno import errno
@ -226,7 +248,7 @@ def _escape_fstab(v):
if isinstance(v, int): if isinstance(v, int):
return v return v
else: else:
return( return (
v. v.
replace('\\', '\\134'). replace('\\', '\\134').
replace(' ', '\\040'). replace(' ', '\\040').
@ -430,6 +452,24 @@ def _set_fstab_args(fstab_file):
return result return result
def _set_ephemeral_args(args):
result = []
# Set fstype switch according to platform. SunOS/Solaris use -F
if platform.system().lower() == 'sunos':
result.append('-F')
else:
result.append('-t')
result.append(args['fstype'])
# Even if '-o remount' is already set, specifying multiple -o is valid
if args['opts'] != 'defaults':
result += ['-o', args['opts']]
result.append(args['src'])
return result
def mount(module, args): def mount(module, args):
"""Mount up a path or remount if needed.""" """Mount up a path or remount if needed."""
@ -446,7 +486,11 @@ def mount(module, args):
'OpenBSD does not support alternate fstab files. Do not ' 'OpenBSD does not support alternate fstab files. Do not '
'specify the fstab parameter for OpenBSD hosts')) 'specify the fstab parameter for OpenBSD hosts'))
else: else:
cmd += _set_fstab_args(args['fstab']) if module.params['state'] != 'ephemeral':
cmd += _set_fstab_args(args['fstab'])
if module.params['state'] == 'ephemeral':
cmd += _set_ephemeral_args(args)
cmd += [name] cmd += [name]
@ -498,18 +542,24 @@ def remount(module, args):
'OpenBSD does not support alternate fstab files. Do not ' 'OpenBSD does not support alternate fstab files. Do not '
'specify the fstab parameter for OpenBSD hosts')) 'specify the fstab parameter for OpenBSD hosts'))
else: else:
cmd += _set_fstab_args(args['fstab']) if module.params['state'] != 'ephemeral':
cmd += _set_fstab_args(args['fstab'])
if module.params['state'] == 'ephemeral':
cmd += _set_ephemeral_args(args)
cmd += [args['name']] cmd += [args['name']]
out = err = '' out = err = ''
try: try:
if platform.system().lower().endswith('bsd'): if module.params['state'] != 'ephemeral' and platform.system().lower().endswith('bsd'):
# Note: Forcing BSDs to do umount/mount due to BSD remount not # Note: Forcing BSDs to do umount/mount due to BSD remount not
# working as expected (suspect bug in the BSD mount command) # working as expected (suspect bug in the BSD mount command)
# Interested contributor could rework this to use mount options on # Interested contributor could rework this to use mount options on
# the CLI instead of relying on fstab # the CLI instead of relying on fstab
# https://github.com/ansible/ansible-modules-core/issues/5591 # https://github.com/ansible/ansible-modules-core/issues/5591
# Note: this does not affect ephemeral state as all options
# are set on the CLI and fstab is expected to be ignored.
rc = 1 rc = 1
else: else:
rc, out, err = module.run_command(cmd) rc, out, err = module.run_command(cmd)
@ -663,6 +713,47 @@ def get_linux_mounts(module, mntinfo_file="/proc/self/mountinfo"):
return mounts return mounts
def _is_same_mount_src(module, src, mountpoint, linux_mounts):
"""Return True if the mounted fs on mountpoint is the same source than src. Return False if mountpoint is not a mountpoint"""
# If the provided mountpoint is not a mountpoint, don't waste time
if (
not ismount(mountpoint) and
not is_bind_mounted(module, linux_mounts, mountpoint)):
return False
# Treat Linux bind mounts
if platform.system() == 'Linux' and linux_mounts is not None:
# For Linux bind mounts only: the mount command does not return
# the actual source for bind mounts, but the device of the source.
# is_bind_mounted() called with the 'src' parameter will return True if
# the mountpoint is a bind mount AND the source FS is the same than 'src'.
# is_bind_mounted() is not reliable on Solaris, NetBSD and OpenBSD.
# But we can rely on 'mount -v' on all other platforms, and Linux non-bind mounts.
if is_bind_mounted(module, linux_mounts, mountpoint, src):
return True
# mount with parameter -v has a close behavior on Linux, *BSD, SunOS
# Requires -v with SunOS. Without -v, source and destination are reversed
# Output format differs from a system to another, but field[0:3] are consistent: [src, 'on', dest]
cmd = '%s -v' % module.get_bin_path('mount', required=True)
rc, out, err = module.run_command(cmd)
mounts = []
if len(out):
mounts = to_native(out).strip().split('\n')
else:
module.fail_json(msg="Unable to retrieve mount info with command '%s'" % cmd)
for mnt in mounts:
fields = mnt.split()
mp_src = fields[0]
mp_dst = fields[2]
if mp_src == src and mp_dst == mountpoint:
return True
return False
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
@ -675,12 +766,13 @@ def main():
passno=dict(type='str', no_log=False, default='0'), passno=dict(type='str', no_log=False, default='0'),
src=dict(type='path'), src=dict(type='path'),
backup=dict(type='bool', default=False), backup=dict(type='bool', default=False),
state=dict(type='str', required=True, choices=['absent', 'mounted', 'present', 'unmounted', 'remounted']), state=dict(type='str', required=True, choices=['absent', 'absent_from_fstab', 'mounted', 'present', 'unmounted', 'remounted', 'ephemeral']),
), ),
supports_check_mode=True, supports_check_mode=True,
required_if=( required_if=(
['state', 'mounted', ['src', 'fstype']], ['state', 'mounted', ['src', 'fstype']],
['state', 'present', ['src', 'fstype']], ['state', 'present', ['src', 'fstype']],
['state', 'ephemeral', ['src', 'fstype']]
), ),
) )
@ -739,7 +831,7 @@ def main():
# handle mount on boot. To avoid mount option conflicts, if 'noauto' # handle mount on boot. To avoid mount option conflicts, if 'noauto'
# specified in 'opts', mount module will ignore 'boot'. # specified in 'opts', mount module will ignore 'boot'.
opts = args['opts'].split(',') opts = args['opts'].split(',')
if 'noauto' in opts: if module.params['boot'] and 'noauto' in opts:
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.") args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'noauto'.")
elif not module.params['boot']: elif not module.params['boot']:
args['boot'] = 'no' args['boot'] = 'no'
@ -748,15 +840,17 @@ def main():
# If fstab file does not exist, we first need to create it. This mainly # If fstab file does not exist, we first need to create it. This mainly
# happens when fstab option is passed to the module. # happens when fstab option is passed to the module.
if not os.path.exists(args['fstab']): # If state is 'ephemeral', we do not need fstab file
if not os.path.exists(os.path.dirname(args['fstab'])): if module.params['state'] != 'ephemeral':
os.makedirs(os.path.dirname(args['fstab'])) if not os.path.exists(args['fstab']):
try: if not os.path.exists(os.path.dirname(args['fstab'])):
open(args['fstab'], 'a').close() os.makedirs(os.path.dirname(args['fstab']))
except PermissionError as e: try:
module.fail_json(msg="Failed to open %s due to permission issue" % args['fstab']) open(args['fstab'], 'a').close()
except Exception as e: except PermissionError as e:
module.fail_json(msg="Failed to open %s due to %s" % (args['fstab'], to_native(e))) module.fail_json(msg="Failed to open %s due to permission issue" % args['fstab'])
except Exception as e:
module.fail_json(msg="Failed to open %s due to %s" % (args['fstab'], to_native(e)))
# absent: # absent:
# Remove from fstab and unmounted. # Remove from fstab and unmounted.
@ -767,12 +861,16 @@ def main():
# mounted: # mounted:
# Add to fstab if not there and make sure it is mounted. If it has # Add to fstab if not there and make sure it is mounted. If it has
# changed in fstab then remount it. # changed in fstab then remount it.
# ephemeral:
# Do not change fstab state, but mount.
state = module.params['state'] state = module.params['state']
name = module.params['path'] name = module.params['path']
changed = False changed = False
if state == 'absent': if state == 'absent_from_fstab':
name, changed = unset_mount(module, args)
elif state == 'absent':
name, changed = unset_mount(module, args) name, changed = unset_mount(module, args)
if changed and not module.check_mode: if changed and not module.check_mode:
@ -798,7 +896,7 @@ def main():
msg="Error unmounting %s: %s" % (name, msg)) msg="Error unmounting %s: %s" % (name, msg))
changed = True changed = True
elif state == 'mounted': elif state == 'mounted' or state == 'ephemeral':
dirs_created = [] dirs_created = []
if not os.path.exists(name) and not module.check_mode: if not os.path.exists(name) and not module.check_mode:
try: try:
@ -826,7 +924,11 @@ def main():
module.fail_json( module.fail_json(
msg="Error making dir %s: %s" % (name, to_native(e))) msg="Error making dir %s: %s" % (name, to_native(e)))
name, backup_lines, changed = _set_mount_save_old(module, args) # ephemeral: completely ignore fstab
if state != 'ephemeral':
name, backup_lines, changed = _set_mount_save_old(module, args)
else:
name, backup_lines, changed = args['name'], [], False
res = 0 res = 0
if ( if (
@ -836,7 +938,26 @@ def main():
if changed and not module.check_mode: if changed and not module.check_mode:
res, msg = remount(module, args) res, msg = remount(module, args)
changed = True changed = True
# When 'state' == 'ephemeral', we don't know what is in fstab, and 'changed' is always False
if state == 'ephemeral':
# If state == 'ephemeral', check if the mountpoint src == module.params['src']
# If it doesn't, fail to prevent unwanted unmount or unwanted mountpoint override
if _is_same_mount_src(module, args['src'], args['name'], linux_mounts):
changed = True
if not module.check_mode:
res, msg = remount(module, args)
else:
module.fail_json(
msg=(
'Ephemeral mount point is already mounted with a different '
'source than the specified one. Failing in order to prevent an '
'unwanted unmount or override operation. Try replacing this command with '
'a "state: unmounted" followed by a "state: ephemeral", or use '
'a different destination path.'))
else: else:
# If not already mounted, mount it
changed = True changed = True
if not module.check_mode: if not module.check_mode:
@ -848,7 +969,8 @@ def main():
# A non-working fstab entry may break the system at the reboot, # A non-working fstab entry may break the system at the reboot,
# so undo all the changes if possible. # so undo all the changes if possible.
try: try:
write_fstab(module, backup_lines, args['fstab']) if state != 'ephemeral':
write_fstab(module, backup_lines, args['fstab'])
except Exception: except Exception:
pass pass

View file

@ -37,7 +37,7 @@ options:
src: src:
description: description:
- Path of the patch file as accepted by the GNU patch tool. If - Path of the patch file as accepted by the GNU patch tool. If
C(remote_src) is 'no', the patch source file is looked up from the C(remote_src) is C(false), the patch source file is looked up from the
module's I(files) directory. module's I(files) directory.
type: path type: path
required: true required: true
@ -50,10 +50,10 @@ options:
default: present default: present
remote_src: remote_src:
description: description:
- If C(no), it will search for src at originating/controller machine, if C(yes) it will - If C(false), it will search for src at originating/controller machine, if C(true) it will
go to the remote/target machine for the C(src). go to the remote/target machine for the C(src).
type: bool type: bool
default: no default: false
strip: strip:
description: description:
- Number that indicates the smallest prefix containing leading slashes - Number that indicates the smallest prefix containing leading slashes
@ -65,20 +65,20 @@ options:
description: description:
- Passes C(--backup --version-control=numbered) to patch, producing numbered backup copies. - Passes C(--backup --version-control=numbered) to patch, producing numbered backup copies.
type: bool type: bool
default: no default: false
binary: binary:
description: description:
- Setting to C(yes) will disable patch's heuristic for transforming CRLF - Setting to C(true) will disable patch's heuristic for transforming CRLF
line endings into LF. line endings into LF.
- Line endings of src and dest must match. - Line endings of src and dest must match.
- If set to C(no), C(patch) will replace CRLF in C(src) files on POSIX. - If set to C(false), C(patch) will replace CRLF in C(src) files on POSIX.
type: bool type: bool
default: no default: false
ignore_whitespace: ignore_whitespace:
description: description:
- Setting to C(yes) will ignore white space changes between patch and input.. - Setting to C(true) will ignore white space changes between patch and input.
type: bool type: bool
default: no default: false
notes: notes:
- This module requires GNU I(patch) utility to be installed on the remote host. - This module requires GNU I(patch) utility to be installed on the remote host.
''' '''

View file

@ -0,0 +1,76 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: Red Hat Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
---
module: rhel_facts
version_added: 1.5.0
short_description: Facts module to set or override RHEL specific facts.
description:
- Compatibility layer for using the "package" module for rpm-ostree based systems via setting the "pkg_mgr" fact correctly.
author:
- Adam Miller (@maxamillion)
requirements:
- rpm-ostree
seealso:
- module: ansible.builtin.package
options: {}
'''
EXAMPLES = '''
- name: Playbook to use the package module on all RHEL footprints
vars:
ansible_facts_modules:
- setup # REQUIRED to be run before all custom fact modules
- ansible.posix.rhel_facts
tasks:
- name: Ensure packages are installed
ansible.builtin.package:
name:
- htop
- ansible
state: present
'''
RETURN = """
ansible_facts:
description: Relevant Ansible Facts
returned: when needed
type: complex
contains:
pkg_mgr:
description: System-level package manager override
returned: when needed
type: str
sample: {'pkg_mgr': 'ansible.posix.rhel_facts'}
"""
import os
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
supports_check_mode=True,
)
ansible_facts = {}
# Verify that the platform is an rpm-ostree based system
if os.path.exists("/run/ostree-booted"):
ansible_facts['pkg_mgr'] = 'ansible.posix.rhel_rpm_ostree'
module.exit_json(ansible_facts=ansible_facts, changed=False)
if __name__ == '__main__':
main()

View file

@ -0,0 +1,124 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: Red Hat Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: rhel_rpm_ostree
version_added: 1.5.0
short_description: Ensure packages exist in a RHEL for Edge rpm-ostree based system
description:
- Compatibility layer for using the "package" module for RHEL for Edge systems utilizing the RHEL System Roles.
author:
- Adam Miller (@maxamillion)
requirements:
- rpm-ostree
options:
name:
description:
- A package name or package specifier with version, like C(name-1.0).
- Comparison operators for package version are valid here C(>), C(<), C(>=), C(<=). Example - C(name>=1.0)
- If a previous version is specified, the task also needs to turn C(allow_downgrade) on.
See the C(allow_downgrade) documentation for caveats with downgrading packages.
- When using state=latest, this can be C('*') which means run C(yum -y update).
- You can also pass a url or a local path to a rpm file (using state=present).
To operate on several packages this can accept a comma separated string of packages or (as of 2.0) a list of packages.
aliases: [ pkg ]
type: list
elements: str
default: []
state:
description:
- Whether to install (C(present) or C(installed), C(latest)), or remove (C(absent) or C(removed)) a package.
- C(present) and C(installed) will simply ensure that a desired package is installed.
- C(latest) will update the specified package if it's not of the latest available version.
- C(absent) and C(removed) will remove the specified package.
- Default is C(None), however in effect the default action is C(present) unless the C(autoremove) option is
enabled for this module, then C(absent) is inferred.
type: str
choices: [ absent, installed, latest, present, removed ]
notes:
- This module does not support installing or removing packages to/from an overlay as this is not supported
by RHEL for Edge, packages needed should be defined in the osbuild Blueprint and provided to Image Builder
at build time. This module exists only for C(package) module compatibility.
'''
EXAMPLES = '''
- name: Ensure htop and ansible are installed on rpm-ostree based RHEL
ansible.posix.rhel_rpm_ostree:
name:
- htop
- ansible
state: present
'''
RETURN = """
msg:
description: status of rpm transaction
returned: always
type: str
sample: "No changes made."
"""
import os
import traceback
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_text
def locally_installed(module, pkgname):
(rc, out, err) = module.run_command('{0} -q {1}'.format(module.get_bin_path("rpm"), pkgname).split())
return (rc == 0)
def rpm_ostree_transaction(module):
pkgs = []
if module.params['state'] in ['present', 'installed', 'latest']:
for pkg in module.params['name']:
if not locally_installed(module, pkg):
pkgs.append(pkg)
elif module.params['state'] in ['absent', 'removed']:
for pkg in module.params['name']:
if locally_installed(module, pkg):
pkgs.append(pkg)
if not pkgs:
module.exit_json(msg="No changes made.")
else:
if module.params['state'] in ['present', 'installed', 'latest']:
module.fail_json(msg="The following packages are absent in the currently booted rpm-ostree commit: %s" ' '.join(pkgs))
else:
module.fail_json(msg="The following packages are present in the currently booted rpm-ostree commit: %s" ' '.join(pkgs))
def main():
module = AnsibleModule(
argument_spec=dict(
name=dict(type='list', elements='str', aliases=['pkg'], default=[]),
state=dict(type='str', default=None, choices=['absent', 'installed', 'latest', 'present', 'removed']),
),
)
# Verify that the platform is an rpm-ostree based system
if not os.path.exists("/run/ostree-booted"):
module.fail_json(msg="Module rpm_ostree is only applicable for rpm-ostree based systems.")
try:
rpm_ostree_transaction(module)
except Exception as e:
module.fail_json(msg=to_text(e), exception=traceback.format_exc())
if __name__ == '__main__':
main()

View file

@ -0,0 +1,125 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: Red Hat Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: rpm_ostree_upgrade
short_description: Manage rpm-ostree upgrade transactions
description:
- Manage an rpm-ostree upgrade transactions.
version_added: 1.5.0
author:
- Adam Miller (@maxamillion)
requirements:
- rpm-ostree
options:
os:
description:
- The OSNAME upon which to operate.
type: str
default: ""
required: false
cache_only:
description:
- Perform the transaction using only pre-cached data, do not download.
type: bool
default: false
required: false
allow_downgrade:
description:
- Allow for the upgrade to be a chronologically older tree.
type: bool
default: false
required: false
peer:
description:
- Force peer-to-peer connection instead of using a system message bus.
type: bool
default: false
required: false
'''
EXAMPLES = '''
- name: Upgrade the rpm-ostree image without options, accept all defaults
ansible.posix.rpm_ostree_upgrade:
- name: Upgrade the rpm-ostree image allowing downgrades
ansible.posix.rpm_ostree_upgrade:
allow_downgrade: true
'''
RETURN = '''
msg:
description: The command standard output
returned: always
type: str
sample: 'No upgrade available.'
'''
import os
import traceback
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_native, to_text
def rpm_ostree_transaction(module):
cmd = []
cmd.append(module.get_bin_path("rpm-ostree"))
cmd.append('upgrade')
if module.params['os']:
cmd += ['--os', module.params['os']]
if module.params['cache_only']:
cmd += ['--cache-only']
if module.params['allow_downgrade']:
cmd += ['--allow-downgrade']
if module.params['peer']:
cmd += ['--peer']
module.run_command_environ_update = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C')
rc, out, err = module.run_command(cmd)
if rc != 0:
module.fail_json(rc=rc, msg=err)
else:
if to_text("No upgrade available.") in to_text(out):
module.exit_json(msg=out, changed=False)
else:
module.exit_json(msg=out, changed=True)
def main():
module = AnsibleModule(
argument_spec=dict(
os=dict(type='str', default=''),
cache_only=dict(type='bool', default=False),
allow_downgrade=dict(type='bool', default=False),
peer=dict(type='bool', default=False),
),
)
# Verify that the platform is an rpm-ostree based system
if not os.path.exists("/run/ostree-booted"):
module.fail_json(msg="Module rpm_ostree_upgrade is only applicable for rpm-ostree based systems.")
try:
rpm_ostree_transaction(module)
except Exception as e:
module.fail_json(msg=to_native(e), exception=traceback.format_exc())
if __name__ == '__main__':
main()

View file

@ -22,9 +22,9 @@ options:
type: str type: str
persistent: persistent:
description: description:
- Set to C(yes) if the boolean setting should survive a reboot. - Set to C(true) if the boolean setting should survive a reboot.
type: bool type: bool
default: 'no' default: false
state: state:
description: description:
- Desired boolean value - Desired boolean value
@ -49,8 +49,8 @@ EXAMPLES = r'''
- name: Set httpd_can_network_connect flag on and keep it persistent across reboots - name: Set httpd_can_network_connect flag on and keep it persistent across reboots
ansible.posix.seboolean: ansible.posix.seboolean:
name: httpd_can_network_connect name: httpd_can_network_connect
state: yes state: true
persistent: yes persistent: true
''' '''
import os import os
@ -75,6 +75,7 @@ except ImportError:
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.six import binary_type from ansible.module_utils.six import binary_type
from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils._text import to_bytes, to_text
from ansible_collections.ansible.posix.plugins.module_utils._respawn import respawn_module, HAS_RESPAWN_UTIL
def get_runtime_status(ignore_selinux_state=False): def get_runtime_status(ignore_selinux_state=False):
@ -281,6 +282,12 @@ def main():
supports_check_mode=True, supports_check_mode=True,
) )
if not HAVE_SELINUX and not HAVE_SEMANAGE and HAS_RESPAWN_UTIL:
# Only respawn the module if both libraries are missing.
# If only one is available, then usage of the "wrong" (i.e. not the system one)
# python interpreter is likely not the problem.
respawn_module("selinux")
if not HAVE_SELINUX: if not HAVE_SELINUX:
module.fail_json(msg=missing_required_lib('libselinux-python'), exception=SELINUX_IMP_ERR) module.fail_json(msg=missing_required_lib('libselinux-python'), exception=SELINUX_IMP_ERR)

View file

@ -32,7 +32,7 @@ options:
description: description:
- If set to I(true), will update also the kernel boot parameters when disabling/enabling SELinux. - If set to I(true), will update also the kernel boot parameters when disabling/enabling SELinux.
- The C(grubby) tool must be present on the target system for this to work. - The C(grubby) tool must be present on the target system for this to work.
default: no default: false
type: bool type: bool
version_added: '1.4.0' version_added: '1.4.0'
configfile: configfile:
@ -107,6 +107,8 @@ from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.common.process import get_bin_path from ansible.module_utils.common.process import get_bin_path
from ansible.module_utils.facts.utils import get_file_lines from ansible.module_utils.facts.utils import get_file_lines
from ansible_collections.ansible.posix.plugins.module_utils._respawn import respawn_module, HAS_RESPAWN_UTIL
# getter subroutines # getter subroutines
def get_config_state(configfile): def get_config_state(configfile):
@ -236,6 +238,8 @@ def main():
) )
if not HAS_SELINUX: if not HAS_SELINUX:
if HAS_RESPAWN_UTIL:
respawn_module("selinux")
module.fail_json(msg=missing_required_lib('libselinux-python'), exception=SELINUX_IMP_ERR) module.fail_json(msg=missing_required_lib('libselinux-python'), exception=SELINUX_IMP_ERR)
# global vars # global vars

View file

@ -26,13 +26,13 @@ options:
description: description:
- Path on the source host that will be synchronized to the destination. - Path on the source host that will be synchronized to the destination.
- The path can be absolute or relative. - The path can be absolute or relative.
type: str type: path
required: true required: true
dest: dest:
description: description:
- Path on the destination host that will be synchronized from the source. - Path on the destination host that will be synchronized from the source.
- The path can be absolute or relative. - The path can be absolute or relative.
type: str type: path
required: true required: true
dest_port: dest_port:
description: description:
@ -53,36 +53,36 @@ options:
description: description:
- Mirrors the rsync archive flag, enables recursive, links, perms, times, owner, group flags and -D. - Mirrors the rsync archive flag, enables recursive, links, perms, times, owner, group flags and -D.
type: bool type: bool
default: yes default: true
checksum: checksum:
description: description:
- Skip based on checksum, rather than mod-time & size; Note that that "archive" option is still enabled by default - the "checksum" option will - Skip based on checksum, rather than mod-time & size; Note that that "archive" option is still enabled by default - the "checksum" option will
not disable it. not disable it.
type: bool type: bool
default: no default: false
compress: compress:
description: description:
- Compress file data during the transfer. - Compress file data during the transfer.
- In most cases, leave this enabled unless it causes problems. - In most cases, leave this enabled unless it causes problems.
type: bool type: bool
default: yes default: true
existing_only: existing_only:
description: description:
- Skip creating new files on receiver. - Skip creating new files on receiver.
type: bool type: bool
default: no default: false
delete: delete:
description: description:
- Delete files in I(dest) that do not exist (after transfer, not before) in the I(src) path. - Delete files in I(dest) that do not exist (after transfer, not before) in the I(src) path.
- This option requires I(recursive=yes). - This option requires I(recursive=true).
- This option ignores excluded files and behaves like the rsync opt C(--delete-after). - This option ignores excluded files and behaves like the rsync opt C(--delete-after).
type: bool type: bool
default: no default: false
dirs: dirs:
description: description:
- Transfer directories without recursing. - Transfer directories without recursing.
type: bool type: bool
default: no default: false
recursive: recursive:
description: description:
- Recurse into directories. - Recurse into directories.
@ -97,7 +97,7 @@ options:
description: description:
- Copy symlinks as the item that they point to (the referent) is copied, rather than the symlink. - Copy symlinks as the item that they point to (the referent) is copied, rather than the symlink.
type: bool type: bool
default: no default: false
perms: perms:
description: description:
- Preserve permissions. - Preserve permissions.
@ -132,43 +132,36 @@ options:
description: description:
- Put user@ for the remote paths. - Put user@ for the remote paths.
- If you have a custom ssh config to define the remote user for a host - If you have a custom ssh config to define the remote user for a host
that does not match the inventory user, you should set this parameter to C(no). that does not match the inventory user, you should set this parameter to C(false).
type: bool type: bool
default: yes 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: no
ssh_connection_multiplexing: ssh_connection_multiplexing:
description: description:
- SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections. - SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections.
This is accomplished by setting the SSH C(ControlSocket) to C(none). This is accomplished by setting the SSH C(ControlSocket) to C(none).
- Set this option to C(yes) to allow multiplexing and reduce SSH connection overhead. - Set this option to C(true) to allow multiplexing and reduce SSH connection overhead.
- Note that simply setting this option to C(yes) is not enough; - Note that simply setting this option to C(true) is not enough;
You must also configure SSH connection multiplexing in your SSH client config by setting values for You must also configure SSH connection multiplexing in your SSH client config by setting values for
C(ControlMaster), C(ControlPersist) and C(ControlPath). C(ControlMaster), C(ControlPersist) and C(ControlPath).
type: bool type: bool
default: no default: false
rsync_opts: rsync_opts:
description: description:
- Specify additional rsync options by passing in an array. - Specify additional rsync options by passing in an array.
- Note that an empty string in C(rsync_opts) will end up transfer the current working directory. - Note that an empty string in C(rsync_opts) will end up transfer the current working directory.
type: list type: list
default: default: []
elements: str elements: str
partial: partial:
description: description:
- Tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster. - Tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster.
type: bool type: bool
default: no default: false
verify_host: verify_host:
description: description:
- Verify destination host key. - Verify destination host key.
type: bool type: bool
default: no default: false
private_key: private_key:
description: description:
- Specify the private key to use for SSH-based rsync connections (e.g. C(~/.ssh/id_rsa)). - Specify the private key to use for SSH-based rsync connections (e.g. C(~/.ssh/id_rsa)).
@ -178,14 +171,38 @@ options:
- Add a destination to hard link against during the rsync. - Add a destination to hard link against during the rsync.
type: list type: list
default: default:
elements: str elements: path
delay_updates: delay_updates:
description: description:
- This option puts the temporary file from each updated file into a holding directory until the end of the transfer, - This option puts the temporary file from each updated file into a holding directory until the end of the transfer,
at which time all the files are renamed into place in rapid succession. at which time all the files are renamed into place in rapid succession.
type: bool type: bool
default: yes default: true
version_added: '1.3.0' version_added: '1.3.0'
use_ssh_args:
description:
- In Ansible 2.10 and lower, it uses the ssh_args specified in C(ansible.cfg).
- In Ansible 2.11 and onwards, when set to C(true), it uses all SSH connection configurations like
C(ansible_ssh_args), C(ansible_ssh_common_args), and C(ansible_ssh_extra_args).
type: bool
default: false
_local_rsync_path:
description: Internal use only.
type: path
default: 'rsync'
required: false
_local_rsync_password:
description: Internal use only, never logged.
type: str
required: false
_substitute_controller:
description: Internal use only.
type: bool
default: false
_ssh_args:
description: Internal use only. See C(use_ssh_args) for ssh arg settings.
type: str
required: false
notes: notes:
- rsync must be installed on both the local and remote host. - rsync must be installed on both the local and remote host.
@ -212,7 +229,7 @@ notes:
- link_destination is subject to the same limitations as the underlying rsync daemon. Hard links are only preserved if the relative subtrees - link_destination is subject to the same limitations as the underlying rsync daemon. Hard links are only preserved if the relative subtrees
of the source and destination are the same. Attempts to hardlink into a directory that is a subdirectory of the source will be prevented. of the source and destination are the same. Attempts to hardlink into a directory that is a subdirectory of the source will be prevented.
seealso: seealso:
- module: copy - module: ansible.builtin.copy
- module: community.windows.win_robocopy - module: community.windows.win_robocopy
author: author:
- Timothy Appnel (@tima) - Timothy Appnel (@tima)
@ -235,7 +252,7 @@ EXAMPLES = r'''
src: rsync://somehost.com/path/ src: rsync://somehost.com/path/
dest: /some/absolute/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: ansible.posix.synchronize:
src: /some/absolute/path/ src: /some/absolute/path/
dest: rsync://somehost.com/path/ dest: rsync://somehost.com/path/
@ -252,27 +269,27 @@ EXAMPLES = r'''
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
archive: no archive: false
- name: Synchronization with --archive options enabled except for --recursive - name: Synchronization with --archive options enabled except for --recursive
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
recursive: no recursive: false
- name: Synchronization with --archive options enabled except for --times, with --checksum option enabled - name: Synchronization with --archive options enabled except for --times, with --checksum option enabled
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
checksum: yes checksum: true
times: no times: false
- name: Synchronization without --archive options enabled except use --links - name: Synchronization without --archive options enabled except use --links
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
archive: no archive: false
links: yes links: true
- name: Synchronization of two paths both on the control machine - name: Synchronization of two paths both on the control machine
ansible.posix.synchronize: ansible.posix.synchronize:
@ -302,8 +319,8 @@ EXAMPLES = r'''
ansible.posix.synchronize: ansible.posix.synchronize:
src: some/relative/path src: some/relative/path
dest: /some/absolute/path dest: /some/absolute/path
delete: yes delete: true
recursive: yes recursive: true
# This specific command is granted su privileges on the destination # This specific command is granted su privileges on the destination
- name: Synchronize using an alternate rsync command - name: Synchronize using an alternate rsync command
@ -362,11 +379,11 @@ def substitute_controller(path):
if not client_addr: if not client_addr:
ssh_env_string = os.environ.get('SSH_CLIENT', None) ssh_env_string = os.environ.get('SSH_CLIENT', None)
try: try:
client_addr, _ = ssh_env_string.split(None, 1) client_addr, _ = ssh_env_string.split(None, 1) # pylint: disable=disallowed-name
except AttributeError: except AttributeError:
ssh_env_string = os.environ.get('SSH_CONNECTION', None) ssh_env_string = os.environ.get('SSH_CONNECTION', None)
try: try:
client_addr, _ = ssh_env_string.split(None, 1) client_addr, _ = ssh_env_string.split(None, 1) # pylint: disable=disallowed-name
except AttributeError: except AttributeError:
pass pass
if not client_addr: if not client_addr:
@ -388,8 +405,8 @@ def is_rsh_needed(source, dest):
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
src=dict(type='str', required=True), src=dict(type='path', required=True),
dest=dict(type='str', required=True), dest=dict(type='path', required=True),
dest_port=dict(type='int'), dest_port=dict(type='int'),
delete=dict(type='bool', default=False), delete=dict(type='bool', default=False),
private_key=dict(type='path'), private_key=dict(type='path'),
@ -412,13 +429,14 @@ def main():
set_remote_user=dict(type='bool', default=True), set_remote_user=dict(type='bool', default=True),
rsync_timeout=dict(type='int', default=0), rsync_timeout=dict(type='int', default=0),
rsync_opts=dict(type='list', default=[], elements='str'), rsync_opts=dict(type='list', default=[], elements='str'),
ssh_args=dict(type='str'), _ssh_args=dict(type='str'),
use_ssh_args=dict(type='bool', default=False),
ssh_connection_multiplexing=dict(type='bool', default=False), ssh_connection_multiplexing=dict(type='bool', default=False),
partial=dict(type='bool', default=False), partial=dict(type='bool', default=False),
verify_host=dict(type='bool', default=False), verify_host=dict(type='bool', default=False),
delay_updates=dict(type='bool', default=True), delay_updates=dict(type='bool', default=True),
mode=dict(type='str', default='push', choices=['pull', 'push']), mode=dict(type='str', default='push', choices=['pull', 'push']),
link_dest=dict(type='list', elements='str'), link_dest=dict(type='list', elements='path'),
), ),
supports_check_mode=True, supports_check_mode=True,
) )
@ -454,7 +472,7 @@ def main():
owner = module.params['owner'] owner = module.params['owner']
group = module.params['group'] group = module.params['group']
rsync_opts = module.params['rsync_opts'] rsync_opts = module.params['rsync_opts']
ssh_args = module.params['ssh_args'] ssh_args = module.params['_ssh_args']
ssh_connection_multiplexing = module.params['ssh_connection_multiplexing'] ssh_connection_multiplexing = module.params['ssh_connection_multiplexing']
verify_host = module.params['verify_host'] verify_host = module.params['verify_host']
link_dest = module.params['link_dest'] link_dest = module.params['link_dest']
@ -572,7 +590,7 @@ def main():
# hardlink is actually a change # hardlink is actually a change
cmd.append('-vv') cmd.append('-vv')
for x in link_dest: for x in link_dest:
link_path = os.path.abspath(os.path.expanduser(x)) link_path = os.path.abspath(x)
destination_path = os.path.abspath(os.path.dirname(dest)) destination_path = os.path.abspath(os.path.dirname(dest))
if destination_path.find(link_path) == 0: if destination_path.find(link_path) == 0:
module.fail_json(msg='Hardlinking into a subdirectory of the source would cause recursion. %s and %s' % (destination_path, dest)) module.fail_json(msg='Hardlinking into a subdirectory of the source would cause recursion. %s and %s' % (destination_path, dest))
@ -581,12 +599,6 @@ def main():
changed_marker = '<<CHANGED>>' changed_marker = '<<CHANGED>>'
cmd.append('--out-format=%s' % shlex_quote(changed_marker + '%i %n%L')) cmd.append('--out-format=%s' % shlex_quote(changed_marker + '%i %n%L'))
# expand the paths
if '@' not in source:
source = os.path.expanduser(source)
if '@' not in dest:
dest = os.path.expanduser(dest)
cmd.append(shlex_quote(source)) cmd.append(shlex_quote(source))
cmd.append(shlex_quote(dest)) cmd.append(shlex_quote(dest))
cmdstr = ' '.join(cmd) cmdstr = ' '.join(cmd)

View file

@ -38,14 +38,14 @@ options:
description: description:
- Use this option to ignore errors about unknown keys. - Use this option to ignore errors about unknown keys.
type: bool type: bool
default: 'no' default: false
reload: reload:
description: description:
- If C(yes), performs a I(/sbin/sysctl -p) if the C(sysctl_file) is - If C(true), performs a I(/sbin/sysctl -p) if the C(sysctl_file) is
updated. If C(no), does not reload I(sysctl) even if the updated. If C(false), does not reload I(sysctl) even if the
C(sysctl_file) is updated. C(sysctl_file) is updated.
type: bool type: bool
default: 'yes' default: true
sysctl_file: sysctl_file:
description: description:
- Specifies the absolute path to C(sysctl.conf), if not C(/etc/sysctl.conf). - Specifies the absolute path to C(sysctl.conf), if not C(/etc/sysctl.conf).
@ -53,9 +53,9 @@ options:
type: path type: path
sysctl_set: sysctl_set:
description: description:
- Verify token value with the sysctl command and set with -w if necessary - Verify token value with the sysctl command and set with -w if necessary.
type: bool type: bool
default: 'no' default: false
author: author:
- David CHANIAL (@davixx) - David CHANIAL (@davixx)
''' '''
@ -78,21 +78,21 @@ EXAMPLES = r'''
name: kernel.panic name: kernel.panic
value: '3' value: '3'
sysctl_file: /tmp/test_sysctl.conf sysctl_file: /tmp/test_sysctl.conf
reload: no reload: false
# Set ip forwarding on in /proc and verify token value with the sysctl command # Set ip forwarding on in /proc and verify token value with the sysctl command
- ansible.posix.sysctl: - ansible.posix.sysctl:
name: net.ipv4.ip_forward name: net.ipv4.ip_forward
value: '1' value: '1'
sysctl_set: yes sysctl_set: true
# Set ip forwarding on in /proc and in the sysctl file and reload if necessary # Set ip forwarding on in /proc and in the sysctl file and reload if necessary
- ansible.posix.sysctl: - ansible.posix.sysctl:
name: net.ipv4.ip_forward name: net.ipv4.ip_forward
value: '1' value: '1'
sysctl_set: yes sysctl_set: true
state: present state: present
reload: yes reload: true
''' '''
# ============================================================== # ==============================================================

View file

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

View file

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

View file

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

View file

@ -1,3 +1,4 @@
---
# (c) 2017, Martin Krizek <mkrizek@redhat.com> # (c) 2017, Martin Krizek <mkrizek@redhat.com>
# This file is part of Ansible # This file is part of Ansible
@ -15,22 +16,21 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- block: - name: Test ACL
- include: acl.yml
when: ansible_system == 'Linux' # TODO enable acls mount option on FreeBSD to test it there too
always:
- name: delete created directory and file
file:
path: '{{ item }}'
state: absent
with_items:
- '{{ test_dir }}'
- '{{ test_file }}'
vars: vars:
test_user: ansible_user test_user: ansible_user
test_group: ansible_group test_group: ansible_group
test_file: '{{ output_dir }}/ansible file' test_file: "{{ output_dir }}/ansible file"
test_dir: "{{ output_dir }}/ansible_dir/with some space" test_dir: "{{ output_dir }}/ansible_dir/with some space"
block:
- name: Include tests task file
ansible.builtin.include_tasks: acl.yml
when: ansible_system == 'Linux' # TODO enable acls mount option on FreeBSD to test it there too
always:
- name: Delete created directory and file
ansible.builtin.file:
path: "{{ item }}"
state: absent
with_items:
- "{{ test_dir }}"
- "{{ test_file }}"

View file

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

View file

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

View file

@ -1,3 +1,4 @@
---
dss_key_basic: ssh-dss DATA_BASIC root@testing dss_key_basic: ssh-dss DATA_BASIC root@testing
dss_key_unquoted_option: idle-timeout=5m ssh-dss DATA_UNQUOTED_OPTION root@testing dss_key_unquoted_option: idle-timeout=5m ssh-dss DATA_UNQUOTED_OPTION root@testing
dss_key_command: command="/bin/true" ssh-dss DATA_COMMAND root@testing dss_key_command: command="/bin/true" ssh-dss DATA_COMMAND root@testing
@ -8,27 +9,27 @@ dss_key_trailing: ssh-dss DATA_TRAILING root@testing foo bar baz
rsa_key_basic: ssh-rsa DATA_BASIC root@testing rsa_key_basic: ssh-rsa DATA_BASIC root@testing
multiple_key_base: | multiple_key_base: |
ssh-rsa DATA_BASIC 1@testing ssh-rsa DATA_BASIC 1@testing
ssh-dss DATA_TRAILING 2@testing foo bar baz ssh-dss DATA_TRAILING 2@testing foo bar baz
ssh-dss DATA_TRAILING 3@testing foo bar baz ssh-dss DATA_TRAILING 3@testing foo bar baz
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
multiple_key_different_order: | multiple_key_different_order: |
ssh-dss DATA_TRAILING 2@testing foo bar baz ssh-dss DATA_TRAILING 2@testing foo bar baz
ssh-dss DATA_TRAILING 3@testing foo bar baz ssh-dss DATA_TRAILING 3@testing foo bar baz
ssh-rsa DATA_BASIC 1@testing ssh-rsa DATA_BASIC 1@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
multiple_key_different_order_2: | multiple_key_different_order_2: |
ssh-dss DATA_TRAILING 2@testing foo bar baz ssh-dss DATA_TRAILING 2@testing foo bar baz
ssh-rsa WHATEVER 2.5@testing ssh-rsa WHATEVER 2.5@testing
ssh-dss DATA_TRAILING 3@testing foo bar baz ssh-dss DATA_TRAILING 3@testing foo bar baz
ssh-rsa DATA_BASIC 1@testing ssh-rsa DATA_BASIC 1@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
multiple_key_exclusive: | multiple_key_exclusive: |
ssh-rsa DATA_BASIC 1@testing ssh-rsa DATA_BASIC 1@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
multiple_keys_comments: | multiple_keys_comments: |
ssh-rsa DATA_BASIC 1@testing ssh-rsa DATA_BASIC 1@testing

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,173 @@
---
# 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: Assert icmp block inversion is enabled
ansible.builtin.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: Assert icmp block inversion is enabled (verify not changed)
ansible.builtin.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: Assert icmp block inversion is disabled
ansible.builtin.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: Assert icmp block inversion is disabled (verify not changed)
ansible.builtin.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: Assert icmp block inversion is enabled
ansible.builtin.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: Assert icmp block inversion is enabled (verify not changed)
ansible.builtin.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: Assert icmp block inversion is disabled
ansible.builtin.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: Assert icmp block inversion is disabled (verify not changed)
ansible.builtin.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: Assert icmp block inversion is enabled
ansible.builtin.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: Assert icmp block inversion is enabled (verify not changed)
ansible.builtin.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: Assert icmp block inversion is disabled
ansible.builtin.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: Assert icmp block inversion is disabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed

View file

@ -0,0 +1,88 @@
---
# 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: Assert lo was added to trusted zone
ansible.builtin.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: Assert lo was added to trusted zone (verify not changed)
ansible.builtin.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: Assert lo was moved from trusted zone to internal zone
ansible.builtin.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: Assert lo was moved from trusted zone to internal zone (verify not changed)
ansible.builtin.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: Assert lo interface was removed from internal zone
ansible.builtin.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: Assert lo interface was removed from internal zone (verify not changed)
ansible.builtin.assert:
that:
- result is not changed

View file

@ -1,22 +1,24 @@
---
# Test playbook for the firewalld module # Test playbook for the firewalld module
# (c) 2017, Adam Miller <admiller@redhat.com> # (c) 2017, Adam Miller <admiller@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Run firewalld tests - name: Run firewalld tests
when:
- ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version('7', '>=')
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('14.04', '=='))
# Firewalld package on OpenSUSE (15+) require Python 3, so we skip on OpenSUSE running py2 on these newer distros
- not (ansible_os_family == "Suse" and ansible_distribution_major_version|int != 42 and ansible_python.version.major != 3)
- not (ansible_facts.distribution == "CentOS" and ansible_distribution_major_version is version('7', '==')) # FIXME
block: block:
- name: Ensure firewalld is installed - name: Ensure firewalld is installed
package: ansible.builtin.package:
name: firewalld name: firewalld
state: present state: present
# This doesn't work for CentOS 6 because firewalld doesn't exist in CentOS6 # This doesn't work for CentOS 6 because firewalld doesn't exist in CentOS6
- name: Check to make sure the firewalld python module is available.
shell: "{{ansible_python.executable}} -c 'import firewall'"
register: check_output
ignore_errors: true
- name: Enable dbus-broker daemon - name: Enable dbus-broker daemon
service: ansible.builtin.service:
name: dbus-broker name: dbus-broker
enabled: true enabled: true
state: started state: started
@ -24,27 +26,20 @@
- name: Test Online Operations - name: Test Online Operations
block: block:
- name: start firewalld - name: Start firewalld
service: ansible.builtin.service:
name: firewalld name: firewalld
state: started state: started
- import_tasks: run_all_tests.yml - name: Import test tasks
when: check_output.rc == 0 ansible.builtin.import_tasks: run_all_tests.yml
- name: Test Offline Operations - name: Test Offline Operations
block: block:
- name: stop firewalld - name: Stop firewalld
service: ansible.builtin.service:
name: firewalld name: firewalld
state: stopped state: stopped
- import_tasks: run_all_tests.yml - name: Import test tasks
when: check_output.rc == 0 ansible.builtin.import_tasks: run_all_tests.yml
when:
- ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version('7', '>=')
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('14.04', '=='))
# Firewalld package on OpenSUSE (15+) require Python 3, so we skip on OpenSUSE running py2 on these newer distros
- not (ansible_os_family == "Suse" and ansible_distribution_major_version|int != 42 and ansible_python.version.major != 3)
- not (ansible_facts.distribution == "CentOS" and ansible_distribution_major_version is version('7', '==')) # FIXME

View file

@ -0,0 +1,173 @@
---
# 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: Assert masquerade is enabled
ansible.builtin.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: Assert masquerade is enabled (verify not changed)
ansible.builtin.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: Assert masquerade is disabled
ansible.builtin.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: Assert masquerade is disabled (verify not changed)
ansible.builtin.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: Assert masquerade is enabled
ansible.builtin.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: Assert masquerade is enabled (verify not changed)
ansible.builtin.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: Assert masquerade is disabled
ansible.builtin.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: Assert masquerade is disabled (verify not changed)
ansible.builtin.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: Assert masquerade is enabled
ansible.builtin.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: Assert masquerade is enabled (verify not changed)
ansible.builtin.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: Assert masquerade is disabled
ansible.builtin.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: Assert masquerade is disabled (verify not changed)
ansible.builtin.assert:
that:
- result is not changed

View file

@ -1,9 +1,10 @@
---
# Test playbook for the firewalld module - port operations # Test playbook for the firewalld module - port operations
# (c) 2017, Adam Miller <admiller@redhat.com> # (c) 2017, Adam Miller <admiller@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: firewalld port forward test permanent enabled - name: Firewalld port forward test permanent enabled
firewalld: ansible.posix.firewalld:
port_forward: port_forward:
- port: 8080 - port: 8080
proto: tcp proto: tcp
@ -12,13 +13,13 @@
state: enabled state: enabled
register: result register: result
- name: assert firewalld port test permanent enabled worked - name: Assert firewalld port test permanent enabled worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld port test permanent enabled rerun (verify not changed) - name: Firewalld port test permanent enabled rerun (verify not changed)
firewalld: ansible.posix.firewalld:
port_forward: port_forward:
- port: 8080 - port: 8080
proto: tcp proto: tcp
@ -27,13 +28,13 @@
state: enabled state: enabled
register: result register: result
- name: assert firewalld port test permanent enabled rerun worked (verify not changed) - name: Assert firewalld port test permanent enabled rerun worked (verify not changed)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed
- name: firewalld port test permanent disabled - name: Firewalld port test permanent disabled
firewalld: ansible.posix.firewalld:
port_forward: port_forward:
- port: 8080 - port: 8080
proto: tcp proto: tcp
@ -42,13 +43,13 @@
state: disabled state: disabled
register: result register: result
- name: assert firewalld port test permanent disabled worked - name: Assert firewalld port test permanent disabled worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld port test permanent disabled rerun (verify not changed) - name: Firewalld port test permanent disabled rerun (verify not changed)
firewalld: ansible.posix.firewalld:
port_forward: port_forward:
- port: 8080 - port: 8080
proto: tcp proto: tcp
@ -57,7 +58,7 @@
state: disabled state: disabled
register: result register: result
- name: assert firewalld port test permanent disabled rerun worked (verify not changed) - name: Assert firewalld port test permanent disabled rerun worked (verify not changed)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed

View file

@ -1,108 +1,109 @@
---
# Test playbook for the firewalld module - port operations # Test playbook for the firewalld module - port operations
# (c) 2017, Adam Miller <admiller@redhat.com> # (c) 2017, Adam Miller <admiller@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: firewalld port range test permanent enabled - name: Firewalld port range test permanent enabled
firewalld: ansible.posix.firewalld:
port: 5500-6950/tcp port: 5500-6850/tcp
permanent: true permanent: true
state: enabled state: enabled
register: result register: result
- name: assert firewalld port range test permanent enabled worked - name: Assert firewalld port range test permanent enabled worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld port range test permanent enabled rerun (verify not changed) - name: Firewalld port range test permanent enabled rerun (verify not changed)
firewalld: ansible.posix.firewalld:
port: 5500-6950/tcp port: 5500-6850/tcp
permanent: true permanent: true
state: enabled state: enabled
register: result register: result
- name: assert firewalld port range test permanent enabled rerun worked (verify not changed) - name: Assert firewalld port range test permanent enabled rerun worked (verify not changed)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed
- name: firewalld port test permanent enabled - name: Firewalld port test permanent enabled
firewalld: ansible.posix.firewalld:
port: 6900/tcp port: 6900/tcp
permanent: true permanent: true
state: enabled state: enabled
register: result register: result
- name: assert firewalld port test permanent enabled worked - name: Assert firewalld port test permanent enabled worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld port test permanent enabled - name: Firewalld port test permanent enabled
firewalld: ansible.posix.firewalld:
port: 6900/tcp port: 6900/tcp
permanent: true permanent: true
state: enabled state: enabled
register: result register: result
- name: assert firewalld port test permanent enabled worked - name: Assert firewalld port test permanent enabled worked
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed
- name: firewalld port test disabled - name: Firewalld port test disabled
firewalld: ansible.posix.firewalld:
port: "{{ item }}" port: "{{ item }}"
permanent: true permanent: true
state: disabled state: disabled
loop: loop:
- 6900/tcp - 6900/tcp
- 5500-6950/tcp - 5500-6850/tcp
- name: firewalld port test permanent enabled - name: Firewalld port test permanent enabled
firewalld: ansible.posix.firewalld:
port: 8081/tcp port: 8081/tcp
permanent: true permanent: true
state: enabled state: enabled
register: result register: result
- name: assert firewalld port test permanent enabled worked - name: Assert firewalld port test permanent enabled worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld port test permanent enabled rerun (verify not changed) - name: Firewalld port test permanent enabled rerun (verify not changed)
firewalld: ansible.posix.firewalld:
port: 8081/tcp port: 8081/tcp
permanent: true permanent: true
state: enabled state: enabled
register: result register: result
- name: assert firewalld port test permanent enabled rerun worked (verify not changed) - name: Assert firewalld port test permanent enabled rerun worked (verify not changed)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed
- name: firewalld port test permanent disabled - name: Firewalld port test permanent disabled
firewalld: ansible.posix.firewalld:
port: 8081/tcp port: 8081/tcp
permanent: true permanent: true
state: disabled state: disabled
register: result register: result
- name: assert firewalld port test permanent disabled worked - name: Assert firewalld port test permanent disabled worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld port test permanent disabled rerun (verify not changed) - name: Firewalld port test permanent disabled rerun (verify not changed)
firewalld: ansible.posix.firewalld:
port: 8081/tcp port: 8081/tcp
permanent: true permanent: true
state: disabled state: disabled
register: result register: result
- name: assert firewalld port test permanent disabled rerun worked (verify not changed) - name: Assert firewalld port test permanent disabled rerun worked (verify not changed)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed

View file

@ -0,0 +1,66 @@
---
# Test playbook for the firewalld module - protocol operations
# (c) 2022, Robért S. Guhr <rguhr@cronon.net>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Firewalld protocol test permanent enabled
ansible.posix.firewalld:
protocol: ospf
permanent: true
state: enabled
register: result
- name: Assert firewalld protocol test permanent enabled worked
ansible.builtin.assert:
that:
- result is changed
- name: Firewalld protocol test permanent enabled rerun (verify not changed)
ansible.posix.firewalld:
protocol: ospf
permanent: true
state: enabled
register: result
- name: Assert firewalld protocol test permanent enabled rerun worked (verify not changed)
ansible.builtin.assert:
that:
- result is not changed
- name: Firewalld protocol test permanent disabled
ansible.posix.firewalld:
protocol: ospf
permanent: true
state: disabled
register: result
- name: Assert firewalld protocol test permanent disabled worked
ansible.builtin.assert:
that:
- result is changed
- name: Firewalld protocol test permanent disabled rerun (verify not changed)
ansible.posix.firewalld:
protocol: ospf
permanent: true
state: disabled
register: result
- name: Assert firewalld protocol test permanent disabled rerun worked (verify not changed)
ansible.builtin.assert:
that:
- result is not changed

View file

@ -1,23 +1,50 @@
---
# Test playbook for the firewalld module # Test playbook for the firewalld module
# (c) 2017, Adam Miller <admiller@redhat.com> # (c) 2017, Adam Miller <admiller@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Ensure /run/firewalld exists - name: Ensure /run/firewalld exists
file: ansible.builtin.file:
path: /run/firewalld path: /run/firewalld
state: directory state: directory
mode: "0755"
# firewalld service operation test cases # firewalld service operation test cases
- include_tasks: service_test_cases.yml - name: Include service test cases for firewalld module
ansible.builtin.include_tasks: service_test_cases.yml
# firewalld protocol operation test cases
- name: Include protocol test cases for firewalld module
ansible.builtin.include_tasks: protocol_test_cases.yml
# firewalld port operation test cases # firewalld port operation test cases
- include_tasks: port_test_cases.yml - name: Include port test cases for firewalld module
ansible.builtin.include_tasks: port_test_cases.yml
# firewalld source operation test cases # firewalld source operation test cases
- include_tasks: source_test_cases.yml - name: Include source test cases for firewalld module
ansible.builtin.include_tasks: source_test_cases.yml
# firewalld zone operation test cases
- name: Include zone test cases for firewalld module
ansible.builtin.include_tasks: zone_test_cases.yml
# firewalld zone target operation test cases # firewalld zone target operation test cases
- include_tasks: zone_target_test_cases.yml - name: Include zone target test cases for firewalld module
ansible.builtin.include_tasks: zone_target_test_cases.yml
# firewalld port forwarding operation test cases # firewalld port forwarding operation test cases
- include_tasks: port_forward_test_cases.yml - name: Include port forward target test cases for firewalld module
ansible.builtin.include_tasks: port_forward_test_cases.yml
# firewalld masquerade operation test cases
- name: Include masquerade target test cases for firewalld module
ansible.builtin.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
# firewalld interface operation test cases
- name: Include interface target test cases for firewalld module
ansible.builtin.include_tasks: interface_test_cases.yml

View file

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

View file

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

View file

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

View file

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

View file

@ -1,52 +1,53 @@
---
# Test playbook for the firewalld_info module # Test playbook for the firewalld_info module
# (c) 2021, Hideki Saito <saito@fgrep.org> # (c) 2021, Hideki Saito <saito@fgrep.org>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# This test is based on the integration test playbook for firewalld module. # This test is based on the integration test playbook for firewalld module.
- name: Run firewalld tests - name: Run firewalld tests
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: block:
- name: Ensure firewalld is installed - name: Ensure firewalld is installed
package: ansible.builtin.package:
name: firewalld name: firewalld
state: present state: present
# This doesn't work for CentOS 6 because firewalld doesn't exist in CentOS6 # This doesn't work for CentOS 6 because firewalld doesn't exist in CentOS6
- name: Check to make sure the firewalld python module is available. - name: Check to make sure the firewalld python module is available.
shell: "{{ansible_python.executable}} -c 'import firewall'" ansible.builtin.command: "{{ ansible_python.executable }} -c 'import firewall'"
changed_when: false
register: check_output_firewall register: check_output_firewall
ignore_errors: true ignore_errors: true
- name: Check to make sure the dbus python module is available. - name: Check to make sure the dbus python module is available.
shell: "{{ansible_python.executable}} -c 'import dbus'" ansible.builtin.command: "{{ ansible_python.executable }} -c 'import dbus'"
changed_when: false
register: check_output_dbus register: check_output_dbus
ignore_errors: true ignore_errors: true
- name: Test Online Operations - name: Test Online Operations
block: block:
- name: start firewalld - name: Start firewalld
service: ansible.builtin.service:
name: firewalld name: firewalld
state: started state: started
- import_tasks: run_tests_in_started.yml - name: Import test tasks from run_tests_in_started.yml
ansible.builtin.import_tasks: run_tests_in_started.yml
- name: Test Offline Operations
when: when:
- check_output_firewall.rc == 0 - check_output_firewall.rc == 0
- check_output_dbus.rc == 0 - check_output_dbus.rc == 0
- name: Test Offline Operations
block: block:
- name: stop firewalld - name: Stop firewalld
service: ansible.builtin.service:
name: firewalld name: firewalld
state: stopped state: stopped
- import_tasks: run_tests_in_stopped.yml - name: Import test tasks from run_tests_in_stopped.yml
when: ansible.builtin.import_tasks: run_tests_in_stopped.yml
- 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,32 +1,33 @@
---
# Test playbook for the firewalld_info module # Test playbook for the firewalld_info module
# (c) 2021, Hideki Saito <saito@fgrep.org> # (c) 2021, Hideki Saito <saito@fgrep.org>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Ensure firewalld_info without options - name: Ensure firewalld_info without options
firewalld_info: ansible.posix.firewalld_info:
register: result register: result
- name: Assert collected_zones and undefined_zones - name: Assert collected_zones and undefined_zones
assert: ansible.builtin.assert:
that: that:
- 'result.collected_zones and not result.undefined_zones' - result.collected_zones and not result.undefined_zones
- name: Ensure firewalld_info with active_zones - name: Ensure firewalld_info with active_zones
firewalld_info: ansible.posix.firewalld_info:
active_zones: yes active_zones: true
register: result register: result
- name: Assert turn active_zones true - name: Assert turn active_zones true
assert: ansible.builtin.assert:
that: that:
- name: Ensure firewalld_zones with zone list - name: Ensure firewalld_zones with zone list
firewalld_info: ansible.posix.firewalld_info:
zones: zones:
- public - public
- invalid_zone - invalid_zone
register: result register: result
- name: Assert specified zones - name: Assert specified zones
assert: ansible.builtin.assert:
that: that:

View file

@ -1,40 +1,41 @@
---
# Test playbook for the firewalld_info module # Test playbook for the firewalld_info module
# (c) 2021, Hideki Saito <saito@fgrep.org> # (c) 2021, Hideki Saito <saito@fgrep.org>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Ensure firewalld_info without options - name: Ensure firewalld_info without options
firewalld_info: ansible.posix.firewalld_info:
register: result register: result
ignore_errors: yes ignore_errors: true
- name: Assert firewalld_info fails if firewalld is not running. - name: Assert firewalld_info fails if firewalld is not running.
assert: ansible.builtin.assert:
that: that:
- result.failed - result.failed
- "'firewalld probably not be running,' in result.msg" - "'firewalld probably not be running,' in result.msg"
- name: Ensure firewalld_info with active_zones - name: Ensure firewalld_info with active_zones
firewalld_info: ansible.posix.firewalld_info:
active_zones: yes active_zones: true
register: result register: result
ignore_errors: yes ignore_errors: true
- name: Assert firewalld_info with active_zones fails if firewalld is not running. - name: Assert firewalld_info with active_zones fails if firewalld is not running.
assert: ansible.builtin.assert:
that: that:
- result.failed - result.failed
- "'firewalld probably not be running,' in result.msg" - "'firewalld probably not be running,' in result.msg"
- name: Ensure firewalld_zones with zone list - name: Ensure firewalld_zones with zone list
firewalld_info: ansible.posix.firewalld_info:
zones: zones:
- public - public
- invalid_zone - invalid_zone
register: result register: result
ignore_errors: yes ignore_errors: true
- name: Assert firewalld_info with zones list fails if firewalld is not running. - name: Assert firewalld_info with zones list fails if firewalld is not running.
assert: ansible.builtin.assert:
that: that:
- result.failed - result.failed
- "'firewalld probably not be running,' in result.msg" - "'firewalld probably not be running,' in result.msg"

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +0,0 @@
integration_tests_dependencies:
- community.general
unit_tests_dependencies:
- community.general

View file

@ -1,8 +0,0 @@
plugins/modules/synchronize.py pylint:blacklisted-name
plugins/modules/synchronize.py use-argspec-type-path
plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented
plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc
plugins/modules/synchronize.py validate-modules:undocumented-parameter
tests/utils/shippable/check_matrix.py replace-urlopen
tests/utils/shippable/timing.py shebang

View file

@ -1,8 +0,0 @@
plugins/modules/synchronize.py pylint:blacklisted-name
plugins/modules/synchronize.py use-argspec-type-path
plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented
plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc
plugins/modules/synchronize.py validate-modules:undocumented-parameter
tests/utils/shippable/check_matrix.py replace-urlopen
tests/utils/shippable/timing.py shebang

View file

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

Some files were not shown because too many files have changed in this diff Show more