217 Commits

Author SHA1 Message Date
softwarefactory-project-zuul[bot]
5f44339fa5 Merge pull request #693 from saito-hideki/pr/ci_2025120500
[CI] Update AZP CI matrix and sanity tests

SUMMARY

Update AZP CI matrix. Bump the remote target version for 2.16 and 2.17
Add ignore file for Ansible Core 2.21 for the current devel version sanity test

ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-12-09 05:56:49 +00:00
Hideki Saito
7d5aef07e2 Update AZP CI matrix and sanity test
* Update AZP CI matrix
* Add ignore file for Ansible Core 2.21
* Remove ignore lines for ansible-bad-import-from in 2.20 sanity tests

Signed-off-by: Hideki Saito <saito@fgrep.org>
2025-12-09 05:23:05 +00:00
softwarefactory-project-zuul[bot]
b39ee97ccc Merge pull request #677 from shenxianpeng/patch-1
docs: fix broken badge and restore coverage badge

SUMMARY
Replaced the outdated Shippable badge and active Codecov coverage badge, like other repos in ansible-collections org
ISSUE TYPE


Docs Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-11-28 07:14:56 +00:00
softwarefactory-project-zuul[bot]
72a6eb9729 Merge pull request #639 from Klaas-/Klaas-fix_authorized_key
Fixes #462 notice permission denied on authorized_key module

SUMMARY
As of right now the authorized_key module does not notice on an "absent" if a authorized_keys file is simply not readable to the executing user. I am trying to fix that
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
authorized_key
ADDITIONAL INFORMATION


Execute as a user that does not have access to the root users authorized keys file

- name: Delete key from root user
  ansible.posix.authorized_key:
    state: absent
    user: root
    key: ssh-rsa xxxxxxxx

- name: Delete key from root user
  become: true
  ansible.posix.authorized_key:
    state: absent
    user: root
    key: ssh-rsa xxxxxxxx

The one without become will succeed before my change and will fail with a permission denied error after my change. The 2nd task will actually remove a key from root user if become privileges are available for the executing user

Reviewed-by: Brian Coca
Reviewed-by: Klaas Demter
Reviewed-by: Felix Fontein <felix@fontein.de>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-11-28 03:25:21 +00:00
Klaas Demter
9651a19805 change result.failed==True to result is failed in check_permissions.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
2025-10-22 08:29:46 +02:00
Klaas Demter
413ab782a8 Fixes #462 notice permission denied on authorized_key module 2025-10-21 10:00:12 +02:00
softwarefactory-project-zuul[bot]
9343c6f56f Merge pull request #682 from saito-hideki/pr/ci_update_20250929
Ignore pylint errors caused by compatibility checks for six

SUMMARY
Ignore pylint errors caused by compatibility checks for six:

pylint:ansible-bad-import-from

Ansible Core 2.16 supports Python2 environment,  and six is required to maintain compatibility with Python 2.
We plan to continue supporting Ansible Core 2.16 at this time.
Additionally, removing the standalone ansible-lint test because it is already included in ansible-test sanity.
ISSUE TYPE

CI tests Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None

Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
Reviewed-by: Felix Fontein <felix@fontein.de>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-10-02 05:55:28 +00:00
saito-hideki
9dc73a686a Ignore pylint errors caused by compatibility checks for six
* This is a temporary measure until we stop covering Python2
* Skipped sanity[cannot-ignore] to keep backward compatibility with Python2
* Consolidate all ansible-lint option locations into .ansible-lint
* Fixed some typos

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-10-02 14:02:56 +09:00
softwarefactory-project-zuul[bot]
6da1331018 Merge pull request #670 from felixfontein/deprecations
Use module.warn() instead of returning warnings

SUMMARY
Returning warnings as warnings has been deprecated.
Ref: #635.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
firewalld_info
mount

Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-08-16 01:03:30 +00:00
Xianpeng Shen
cda2e0657f docs: fix broken badge and restore coverage badge 2025-08-14 14:33:30 +03:00
Felix Fontein
ab8dfefd90 Use module.warn() instead of returning warnings. 2025-08-06 06:49:32 +02:00
softwarefactory-project-zuul[bot]
b96fad5e5b Merge pull request #673 from saito-hideki/pr/ci_update_20250805
[AZP] Update CI matrix

SUMMARY
Update AZP CI matrix:

Addresses #672
Bump test container version 7.0.0
Removes Ansible Core 2.15 tests. Python 3.11 is no longer supported in Container 7.0.0.

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-08-05 23:44:46 +00:00
saito-hideki
2d350e6073 AZP update CI matrix
* Addresses #672
* Bump test container version 7.0.0
* Removes Ansible Core 2.15 tests. Python 3.11 is no longer supported in Container 7.0.0.

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-08-05 14:30:30 +09:00
softwarefactory-project-zuul[bot]
ea6ef5c775 Merge pull request #665 from saito-hideki/pr/readme_20250728
Update README for release of Ansible Core 2.19

SUMMARY
README updated with the release of Ansible Core 2.19

https://docs.ansible.com/ansible/devel/roadmap/ROADMAP_2_19.html

ISSUE TYPE

Docs Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
N/A
2025-07-28 08:38:22 +00:00
saito-hideki
9007e20b2f README updated with the release of Ansible Core 2.19
* https://docs.ansible.com/ansible/devel/roadmap/ROADMAP_2_19.html

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-07-28 17:12:02 +09:00
softwarefactory-project-zuul[bot]
508e3d920f Merge pull request #666 from saito-hideki/pr/azp_update_matrix_20250728
[AZP][CI] Update AZP matrix to follow ansible-test changes

SUMMARY
Update AZP matrix to follow ansible-test changes

ansible/ansible/pull/85558
ansible/ansible/pull/85561
ansible/ansible/pull/85562

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-07-28 06:32:06 +00:00
saito-hideki
18e023dd77 Update AZP matrix to follow ansible-test changes
* https://github.com/ansible/ansible/pull/85558
* https://github.com/ansible/ansible/pull/85561
* https://github.com/ansible/ansible/pull/85562

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-07-28 14:59:14 +09:00
softwarefactory-project-zuul[bot]
d3204df536 Merge pull request #660 from saito-hideki/pr_azp_syntax
[AZP] Fixed syntax error in AZP settings

SUMMARY
Fixed syntax error in AZP settings
ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-07-17 03:39:40 +00:00
Hideki SAITO
162e72182f Fixed syntax error in azurepileline settings
Signed-off-by: Hideki SAITO <hsaito@macallan.home.fgrep.org>
2025-07-17 12:16:09 +09:00
softwarefactory-project-zuul[bot]
1c1dd005c8 Merge pull request #654 from saito-hideki/pr/bump_core_version_220
[CI] bump ansible-core version to 2.20 for devel branch

SUMMARY
Bump ansible-core version to 2.20 for devel branch.

Bump devel test to ansible-core 2.19
Add ansible-core 2.18 to the stable list

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-07-10 01:00:47 +00:00
saito-hideki
40c27e2bee CI - bump ansible-core version
* bump devel to ansible-core 2.20
* add ansible-core 2.19 to stable list

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-07-10 09:35:28 +09:00
softwarefactory-project-zuul[bot]
c273ac2a01 Merge pull request #650 from felixfontein/callback
profile_* callbacks: avoid deprecated/deleted functions

SUMMARY
The profile_roles and profile_tasks callbacks define methods playbook_on_setup and playbook_on_stats which have been deleted/deprecated:

playbook_on_stats has been deprecated, v2_playbook_on_stats should be used instead (that one has already been there for many years: ansible/ansible@ba0e532 was added in 2015).
playbook_on_setup has been deleted (ansible/ansible@eec57ec), and its v2 variant was already deleted in 2017: ansible/ansible@59d5481

Ref: #635
ISSUE TYPE

Bugfix Pull Request
Feature Pull Request

COMPONENT NAME
profile_roles
profile_tasks

Reviewed-by: Abhijeet Kasurde
Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-07-08 05:47:53 +00:00
Felix Fontein
f978998521 Add changelog fragment. 2025-06-28 16:34:47 +02:00
Felix Fontein
c319c856ed Avoid deprecated/deleted callback functions. 2025-06-28 16:29:29 +02:00
softwarefactory-project-zuul[bot]
cdb442ea48 Merge pull request #646 from saito-hideki/issue/642
[AZP] Add RHEL10 environment to CI matrix

SUMMARY
Add RHEL10 environment to CI matrix

Fixes #642

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
N/A
2025-06-09 10:07:53 +00:00
saito-hideki
f977bffff2 [AZP] Add RHEL10 environment to CI matrix
* Fixes #642

Signed-off-by: saito-hideki <saito@fgrep.org>
2025-06-09 18:43:43 +09:00
softwarefactory-project-zuul[bot]
dabaca4b70 Merge pull request #640 from Klaas-/Klaas-fixCI
Remove EOL FreeBSD 13.2 from CI

SUMMARY

CI seems to be failing for a month, reason is that freebsd 13.2 is no longer valid.
See ansible-collections/community.general#8607

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
CI

Reviewed-by: Felix Fontein <felix@fontein.de>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-05-20 00:22:19 +00:00
Klaas Demter
26b9b1438d Remove EOL FreeBSD 13.2 from CI 2025-05-19 18:10:38 +02:00
softwarefactory-project-zuul[bot]
1994b2cf1c Merge pull request #626 from pablomh/datetime_format
plugins/callback/profile_tasks.py: Add option to provide a different date/time format

SUMMARY
The new datetime_format key will offer the possibility of providing a different date/time format than the default one ('%A %d %B %Y  %H:%M:%S %z').

The iso8601 value can be used as an '%Y-%m-%dT%H:%M:%S.%f' alias (format of the ISO 8601 date/time standard).

The code has changed from using the time API to the datetime one in order to support sub-second precision (needed by the ISO 8601 format, for example).
Fixes: #279
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
plugins/callback/profile_tasks.py
ADDITIONAL INFORMATION

Output with no key which keeps current behavior:

TASK [Import subscription manifest] *******************************************************************************************************************************************************************************************************************************************************************
Thursday 10 April 2025  00:52:11 +0200 (0:00:17.416)       0:00:17.453 ******** 
changed: [localhost]


Output with datetime_format = 'iso8601':

TASK [Import subscription manifest] *******************************************************************************************************************************************************************************************************************************************************************
2025-04-10T00:55:19.967718 (0:00:15.664)       0:00:15.691 ******************** 
changed: [localhost]


Output with datetime_format = '%Y-%m-%dT%H:%M:%S.%f%z' (ISO 8601 with UTC offset information):

TASK [Import subscription manifest] *******************************************************************************************************************************************************************************************************************************************************************
2025-04-10T00:57:49.290347+0200 (0:00:16.265)       0:00:16.293 *************** 
changed: [localhost]

Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-04-25 06:44:25 +00:00
Pablo Méndez Hernández
2f224e6a6a Add option to provide a different date/time format
The new `datetime_format` key will offer the possibility of
providing a different date/time format than the default one
(`'%A %d %B %Y  %H:%M:%S %z'`).

- The `iso8601` value can be used as an `'%Y-%m-%dT%H:%M:%S.%f'`
  alias (format of the ISO 8601 date/time standard).

The code has changed from using the `time` API to the `datetime`
one in order to support sub-second precision (needed by the ISO
8601 format, for example).

Signed-off-by: Pablo Mendez Hernandez <pablomh@redhat.com>
2025-04-17 15:57:00 +02:00
softwarefactory-project-zuul[bot]
96ec2097cc Merge pull request #631 from saito-hideki/issue/630
Fixes issue related to latest ansible-core devel branch

SUMMARY
Fixes a bug related to updating the ansible-core devel branch.

Fixes incorrect load path for json module in cgroup_perf_recap
Remove unnecessary condition from seboolean integration tests
Optimize conditions for selinux integration tests
Fixes #630

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix.cgroup_perf_recap

ADDITIONAL INFORMATION
N/A
2025-04-17 00:34:06 +00:00
Hideki Saito
7b9b1f4957 Fixes issue related to updating the ansible-core devel branch
* Fixes incorrect load path for json module in cgroup_perf_recap
* Remove unnecessary condition from seboolean integration tests
* Optimize conditions for selinux integration tests
* Fixes #630

Signed-off-by: Hideki Saito <saito@fgrep.org>
2025-04-17 00:11:31 +00:00
softwarefactory-project-zuul[bot]
f0b5f039d3 Merge pull request #613 from simonLeary42/rewrite-mount-tests
improve mount integration tests

SUMMARY

added check mode tests (assert no changes made)
added comments to make file less scary

ISSUE TYPE
tests
COMPONENT NAME
mount
ADDITIONAL INFORMATION

Reviewed-by: Abhijeet Kasurde
Reviewed-by: Hideki Saito <saito@fgrep.org>
2025-04-10 03:58:40 +00:00
softwarefactory-project-zuul[bot]
5ceb40b600 Merge pull request #618 from saito-hideki/issie/612
[AZP] Remove ubuntu20.04 from CI tests

SUMMARY
Remove ubuntu20.04 from CI tests

Fixes #612

ISSUE TYPE

CI Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2025-03-28 01:32:12 +00:00
Hideki Saito
2cec8cbed5 [CI] Remove ubuntu20.04 from CI tests
* Fixes #612

Signed-off-by: Hideki Saito <saito@fgrep.org>
2025-03-28 10:04:16 +09:00
Pavel Knoblokh
1b8aeb03cb sysctl: Add custom sysctl file example (#606) 2025-03-26 19:21:08 -07:00
Abhijeet Kasurde
eead50b287 Apply suggestions from code review 2025-03-26 12:36:08 -07:00
Simon Leary
4ff0e3aa13 remove assertion of changed 2025-03-26 15:20:42 -04:00
Simon Leary
979f00ce75 fix lint errors 2025-03-26 15:18:35 -04:00
softwarefactory-project-zuul[bot]
ed3d322fd5 Merge pull request #617 from Akasurde/ci_fix
[CI] update test containers

SUMMARY
Signed-off-by: Abhijeet Kasurde Akasurde@redhat.com
ISSUE TYPE

Bugfix Pull Request

Reviewed-by: Matt Clay
2025-03-26 19:00:30 +00:00
Abhijeet Kasurde
d9f54eb9d4 [CI] update test containers
Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
2025-03-26 09:02:59 -07:00
Simon Leary
7d8da00f79 add (check mode) to task name 2025-03-06 10:46:57 -05:00
Simon Leary
f087d58cbe fix bugs 2025-03-05 00:39:46 +00:00
Simon Leary
eb740e97d4 add check mode tests, add comments 2025-03-05 00:33:11 +00:00
softwarefactory-project-zuul[bot]
44a2151dbf Merge pull request #604 from saito-hideki/pr/bump_up_version_3.0.0
Bump version to 3.0.0 for the next release

SUMMARY
Bump version to 3.0.0 for the next release on main branch:

Fixes #603

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION

None
2024-12-10 08:59:03 +00:00
Hideki Saito
83288b9020 Bump version to 3.0.0 for the next release
* Fixes #603

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-12-10 17:30:22 +09:00
softwarefactory-project-zuul[bot]
4c6898ee6e Merge pull request #600 from saito-hideki/release_2.0.0
Release 2.0.0 commit

SUMMARY
Release 2.0.0 commit

Release Plan #149

ISSUE TYPE
Feature Pull Request
COMPONENT NAME
ansible.posix
ADDITIONAL INFORMATION
This will be merged on 5 December if there are no problems

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
2024-12-05 00:48:30 +00:00
Hideki Saito
f5eae12146 Release 2.0.0 commit
Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-12-04 09:46:44 +09:00
softwarefactory-project-zuul[bot]
f632fad9d4 Merge pull request #598 from saito-hideki/issue/586
[Breaking Change] [firewalld] Change type of icmp_block_inversion option from str to bool

SUMMARY
Changed the type of icmp_block_inversion option from str to bool

Fixes #586

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix.firewalld

ADDITIONAL INFORMATION
Related  #582 and #584

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
2024-12-02 23:50:26 +00:00
softwarefactory-project-zuul[bot]
74edb72249 Merge pull request #597 from vbotka/mount-fix-comment
Remove comment from fstab entry on updating.

SUMMARY
Fix #595.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ansible.posix.mount
ADDITIONAL INFORMATION

Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: Vladimir Botka <vbotka@gmail.com>
2024-11-29 02:59:28 +00:00
Vladimir Botka
91129ed381 Fix changelog fragment module name. 2024-11-29 03:34:14 +01:00
Vladimir Botka
7b8d627552 Changelog fragment added. 2024-11-28 08:17:41 +01:00
Hideki Saito
6175a5028b Change type of icmp_block_inversion option from str to bool
* Fixes #586

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-11-28 14:19:20 +09:00
Vladimir Botka
8e34860d6c Fix #595. Remove comment from fstab entry on updating. 2024-11-21 20:54:27 +01:00
softwarefactory-project-zuul[bot]
1b9ae1c77f Merge pull request #593 from saito-hideki/pr/replace_freebsd
Replace FreeBSD 13.3 with 13.4 and add FreeBSD 14.1 for devel

SUMMARY
Replace FreeBSD 13.3 with 13.4 and add FreeBSD 14.1 for integration test environments for ansible-core devel branch.
ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION

None
2024-11-14 05:45:26 +00:00
Hideki Saito
ae95adcfdc Replace FreeBSD 13.3 with 13.4 and add FreeBSD 14.1 for devel
It's for integration test environments for ansible-core devel.

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-11-14 14:23:53 +09:00
softwarefactory-project-zuul[bot]
c654bf0b4c Merge pull request #588 from saito-hideki/pr/enable_test_for_devel
[CI] enabled integration tests for devel branch

SUMMARY
Enabled integration tests for devel branch

Remote tests
Docker tests

ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2024-11-06 02:32:26 +00:00
Hideki Saito
04283b5993 [CI] enable integration tests for devel branch
* Remote tests
* Docker tests

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-11-06 11:07:13 +09:00
softwarefactory-project-zuul[bot]
b0097bd14c Merge pull request #587 from saito-hideki/issue/587
Update README to cover RH guidelines

SUMMARY
This PR updates README.md to cover Red Hat guidelines
Also, this new content aligns with the community template content guidelines.

Fixes #585

ISSUE TYPE

Docs Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-11-05 14:08:33 +00:00
Hideki Saito
b991f4f9af Update README to cover RH guidelines
* Fixes #585

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-11-05 21:30:07 +09:00
softwarefactory-project-zuul[bot]
5eacaba86d Merge pull request #584 from saito-hideki/issue/582
Changed the type of the forward and masquerade options from str to bool

SUMMARY
The forward and masquerade options for the firewall module takes either True or False as a value.
Currently, it is defined as a string, but it should be a boolean.

Fixes #582

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ansible.posix.firewalld

ADDITIONAL INFORMATION
None

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Andrew Klychkov <aklychko@redhat.com>
2024-10-31 23:26:30 +00:00
Hideki Saito
8b611775d6 Changed the type of forward and masquerade options from str to bool
* Breaking Change
* Fixes #582

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-10-31 16:06:10 +09:00
softwarefactory-project-zuul[bot]
9171b7fcf1 Merge pull request #581 from saito-hideki/pr/selinux_integration_test
[CI] Modify conditions for selinux integratuion tests

SUMMARY
Conditions for selinux integration tests have been modified to be more accurate.
This fix only affects integration tests, so it will not affect module behavior.
ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix.selinux

ADDITIONAL INFORMATION
None
2024-10-15 23:58:44 +00:00
Hideki Saito
2f095566c7 Modify conditions for selinux integratuion tests
Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-10-15 17:15:51 +09:00
softwarefactory-project-zuul[bot]
daca208c0b Merge pull request #576 from saito-hideki/bump_version_2.0.0
Bump version info to 2.0.0 on main branch

SUMMARY
Bump version 2.0.0 for the next release.

fixes #575

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

galaxy.yml

ADDITIONAL INFORMATION
None
2024-10-11 07:44:38 +00:00
Hideki Saito
4d928119de Bump version 2.0.0 for the next release
* main branch

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-10-11 16:20:58 +09:00
Hideki Saito
906bbb88b7 Revert "Revert "Merge pull request #568 from abakanovskii/feature/add_path_option_authorized_key""
This reverts commit 098b5bee70.
2024-10-09 15:41:37 +09:00
Hideki Saito
57be05289c Revert "Revert "Merge pull request #387 from ansiblejunky/fix-callback-output""
This reverts commit 3a085b0b10.
2024-10-09 15:41:22 +09:00
Hideki Saito
9df5aac2a5 Revert "Revert "Merge pull request #556 from Akasurde/i350""
This reverts commit cd43bd10bb.
2024-10-09 15:36:53 +09:00
Hideki Saito
098b5bee70 Revert "Merge pull request #568 from abakanovskii/feature/add_path_option_authorized_key"
This reverts commit 0821768bcb, reversing
changes made to 5321a9ecb5.
2024-10-09 15:33:16 +09:00
Hideki Saito
3a085b0b10 Revert "Merge pull request #387 from ansiblejunky/fix-callback-output"
This reverts commit f4baa4c6d8, reversing
changes made to 0821768bcb.
2024-10-09 15:32:45 +09:00
Hideki Saito
cd43bd10bb Revert "Merge pull request #556 from Akasurde/i350"
This reverts commit 9a2ddcd713, reversing
changes made to 7d219a7e05.
2024-10-09 15:32:23 +09:00
softwarefactory-project-zuul[bot]
9cf2d8cc48 Merge pull request #365 from copyrights/last_wins
mount: remove boot exception if defaults in opts

SUMMARY

There is no need for an exception on defaults option when adding noauto. Mount is implemented as last win.
from mount(8):
       If you want to override mount options from /etc/fstab, you have to use the -o option:

          mount device|dir -o options

       and then the mount options from the command line will be appended to the list of options from /etc/fstab. This default behaviour can be changed using the --options-mode command-line option. The usual behavior is that the last
       option wins if there are conflicting ones.


Fixes #364
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME


ansible.posix.mount

ADDITIONAL INFORMATION

Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-10-04 06:21:14 +00:00
copyrights
2041e7f918 mount: remove boot exception if defaults in opts 2024-10-04 14:39:04 +09:00
softwarefactory-project-zuul[bot]
f4baa4c6d8 Merge pull request #387 from ansiblejunky/fix-callback-output
Fix callback output to align header with roles, tasks and play RECAP

SUMMARY
All three callback plugins (timer, roles, tasks) do not produce headers in the output that align with how we do "PLAY RECAP *********" that is generated by the "default" output callback. So these changes are provided to align the callback plugins and have a clean output that is much more readable.
Note, the asterisks are generated just as how they are for "PLAY RECAP", where it extends to the end of the terminal window.
I am considering this as a "bug" in that the output was never aligned, instead of a feature since this does not provide any new feature per-se.
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ansible.posix.timer
ansible.posix.profile_tasks
ansible.posix.profile_roles
ADDITIONAL INFORMATION


The new output is shown below. You can see the headers are now all the same and broken down by PLAY, ROLE, TASKS, and PLAYBOOK RECAP.

PLAY RECAP ***************************************************************************************************************************************************************************************
localhost                  : ok=14   changed=2    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   


ROLE RECAP ***************************************************************************************************************************************************************************************
awx.awx.subscriptions --------------------------------------------------- 4.81s
users ------------------------------------------------------------------- 2.89s
labels ------------------------------------------------------------------ 2.86s
settings ---------------------------------------------------------------- 2.46s
credential_types -------------------------------------------------------- 2.27s
organizations ----------------------------------------------------------- 2.21s
teams ------------------------------------------------------------------- 2.21s
awx.awx.license --------------------------------------------------------- 1.49s
dispatch ---------------------------------------------------------------- 0.58s
credentials ------------------------------------------------------------- 0.03s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
total ------------------------------------------------------------------ 21.80s

TASKS RECAP **************************************************************************************************************************************************************************************
Get subscriptions with a filter ----------------------------------------------------------------------------------------------------------------------------------------------------------- 4.81s
redhat_cop.controller_configuration.users : Configure Users | Wait for finish the Users creation ------------------------------------------------------------------------------------------ 1.93s
redhat_cop.controller_configuration.labels : Configure Labels | Wait for finish the Label creation ---------------------------------------------------------------------------------------- 1.91s
redhat_cop.controller_configuration.settings : Configure Settings | Wait for finish the Settings creation --------------------------------------------------------------------------------- 1.75s
redhat_cop.controller_configuration.teams : Configure Teams | Wait for finish the Teams creation ------------------------------------------------------------------------------------------ 1.63s
redhat_cop.controller_configuration.organizations : Configure Controller Organizations | Wait for finish the organization creation -------------------------------------------------------- 1.62s
Attach to a pool -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1.49s
redhat_cop.controller_configuration.credential_types : Add Credential Types --------------------------------------------------------------------------------------------------------------- 1.32s
redhat_cop.controller_configuration.users : Add controller user --------------------------------------------------------------------------------------------------------------------------- 0.96s
redhat_cop.controller_configuration.labels : Add a label to Controller -------------------------------------------------------------------------------------------------------------------- 0.95s
redhat_cop.controller_configuration.credential_types : Configure Controller Credential Types | Wait for finish the credential types creation ---------------------------------------------- 0.94s
redhat_cop.controller_configuration.settings : Update Ansible Controller Settings from dictionary or list of dictionaries ----------------------------------------------------------------- 0.70s
redhat_cop.controller_configuration.organizations : Add organizations --------------------------------------------------------------------------------------------------------------------- 0.59s
redhat_cop.controller_configuration.teams : Create Ansible Controller Team ---------------------------------------------------------------------------------------------------------------- 0.58s
Run redhat_cop.controller_configuration.{{ __role.role }} role ---------------------------------------------------------------------------------------------------------------------------- 0.58s
redhat_cop.controller_configuration.credentials : Add Credentials ------------------------------------------------------------------------------------------------------------------------- 0.03s

PLAYBOOK RECAP ***********************************************************************************************************************************************************************************
Playbook run took 0 days, 0 hours, 0 minutes, 21 seconds


Current output (how it is today) for comparison:
PLAY RECAP ***************************************************************************************************************************************************************************************
localhost                  : ok=14   changed=2    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Playbook run took 0 days, 0 hours, 0 minutes, 23 seconds
Tuesday 20 September 2022  15:00:49 -0700 (0:00:00.038)       0:00:23.039 ***** 
=============================================================================== 
Get subscriptions with a filter ----------------------------------------------------------------------------------------------------------------------------------------------------------- 5.49s
redhat_cop.controller_configuration.labels : Configure Labels | Wait for finish the Label creation ---------------------------------------------------------------------------------------- 1.98s
redhat_cop.controller_configuration.users : Configure Users | Wait for finish the Users creation ------------------------------------------------------------------------------------------ 1.92s
redhat_cop.controller_configuration.organizations : Configure Controller Organizations | Wait for finish the organization creation -------------------------------------------------------- 1.84s
redhat_cop.controller_configuration.settings : Configure Settings | Wait for finish the Settings creation --------------------------------------------------------------------------------- 1.78s
redhat_cop.controller_configuration.teams : Configure Teams | Wait for finish the Teams creation ------------------------------------------------------------------------------------------ 1.61s
Attach to a pool -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1.53s
redhat_cop.controller_configuration.credential_types : Add Credential Types --------------------------------------------------------------------------------------------------------------- 1.35s
redhat_cop.controller_configuration.users : Add controller user --------------------------------------------------------------------------------------------------------------------------- 0.95s
redhat_cop.controller_configuration.labels : Add a label to Controller -------------------------------------------------------------------------------------------------------------------- 0.95s
redhat_cop.controller_configuration.credential_types : Configure Controller Credential Types | Wait for finish the credential types creation ---------------------------------------------- 0.94s
redhat_cop.controller_configuration.settings : Update Ansible Controller Settings from dictionary or list of dictionaries ----------------------------------------------------------------- 0.73s
Run redhat_cop.controller_configuration.{{ __role.role }} role ---------------------------------------------------------------------------------------------------------------------------- 0.63s
redhat_cop.controller_configuration.organizations : Add organizations --------------------------------------------------------------------------------------------------------------------- 0.61s
redhat_cop.controller_configuration.teams : Create Ansible Controller Team ---------------------------------------------------------------------------------------------------------------- 0.60s
redhat_cop.controller_configuration.credentials : Add Credentials ------------------------------------------------------------------------------------------------------------------------- 0.04s
Tuesday 20 September 2022  15:00:49 -0700 (0:00:00.043)       0:00:23.041 ***** 
=============================================================================== 
awx.awx.subscriptions --------------------------------------------------- 5.49s
labels ------------------------------------------------------------------ 2.93s
users ------------------------------------------------------------------- 2.88s
settings ---------------------------------------------------------------- 2.51s
organizations ----------------------------------------------------------- 2.45s
credential_types -------------------------------------------------------- 2.29s
teams ------------------------------------------------------------------- 2.21s
awx.awx.license --------------------------------------------------------- 1.53s
dispatch ---------------------------------------------------------------- 0.63s
credentials ------------------------------------------------------------- 0.04s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
total ------------------------------------------------------------------ 22.95s

Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-10-02 06:44:04 +00:00
John
afa724ba8a Improve callback output to align header with roles, tasks and play RECAP 2024-10-02 15:08:03 +09:00
softwarefactory-project-zuul[bot]
0821768bcb Merge pull request #568 from abakanovskii/feature/add_path_option_authorized_key
authorized_key: Allow local path to a key

SUMMARY

Add option to specify an absolute path to file with SSH key(s) for authorized_key

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

authorized_key

ADDITIONAL INFORMATION


Before this change you would need to get key using ansible.builtin.slurp or something like ansible.builtin.command: cat <file> with register
I tried to keep it as simple as possible

# Now this is possible
- name: Set authorized keys taken from path
  ansible.posix.authorized_key:
    user: charlie
    state: present
    key: /home/charlie/.ssh/id_rsa.pub

Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: alexander
2024-09-30 07:07:25 +00:00
Александр Бакановский
5f3f8514eb Allow remote path for authorized_key 2024-09-30 09:40:03 +03:00
softwarefactory-project-zuul[bot]
5321a9ecb5 Merge pull request #571 from saito-hideki/pr/bump_core_version
[CI] bump ansible-core version to 2.19 for devel branch

SUMMARY

bump devel test to ansible-core 2.19
add ansible-core 2.18 to the stable list (CI only covers sanity tests at the moment)

ISSUE TYPE

CI Pull Request

COMPONENT NAME
ansible.posix
ADDITIONAL INFORMATION
None
2024-09-25 01:24:12 +00:00
Hideki Saito
7194b6bb13 CI - bump ansible-core version
* bump devel test to ansible-core 2.19
* add ansible-core 2.18 to stable list but CI only covers sanity test at the moment.

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-09-25 09:37:42 +09:00
softwarefactory-project-zuul[bot]
a85108e25e Merge pull request #570 from saito-hideki/pr/AAP-29225
Fixed to set ACLs on paths mounted with NFSv4 correctly

SUMMARY
Fixed to set ACLs on paths mounted with NFSv4 correctly.

Fixed #240

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ansible.posix.acl
ADDITIONAL INFORMATION
None
2024-09-20 05:44:24 +00:00
Hideki Saito
c353e43a90 Fixed to set ACLs on paths mounted with NFSv4 correctly
* Fixed #240

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-09-20 10:10:15 +09:00
softwarefactory-project-zuul[bot]
7e4d5dd7a9 Merge pull request #567 from saito-hideki/pr/remove_version_added
Remove wrong version_added section from mount module

SUMMARY
Remove the wrong version_added section from the mount module. It's not the collection version; it should be the ansible-core version.
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
ansible.posix.mount
ADDITIONAL INFORMATION

None
2024-09-13 06:44:06 +00:00
Hideki Saito
e05b8507a4 Remove wrong version_added section from mount module
Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-09-13 15:15:04 +09:00
softwarefactory-project-zuul[bot]
4f0114eb57 Merge pull request #566 from saito-hideki/pr/bump_up_version_1.6.1
Bump version to 1.6.1 to prepare the next release

SUMMARY

Bump version to 1.6.1 to prepare the next release
Update document site link

ISSUE TYPE

Docs Pull Request

COMPONENT NAME
ansible.posix
ADDITIONAL INFORMATION
None
2024-09-12 02:13:53 +00:00
Hideki Saito
6ab2053005 Maintain galaxy.yml
* Bump version to 1.6.1 to prepare the next release
* Update document site link

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-09-12 10:41:07 +09:00
softwarefactory-project-zuul[bot]
e26d9664ba Merge pull request #565 from saito-hideki/release_1.6.0
Release 1.6.0 commit

SUMMARY
Release 1.6.0 commit

Fixed #559

ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ansible.posix
ADDITIONAL INFORMATION
This will be merged on 12 September if there are no problems
2024-09-12 00:12:39 +00:00
Hideki Saito
97c022871b Release 1.6.0 commit
Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-09-11 12:12:05 +09:00
softwarefactory-project-zuul[bot]
d968ac441e Merge pull request #563 from dtvillafana/main
(feat) add no_log option for 'opts' parameter

SUMMARY

Allows you to set no_log on just the opts parameter.
This is useful for CIFS/SMB mounts that would otherwise leak secrets.

Adds feature from issue: . #497
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

mount

Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-09-11 02:27:00 +00:00
dvillafana
e00a4299c1 (feat) add no_log options for 'opts' parameter
* Fixed #497
2024-09-11 11:04:16 +09:00
softwarefactory-project-zuul[bot]
0ed72d0004 Merge pull request #361 from k3it/main
maintain proper formating of the remote paths when defined as user@ho…

…st:/... or host:/...
SUMMARY

update  _format_rsync_rsh_target for proper handling of remote rsh/ssh paths.  fixes #360

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ansible.posix.synchronize

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-09-09 09:39:57 +00:00
k3it
4efdb43ccd maintain proper formating of the remote paths when defined as user@host:/... or host:/...
* fixes #360
2024-09-09 18:08:27 +09:00
softwarefactory-project-zuul[bot]
52d140895b Merge pull request #548 from gfokkema/main
Firewalld: Add functionality to set forwarding

SUMMARY

Adds firewalld functionality to do the equivalent of firewall-cmd --add-forwarding --zone={zone}.
Functionality is exactly analogous to the firewall-cmd --add-masquerade --zone={zone} already present.
Fixes #529

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

firewalld
ADDITIONAL INFORMATION


Usage:

- ansible.posix.firewalld:
    forward: true
    state: enabled
    permanent: true
    zone: internal

Reviewed-by: Abhijeet Kasurde
Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-09-09 08:11:26 +00:00
Gerlof Fokkema
257392f33d Firewalld: Add functionality to set forwarding. Fixes #529. 2024-09-09 15:13:12 +09:00
softwarefactory-project-zuul[bot]
0df6c21af4 Merge pull request #562 from saito-hideki/pr/replace_214_with_215
Drop ansible-core 2.14 and set 2.15 minimum version

SUMMARY
Drop ansible-core 2.14 and set 2.15 minimum version.
ISSUE TYPE

Docs Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
N/A
2024-09-06 02:40:34 +00:00
Hideki Saito
71b48d3b5f Drop ansible-core 2.14 and set 2.15 minimum version.
Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-09-06 11:17:52 +09:00
softwarefactory-project-zuul[bot]
9a2ddcd713 Merge pull request #556 from Akasurde/i350
Remove skippy callback

SUMMARY
Fixes: #350
Signed-off-by: Abhijeet Kasurde akasurde@redhat.com
ISSUE TYPE

Bugfix Pull Request

Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-09-05 07:53:20 +00:00
Abhijeet Kasurde
f2d0b38b0e Remove skippy callback
Fixes: #350

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-09-05 16:08:40 +09:00
Andrew Klychkov
7d219a7e05 README: Add Communication section with Forum information (#557)
* README: Add Communication section with Forum information

* Update README.md
2024-08-19 10:25:07 +02:00
softwarefactory-project-zuul[bot]
f41f08e9e3 Merge pull request #555 from Akasurde/ci_fix
Update CI pipelines

SUMMARY
Signed-off-by: Abhijeet Kasurde akasurde@redhat.com
ISSUE TYPE

Bugfix Pull Request

Reviewed-by: Matt Clay
2024-07-15 18:41:50 +00:00
Abhijeet Kasurde
41fc0901d9 Remove unecessary changes to CI scripts 2024-07-15 10:25:20 -07:00
Abhijeet Kasurde
738a839ce5 Remove unecessary changes to CI scripts 2024-07-15 10:22:43 -07:00
Abhijeet Kasurde
c07ebc2f9c Update Ubuntu 2404
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-15 09:40:13 -07:00
Abhijeet Kasurde
7bf56953cb Update Ubuntu 2004
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-13 08:52:46 -07:00
Abhijeet Kasurde
7b9eb8d56e Update Ubuntu 2004
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-13 08:35:59 -07:00
Abhijeet Kasurde
c29e8c213b Update Fedora 40
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-13 08:23:29 -07:00
Abhijeet Kasurde
39a9e79985 Update Ubuntu 2004
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-12 16:31:01 -07:00
Abhijeet Kasurde
d80fde7ea0 Update Ubuntu 2004
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-12 16:26:41 -07:00
Abhijeet Kasurde
271119d196 Update Ubuntu 2204
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-12 16:24:56 -07:00
Abhijeet Kasurde
af6b90981a Add Python version for Ubuntu and Fedora
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-12 16:06:40 -07:00
Abhijeet Kasurde
0ea18d208f remove RHEL9.3@3.11
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-12 15:58:43 -07:00
Abhijeet Kasurde
d2f1cc063a CI fixes
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-12 15:27:56 -07:00
Abhijeet Kasurde
55fb80cf5e CI fixes
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-12 15:16:36 -07:00
Abhijeet Kasurde
3bff8d22a5 Update CI pipelines
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-07-12 14:43:14 -07:00
softwarefactory-project-zuul[bot]
7313065a96 Merge pull request #547 from felixfontein/rst
Remove included RST files

SUMMARY
The docs/ folder currently includes RST files generated from the module documentation. This is using collection_prep, which does not support modern Ansible markup. I propose to get rid of that documentation.
Also, as the comment in README.md said:

Galaxy will eventually list the module docs within the UI, but until that is ready, you may need to either describe your plugins etc here, or point to an external docsite to cover that information.

Galaxy now does support that, and the list of content was already available on the Ansible docsite for the last four years.
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
README
docs/

Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-07-09 12:35:28 +00:00
softwarefactory-project-zuul[bot]
38312cb8e1 Merge pull request #545 from russoz-ansible/docs-review
review modules docs

SUMMARY

Review the doc blocks of the modules in the collection.

ISSUE TYPE


Docs Pull Request

COMPONENT NAME

plugins/modules/acl.py
plugins/modules/at.py
plugins/modules/authorized_key.py
plugins/modules/firewalld.py
plugins/modules/firewalld_info.py
plugins/modules/mount.py
plugins/modules/patch.py
plugins/modules/rhel_facts.py
plugins/modules/rhel_rpm_ostree.py
plugins/modules/seboolean.py
plugins/modules/selinux.py
plugins/modules/synchronize.py
plugins/modules/sysctl.py

Reviewed-by: Felix Fontein <felix@fontein.de>
Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-06-27 09:29:59 +00:00
Alexei Znamensky
ef07eb8a06 Apply suggestions from code review
Thanks felixfontein for the thorough review. :-)

Co-authored-by: Felix Fontein <felix@fontein.de>
2024-06-15 17:00:54 +12:00
Alexei Znamensky
0c9ab06a55 review modules docs 2024-06-15 17:00:54 +12:00
softwarefactory-project-zuul[bot]
b228507b62 Merge pull request #550 from saito-hideki/pr/azp_update_image
[CI] Bump Azure test container to 6.0.0

SUMMARY
Replace AZP container image version with 6.0.0:

Fixes #549

ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
See ansible-collections/news-for-maintainers#71
2024-06-12 00:17:48 +00:00
Hideki Saito
0341c9420f Replace AZP default image with 6.0.0
- See https://github.com/ansible-collections/news-for-maintainers/issues/71

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-06-12 08:35:57 +09:00
Felix Fontein
b976831cef Remove included RST files. 2024-06-08 13:59:15 +02:00
softwarefactory-project-zuul[bot]
fd78e3e6da Merge pull request #546 from felixfontein/ci
Add basic ansible-lint config to fix CI; add ansible-core 2.17 to CI

SUMMARY
ansible-lint makes the nightly CI fail (https://dev.azure.com/ansible/ansible.posix/_build/results?buildId=114105&view=logs&j=2671e6a6-f41a-533c-2720-8ffdcf8ab96f&t=5b604a49-baaa-558f-6ab2-4a2ff646af4f) due to two rules:

meta-runtime[unsupported-version]: it doesn't like that the collection supports ansible-core versions that are EOL. This rule simply doesn't make any sense, and it should be disabled by default IMO.
fqcn[deep]: this rule produces false positives for files in tests/unit/plugins/action/fixtures/.

Also adds sanity ignore file for ansible-core 2.18 (the version used by the current devel branch).
ISSUE TYPE

Bugfix Pull Request
Test Pull Request

COMPONENT NAME
ansible-lint in CI

Reviewed-by: Adam Miller <admiller@redhat.com>
2024-06-07 15:42:58 +00:00
Felix Fontein
11f29eba6f Add ansible-core 2.17 to CI. 2024-06-07 11:38:13 +02:00
Felix Fontein
a615b84bf7 Add sanity ignore file for ansible-core devel 2.18. 2024-06-07 07:12:06 +02:00
Felix Fontein
9ccc24edf2 Add basic ansible-lint config. 2024-06-07 07:03:56 +02:00
softwarefactory-project-zuul[bot]
34f140c22f Merge pull request #206 from satken2/sakten2_issue111
Fixed sysctl to work on symlinks

SUMMARY
Fixes #111.
This issue reports a bug of sysctl that the module does not work properly when sysctl_file is a symlink.
I Fixed the bug by inserting os.path.realpath to get real path.
When sysctl_file is a real file, os.path.realpath return the original path as is.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
sysctl
ADDITIONAL INFORMATION


I have executed the script described in #111 and confirmed that it works properly.
But I need to add some tests.

satken@dockerhost1:~/ansible$ sudo docker run --rm -v ${PWD}:/work -w /work -e ANSIBLE_LIBRARY=/work/ansible.posix -e ANSIBLE_HOST_KEY_CHECKING=False satken2/ansible:3.3.0 ansible-playbook -i hosts main.yml

PLAY [test] ********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [192.168.91.76]

TASK [test] ********************************************************************
ok: [192.168.91.76] => {
    "msg": "This is test"
}

TASK [command] *****************************************************************
changed: [192.168.91.76]

TASK [command] *****************************************************************
ok: [192.168.91.76]

TASK [debug] *******************************************************************
ok: [192.168.91.76] => {
    "sysctl_current_value.stdout": "kernel.randomize_va_space = 2"
}

TASK [copy] ********************************************************************
changed: [192.168.91.76]

TASK [file] ********************************************************************
changed: [192.168.91.76]

TASK [stat] ********************************************************************
ok: [192.168.91.76]

TASK [assert] ******************************************************************
ok: [192.168.91.76] => {
    "changed": false,
    "msg": "/tmp/ansible_sysctl_test_symlink.conf is correct symlink"
}

TASK [sysctl | enable randomized layout of virtual address space] **************
changed: [192.168.91.76]

TASK [stat] ********************************************************************
ok: [192.168.91.76]

TASK [assert] ******************************************************************
ok: [192.168.91.76] => {
    "changed": false,
    "msg": "/tmp/ansible_sysctl_test_symlink.conf is correct symlink"
}

PLAY RECAP *********************************************************************
192.168.91.76              : ok=12   changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Reviewed-by: quidame
Reviewed-by: Jill R
2024-05-09 19:41:13 +00:00
Jill Rouleau
83c4d2abd1 lint fixes 2024-05-09 12:10:44 -07:00
Jill Rouleau
e5733c5e49 Quote string in test assertion 2024-05-07 16:53:57 -07:00
Jill Rouleau
d49bd27fae Revert "sysctl: Fixed sysctl to work on symlinks(#111)"
This reverts commit 34b467719e0dab10d062813cdef11b49f3925ed6.
2024-05-07 16:53:57 -07:00
satken2
9064ff7eb2 sysctl: Fixed sysctl to work on symlinks(#111) 2024-05-07 16:53:57 -07:00
satken2
a842e5f96a sysctl: Fixed sysctl to work on symlinks(#111) 2024-05-07 16:53:57 -07:00
satken2
97dcdee670 sysctl: Fixed sysctl to work on symlinks(#111) 2024-05-07 16:53:57 -07:00
satken2
55ea4ba1de sysctl: Fixed sysctl to work on symlinks(#111) 2024-05-07 16:53:57 -07:00
satken2
a88f5f8ae0 sysctl: Fixed sysctl to work on symlinks(#111) 2024-05-07 16:53:57 -07:00
softwarefactory-project-zuul[bot]
d36a289deb Merge pull request #490 from atom4git/main
Docs/authorized_key: clarify that the path key should probably NOT be set

SUMMARY

Docs: Fixed unclearance in documentation connected wirh relative path
Added additional description in documentation.

ISSUE TYPE


Docs Pull Request

COMPONENT NAME

authorized_key.py
ADDITIONAL INFORMATION

Clarify the documentation unclearance in connected with relative path ~/.ssh/authorized_keys
The purpose of the pull request is to eliminate ambiguities in the documentation.
In our case, when using the ~ sign, we get the user's root directory (although we explicitly specify a different username)
Here is the issue and full picture of problem which we want to fix: LINK

Closese:  #483

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: atom4git
Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-04-02 08:44:34 +00:00
Sergey
60c8d23c7f Docs/authorized_key: clarify that the path key should probably NOT be set 2024-04-02 17:08:28 +09:00
softwarefactory-project-zuul[bot]
795d8e34e7 Merge pull request #538 from csmart/ci_freebsd_133
ci: replace freebsd 13.2 with 13.3

The devel version of ansible-test has been updated to include support for FreeBSD 13.3, so this change swaps out 13.2 accordingly.
See ansible-collections/news-for-maintainers#67

Reviewed-by: Hideki Saito <saito@fgrep.org>
2024-03-26 06:50:36 +00:00
Chris Smart
b615d61fae ci: replace freebsd 13.2 with 13.3
The devel version of ansible-test has been updated to include support
for FreeBSD 13.3, so this change swaps out 13.2 accordingly.
2024-03-26 14:59:32 +09:00
softwarefactory-project-zuul[bot]
bda85b7453 Merge pull request #541 from saito-hideki/pr/replace_yield
[CI] Replaced yield with yield from for sanity test

SUMMARY
Replaced yield with yield from to address latest sanity test.
ISSUE TYPE

CI Tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2024-03-26 05:51:09 +00:00
Hideki Saito
ac82f575c6 Replaced yield with yield from to address latest sanity test
Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-03-26 13:54:40 +09:00
softwarefactory-project-zuul[bot]
a356bdd3c4 Merge pull request #540 from saito-hideki/pr/relace_old_fqcn_selogin
[CI] Replaced old selogin FQCN for integration tests

SUMMARY
Some integration test tasks used the old FQCNs of commuinity.general.
This PR will replace old FQCN(community.general.system.selogin)with new cummonity.general.selogin
ISSUE TYPE

CI Tests Pull Request

COMPONENT NAME

ansible.posix.selinux

ADDITIONAL INFORMATION
None
2024-03-26 02:59:55 +00:00
Hideki Saito
4f93234a8b Replaced old selogin FQCN
- FCQN has been changed since comunity.general stable-6

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-03-26 10:39:34 +09:00
softwarefactory-project-zuul[bot]
9bfed58f7f Merge pull request #333 from NeodymiumFerBore/fix/doc/mount_absent_description
Fix absent state documentation

SUMMARY
Fix the documentation of the state absent so it describes its actual behavior:

absent does not specify that (quote) a device mount's entry will be removed from fstab. It specifies that a mount point entry will be removed from fstab
absent does not unmount recursively, and the module will fail if multiple devices are mounted on the same mount point
absent with a mount point that is not registered in the fstab has no effect. The state unmounted should be used instead.
src is ignored with state absent or unmounted

ISSUE TYPE

Docs Pull Request

COMPONENT NAME
mount
ADDITIONAL INFORMATION
This PR addresses a fix for issue 322.
2024-02-06 16:13:16 +00:00
Adam Miller
a18d180246 Merge branch 'main' into fix/doc/mount_absent_description 2024-02-06 09:29:55 -06:00
Marty Winkler
51b94f536c Feat/add summary only option to profile callbacks (#511)
* profile_tasks callback: add parameter to show only summary
2024-02-06 09:21:42 -06:00
Petr Lautrbach
0a07bdb358 seboolean: make it work with disabled SELinux (#496)
Sometimes it's necessary to configure SELinux before it's enabled on the
system. There's `ignore_selinux_state` which should allow it. Before
this change `seboolean` module failed on SELinux disabled system even
with `ignore_selinux_state: true` and SELinux policy installed while
`semanage boolean` worked as expected:

    $ ansible -i 192.168.121.153, -m seboolean -a "name=ssh_sysadm_login state=on ignore_selinux_state=true" all
    192.168.121.153 | FAILED! => {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/bin/python3"
        },
        "changed": false,
        "msg": "Failed to get list of boolean names"
    }

    $ ssh root@192.168.121.153 semanage boolean -l | grep ssh_sysadm_login
    ssh_sysadm_login               (off  ,  off)  Allow ssh to sysadm login

It's caused by `selinux.security_get_boolean_names()` and
`selinux.security_get_boolean_active(name)` which required SELinux
enabled system.

This change adds a fallback to semanage API which works in SELinux
disabled system when SELinux targeted policy is installed:

    ANSIBLE_LIBRARY=plugins/modules ansible -i 192.168.121.153, -m seboolean -a "name=ssh_sysadm_login state=on persistent=true ignore_selinux_state=true" all
    192.168.121.153 | CHANGED => {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/bin/python3"
        },
        "changed": true,
        "name": "ssh_sysadm_login",
        "persistent": true,
        "state": true
    }

    $ ssh root@192.168.121.153 semanage boolean -l | grep ssh_sysadm_login
    ssh_sysadm_login               (on   ,   on)  Allow ssh to sysadm login

Note that without `persistent=true` this module is effectively NO-OP now.

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
2024-02-06 09:21:27 -06:00
Sloane Hertel
e929aad539 remove deprecated internal argument from synchronize (#421)
* remove deprecated internal argument from synchronize

the new_stdin argument is no longer used to instantiate a connection plugin

* add a changelog
2024-01-11 14:24:45 -06:00
Michael
0847977d12 Warn only when zones were ignored in firewalld_info (#504)
* warn only when zones were ignored

* add changelog 504-firewalld_info-warning
2024-01-09 16:07:58 -06:00
Christer Warén
2a1fb334ee mount: edit boot parameters warning condition (#523)
the CI failures are unrelated and shouldn't even be showing up ... I'm going to sort that out separately but that doesn't need to prevent this merge, all relevant CI tests passed
2024-01-09 16:06:26 -06:00
softwarefactory-project-zuul[bot]
af870d0b83 Merge pull request #524 from felixfontein/fix-ci
Fix CI issues

SUMMARY

Sanity tests fail; remove problematic Shippable-specific parts of shippable.sh script.
FreeBSD 12.4 have apparently been removed also from older versions of ansible-test.

ISSUE TYPE

Test Pull Request

COMPONENT NAME
CI
2024-01-09 18:43:25 +00:00
Felix Fontein
8e900e5218 Support for FreeBSD 12.4 was removed. 2024-01-09 07:30:04 +01:00
Felix Fontein
45d8819b7c Remove Shippable leftovers. 2024-01-09 07:25:45 +01:00
softwarefactory-project-zuul[bot]
6473053b13 Merge pull request #518 from bcoca/ci_fbsd132
update ci target for freebsd 13, r1 is eol

Current CI fails due to the  release_1/ dir returning 404, this will move to working release_2/ dir
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

CI
2024-01-08 20:11:06 +00:00
Brian Coca
046f6d1483 update ci target for freebsd 13, r1 is eol 2023-12-11 10:18:12 -05:00
softwarefactory-project-zuul[bot]
2c52f969e1 Merge pull request #484 from flowerysong/firewalld_offline
firewalld: make offline do something

SUMMARY

ansible.posix.firewalld has an offline flag, but it currently does not do anything. What most people expect it to do is allow the task to proceed even when firewalld is offline, so it makes the most sense for it to override the immediate flag and prevent the module from throwing an error in that case.
Fixes #81.
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

firewalld
ADDITIONAL INFORMATION

Reviewed-by: Adam Miller <admiller@redhat.com>
2023-12-07 21:18:29 +00:00
softwarefactory-project-zuul[bot]
011c60e736 Merge pull request #516 from maxamillion/lint/major-refactor
refactor to comply with current ansible-lint guidelines

SUMMARY

refactor to comply with current ansible-lint guidelines

ISSUE TYPE


Bugfix Pull Request
2023-12-07 16:20:11 +00:00
Adam Miller
a85f736f6a refactor to comply with current ansible-lint and sanity guidelines
Signed-off-by: Adam Miller <admiller@redhat.com>
2023-12-06 17:22:59 -06:00
softwarefactory-project-zuul[bot]
05ee6ebc2a Merge pull request #515 from maxamillion/tests/azure_pipelines
remove old pipelines, run sanity in pipelines because we're dropping zuul

SUMMARY

remove old pipelines, run sanity in pipelines because we're dropping zuul

ISSUE TYPE


Bugfix Pull Request
2023-12-01 01:34:06 +00:00
Adam Miller
c394f6778d remove old pipelines, run sanity in pipelines because we're dropping zuul
Signed-off-by: Adam Miller <admiller@redhat.com>
2023-11-30 19:01:55 -06:00
Adam Miller
748bad22ad fix sanity tests for core 2.16 (#514)
Signed-off-by: Adam Miller <admiller@redhat.com>
2023-11-30 16:25:07 -06:00
softwarefactory-project-zuul[bot]
6f95c8b356 Merge pull request #460 from gotmax23/respawn
Respawn modules to use the system python interpreter

SUMMARY
The seboolean, selinux, firewalld, and firewalld_info modules depend on
system bindings that are only available for the default system python
interpreter. ansible-core is not packaged for the default system python
interpreter on RHEL 8 and 9. When automatic interpreter discovery does
not occur (e.g. when using implicit localhost [1]), ansible-core will
not use the system interpreter to run ansible modules and the
aforementioned modules will not work even if the bindings are installed.
The RHEL ansible-core maintainers as well as the EPEL ansible and
ansible-collection-* package maintainers (inc. me) have gotten multiple
bug reports about this. We have been telling people to fix their setup
to use the correct Python interpreter. Fortunately, ansible-core 2.11
and above have a module utility that'll respawn modules to use the
correct system interpreter.
[1] https://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
seboolean
selinux
firewalld
firewalld_info

Reviewed-by: Adam Miller <admiller@redhat.com>
2023-11-30 17:03:21 +00:00
Paul Arthur
695fa213b3 firewalld: make offline do something 2023-11-29 00:06:36 +00:00
softwarefactory-project-zuul[bot]
719f7dfebf Merge pull request #510 from saito-hideki/issue/509
[CI] Replace Fedora 38 with 39 for devel branch container test

SUMMARY
Replace Fedora 38 container test with 39 for devel branch.

Fixed /#509

ISSUE TYPE

CI test Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2023-11-23 15:56:55 +00:00
Hideki Saito
5cae7aa946 Replace Fedora 38 with 39 for devel branch container test 2023-11-22 17:09:41 +09:00
softwarefactory-project-zuul[bot]
2f699307c7 Merge pull request #508 from saito-hideki/pr/refactoring_ci_remote
[CI] Refactoring CI tests for both remote and container tests

SUMMARY
Refactored CI tests:

Remove tests for Ansible Core 2.10 and 2.11 that already reached EOL.
Remote test target of ansible.posix will be the latest version of RHEL8,9 only.
The target OS of container tests has been modified, and a few OS have been removed
Add Ansible Core 2.16 and new devel branch to container and remote test target.
#506

For CI testing, other platforms can be added as needed.
ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2023-11-16 04:34:53 +00:00
Hideki Saito
7dd5087e7b Refactoring remote and docker CI tests.
* Removed tests for Ansible Core 2.10 and 2.11 fromn remote and container targets
* Modoifed remote and container test target OS
* Fixed #506

Signed-off-by: Hideki Saito <saito@fgrep.org>
2023-11-16 11:56:08 +09:00
softwarefactory-project-zuul[bot]
542643e786 Merge pull request #487 from saito-hideki/pr/ci_remove_freebsd12
Drop OSX10.11 and FreeBSD12.4 from CI

SUMMARY
Drop OSX-10.11 and FreeBSD12.4 from CI

Fixes #476
Fixes #486
Drop OSX10.11 from ansible:2.9 and ansible-core:2.10
Drop FreeBSD12.4 from ansible-core:devel

ISSUE TYPE

CI Tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2023-08-02 08:29:22 +00:00
Hideki Saito
2cde4cdb26 Drop OSX10.11 and FreeBSD12.4 from CI
- Fixes #476
- Fixes #486
- Drop OSX10.11 from ansible:2.9 and ansible-core:2.10
- Drop FreeBSD12.4 from ansible-core:devel

Signed-off-by: Hideki Saito <saito@fgrep.org>

test
2023-08-02 16:03:19 +09:00
softwarefactory-project-zuul[bot]
12a1c25f5e Merge pull request #478 from maxamillion/test/rhel_updates
Update azure-pipelines for new RHEL versions

SUMMARY

Change to the CI system annnounced in the following required this change:
ansible-collections/news-for-maintainers#47
2023-07-06 22:34:53 +00:00
Adam Miller
7062be892e only for devel
Signed-off-by: Adam Miller <admiller@redhat.com>
2023-07-06 10:19:58 -05:00
softwarefactory-project-zuul[bot]
20c2c30d23 Merge pull request #477 from saito-hideki/issue/476/1
Update CI tests to address changes on ansible-core

SUMMARY
Replace Python3.9 with 3.12 for ansible-test

Addresses issue #476

ISSUE TYPE

CI Test Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2023-07-04 01:39:12 +00:00
Hideki Saito
4f1e6b4a6d Drop Python3.9 and update versions of RHEL,Fedora and FreeBSD for ansible-core:devel
* Addresses issue #476
* Drop Python3.9
* Replace Fedora 37 with 38
* Replace FreeBSD13.1 with 13.2
* Replace RHEL 8.7 with 8.8
* Replace RHEL 9.1 with 9.2

Signed-off-by: Hideki Saito <saito@fgrep.org>
2023-07-04 09:15:24 +09:00
Adam Miller
806ab9ef9d Update azure-pipelines for new RHEL versions
Change to the CI system annnounced in the following required this
change:

  https://github.com/ansible-collections/news-for-maintainers/issues/47

Signed-off-by: Adam Miller <admiller@redhat.com>
2023-06-29 10:57:49 -05:00
softwarefactory-project-zuul[bot]
2ed8bdc8e8 Merge pull request #465 from felixfontein/req
Switch to Ansible Galaxy compatible requirements files for tests

SUMMARY
See ansible-community/community-topics#230.
ISSUE TYPE

Test Pull Request

COMPONENT NAME
test requirements files

Reviewed-by: Sorin Sbarnea <sorin.sbarnea@gmail.com>
2023-05-31 14:01:42 +00:00
Felix Fontein
622aef2aad Switch to Ansible Galaxy compatible requirements files for tests. 2023-05-26 08:14:28 +02:00
softwarefactory-project-zuul[bot]
5165572e9e Merge pull request #467 from oraNod/rm-eol-tests
Fix CI: Remove FreeBSD 12.2 targets

SUMMARY
Removes CI tests for FreeBSD 12.2 that are failing when trying to bootstrap http://pkg.freebsd.org/FreeBSD:12:amd64/release_2
Example PR affected #466
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
.azure-pipelines/azure-pipelines.yml
ADDITIONAL INFORMATION
N/A

Reviewed-by: Hideki Saito <saito@fgrep.org>
2023-05-26 06:09:47 +00:00
softwarefactory-project-zuul[bot]
6c46a924b9 Merge pull request #466 from felixfontein/ci
Fix CI: replace `include:` with `include_tasks:`

SUMMARY
include: is removed for ansible-core 2.16 and no longer works with current devel.
ISSUE TYPE

Test Pull Request

COMPONENT NAME
integration tests

Reviewed-by: Hideki Saito <saito@fgrep.org>
2023-05-26 05:09:48 +00:00
Don Naro
ab1bc5df9f remove FreeBSD 12.2 targets 2023-05-24 19:41:58 +01:00
Felix Fontein
4106ec65f9 Replace 'include:' with 'include_tasks:'.
'include:' is removed for ansible-core 2.16.
2023-05-21 13:17:48 +02:00
Maxwell G
85c958ccb8 respawn firewalld_info module when selinux is missing 2023-05-14 05:44:47 +00:00
Maxwell G
ad414c87b4 respawn firewalld module when selinux is missing 2023-05-14 05:44:47 +00:00
Maxwell G
34a9cf3e4d respawn selinux module when selinux is missing 2023-05-14 05:44:46 +00:00
Maxwell G
63fba50912 respawn seboolean module when selinux is missing 2023-05-14 05:44:46 +00:00
Maxwell G
8ec2c261bd add helper to respawn modules with system python
The seboolean, selinux, firewalld, and firewalld_info modules depend on
system bindings that are only available for the default system python
interpreter. ansible-core is not packaged for the default system python
interpreter on RHEL 8 and 9. When automatic interpreter discovery does
not occur (e.g. when using implicit localhost [1]), ansible-core will
not use the system interpreter to run ansible modules and the
aforementioned modules will not work even if the bindings are installed.
The RHEL ansible-core maintainers as well as the EPEL ansible and
ansible-collection-* package maintainers (inc. me) have gotten multiple
bug reports about this. We have been telling people to fix their setup
to use the correct Python interpreter. Fortunately, ansible-core 2.11
and above have a module utility that'll respawn modules to use the
correct system interpreter.

[1] https://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html
2023-05-14 05:44:02 +00:00
softwarefactory-project-zuul[bot]
f48515aad3 Merge pull request #458 from maxamillion/release-prep/1.5.4
Release 1.5.4

SUMMARY

Release 1.5.4
2023-05-11 15:00:31 +00:00
Adam Miller
3bbf2e3cd5 Release 1.5.4
Signed-off-by: Adam Miller <admiller@redhat.com>
2023-05-10 13:17:59 -05:00
softwarefactory-project-zuul[bot]
ae0380d671 Merge pull request #456 from maxamillion/tests/fix_sysctl_failures
fix sysctl integration test failing on newer versions of core

Previously NoneType was allowable, now it fails to convert to a str type.
SUMMARY

fix sysctl integration test failing on newer versions of core

Previously NoneType was allowable, now it fails to convert to a str
type.


ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

sysctl
2023-05-10 14:18:34 +00:00
Adam Miller
4f46ff218f add changelog fragment
Signed-off-by: Adam Miller <admiller@redhat.com>
2023-05-09 16:32:56 -05:00
Adam Miller
07f1e11015 fix sysctl integration test failing on newer versions of core
Previously NoneType was allowable, now it fails to convert to a str
type.

Signed-off-by: Adam Miller <admiller@redhat.com>
2023-05-05 11:59:04 -05:00
softwarefactory-project-zuul[bot]
202609e425 Merge pull request #454 from rekup/fix/firewalld
fix firewalld protocol

SUMMARY
This PR resolves an issue where opening a port (e.g. 25/tcp) resulted in opening all ports for the specified protocol (e.g. tcp)
Fixes #451
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
ansible.posix.firewalld
ADDITIONAL INFORMATION
Many thanks to @nerrehmit and every one else who helped troubleshooting this!
2023-05-04 15:25:13 +00:00
Reto Kupferschmid
f1b36ba1c2 fix unbound variable error 2023-05-04 07:34:08 +02:00
Reto Kupferschmid
0eb6a7a437 fixup! fix firewalld protocol 2023-05-03 19:31:05 +02:00
Reto Kupferschmid
15954f8def add changelog fragment 2023-05-03 19:25:06 +02:00
Reto Kupferschmid
41ce2cc8f9 fix firewalld protocol 2023-05-03 19:04:35 +02:00
softwarefactory-project-zuul[bot]
b9feff586f Merge pull request #441 from jsquyres/pr/json-indent-level
json[l] callback: add parameter to set JSON prettyprint indent level

SUMMARY
Add ANSIBLE_JSON_INDENT parameter to both the json and jsonl callback plugins.  The default values are different between the two modules to maintain their existing behavior:

json: indent==4, causing a prettyprint output
jsonl: indent==0, causing a 1-line output

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix.json
ansible.posix.jsonl

ADDITIONAL INFORMATION
One specific use-case that is enabled by this feature: if a user chooses to use the jsonl plugin so that they still get output at the end of each task (vs. only at the end of the play), they may also want human-readable output so that they can monitor the status of their play.  For example, setting the jsonl indent level to 4 gives a) output at the end of each task, and b) making that output be both machine readable and human readable.
Using this trivial playbook shows the change:
- hosts: localhost
  gather_facts: false
  tasks:
    - name: hello, world
      debug:
        msg: hello, world
When using the jsonl callback, here's what one JSON emit looks like before the change:
{"_event":"v2_playbook_on_play_start","_timestamp":"2023-04-08T12:11:48.001806Z","play":{"duration":{"start":"2023-04-08T12:11:48.001383Z"},"id":"acde4800-1122-f32c-94c3-000000000001","name":"localhost"},"tasks":[]}
After the change, setting ANSIBLE_JSON_INDENT to 4, the same output looks like this:
{
    "_event":"v2_playbook_on_play_start",
    "_timestamp":"2023-04-08T12:12:47.787516Z",
    "play":{
        "duration":{
            "start":"2023-04-08T12:12:47.787164Z"
        },
        "id":"acde4800-1122-2946-e3e4-000000000001",
        "name":"localhost"
    },
    "tasks":[]
}
Both outputs are suitable for automated processes to parse the machine readable output.  The second output has the benefit of being human readable.

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Jeff Squyres
2023-04-27 20:52:09 +00:00
Jeff Squyres
281f957ece json[l] callback: add parameter to set JSON prettyprint indent level
Add ANSIBLE_JSON_INDENT parameter to both the json and jsonl callback
plugins.  The default values are different between the two modules to
maintain their existing behavior:

* json: indent==4, causing a prettyprint output
* jsonl: indent==0, causing a 1-line output

One specific use-case that is enabled by this feature: if a user
chooses to use the jsonl plugin so that they still get output at the
end of each task (vs. only at the end of the play), they may also want
human-readable output so that they can monitor the status of their
play.  For example, setting the jsonl indent level to 4 gives a)
output at the end of each task, and b) making that output be both
machine readable and human readable.

Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
2023-04-18 08:00:04 -07:00
softwarefactory-project-zuul[bot]
da1713ed3e Merge pull request #440 from jsquyres/pr/json-callback-path
json[l] callback: add play/task path info

Add the play and task path info (i.e., filename and line number) to the JSON that is emitted from the json and jsonl callback plugins, allowing more accurate post-mortem analysis.
SUMMARY
Add the play and task path info (i.e., filename and line number) to the JSON that is emitted from the json and jsonl callback plugins, allowing more accurate post-mortem analysis.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix.json
ansible.posix.jsonl

ADDITIONAL INFORMATION
By also including the file/line number in the JSON data emitted, post-mortem analysis can unambiguously tie play/task log data to the specific play / task that generated it.  Without this information, it could be difficult for automated processes to precisely map log output back to the task that generated it (especially with playbooks that either do not name tasks, or do not name tasks uniquely).
Using this trivial playbook shows the change:
- hosts: localhost
  gather_facts: false
  tasks:
    - name: hello, world
      debug:
        msg: hello, world
When using the json callback, here's what it looks like before the change (for brevity, just the plays section of the output):
        {
            "play": {
                "duration": {
                    "end": "2023-04-08T11:35:39.694000Z",
                    "start": "2023-04-08T11:35:39.657056Z"
                },
                "id": "acde4800-1122-6387-7abd-000000000001",
                "name": "localhost",
            },
            "tasks": [
                {
                    "hosts": {
                        "localhost": {
                            "_ansible_no_log": null,
                            "_ansible_verbose_always": true,
                            "action": "debug",
                            "changed": false,
                            "msg": "hello, world"
                        }
                    },
                    "task": {
                        "duration": {
                            "end": "2023-04-08T11:35:39.694000Z",
                            "start": "2023-04-08T11:35:39.672132Z"
                        },
                        "id": "acde4800-1122-6387-7abd-000000000003",
                        "name": "hello, world",
                    }
                }
            ]
        }
After the change, there is a new path key/value in both the play and the task:
        {
            "play": {
                "duration": {
                    "end": "2023-04-08T11:35:39.694000Z",
                    "start": "2023-04-08T11:35:39.657056Z"
                },
                "id": "acde4800-1122-6387-7abd-000000000001",
                "name": "localhost",
                "path": "/tmp/plays/hello.yaml:1"
            },
            "tasks": [
                {
                    "hosts": {
                        "localhost": {
                            "_ansible_no_log": null,
                            "_ansible_verbose_always": true,
                            "action": "debug",
                            "changed": false,
                            "msg": "hello, world"
                        }
                    },
                    "task": {
                        "duration": {
                            "end": "2023-04-08T11:35:39.694000Z",
                            "start": "2023-04-08T11:35:39.672132Z"
                        },
                        "id": "acde4800-1122-6387-7abd-000000000003",
                        "name": "hello, world",
                        "path": "/tmp/plays/hello.yaml:4"
                    }
                }
            ]
        }
The effect is the same in the jsonl plugin, but the output is squashed into a single line.

Reviewed-by: Adam Miller <admiller@redhat.com>
2023-04-18 03:24:12 +00:00
softwarefactory-project-zuul[bot]
7fb9cc95c3 Merge pull request #435 from ziegenberg/fix-412
docs: fix profile_tasks callback documentation

SUMMARY

This fixes the markup.
Fixes: #412
ISSUE TYPE


Docs Pull Request

COMPONENT NAME

profile_tasks
ADDITIONAL INFORMATION


None.

Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: Adam Miller <admiller@redhat.com>
2023-04-18 01:52:07 +00:00
softwarefactory-project-zuul[bot]
3a5ba91d92 Merge pull request #448 from saito-hideki/issue/446
[CI] Support sanity docker test on devel(2.16.0.dev0) branch

SUMMARY
Support sanity docker test on devel(2.16.0.dev0) branch:

Fixes #446

ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2023-04-17 15:16:08 +00:00
Hideki Saito
1c560e93d2 Support sanity docker test on devel(2.16.0.dev0) branch
- Fixes #446

Signed-off-by: Hideki Saito <saito@fgrep.org>
2023-04-17 23:32:21 +09:00
softwarefactory-project-zuul[bot]
daf0b89fcb Merge pull request #445 from saito-hideki/issue/444
Update AZP to support stable-2.15 branch

SUMMARY
Update AZP to support stable-2.15 branch.

Fixes #444

ISSUE TYPE

CI tests Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2023-04-12 23:12:34 +00:00
softwarefactory-project-zuul[bot]
083f3aab64 Merge pull request #404 from gnfzdz/bugfix_masquerade_icmp_block_inversion
Bugfix masquerade icmp block inversion

SUMMARY

Fixes #235
Fixes #116
The masquerade and icmp_block_inversion parameters are currently strings and the values are completely ignored by the module.  A warning was previously added that these values will be converted to a boolean in the future.
This PR updates the behavior so that when a boolean like value is provided, the value is correctly considered. If a boolean like string is NOT provided, the current behavior is retained and the value is treated as true.  Additionally, comprehensive tests are added for every combination of the parameters state (enabled/disabled) and icmp_block_inversion / masquerade (True/False/non-boolean string).
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ansible.posix.firewalld
ADDITIONAL INFORMATION



Given icmp block inversion is currently enabled
  - name: Testing disable icmp block inversion
    ansible.posix.firewalld:
      zone:       trusted
      icmp_block_inversion: no
      permanent:  yes
      state:      enabled

Before
TASK [firewalld : Testing disable icmp block inversion] ************************
task path: /root/ansible_collections/ansible/posix/tests/output/.tmp/integration/firewalld-96jns0q4-ÅÑŚÌβŁÈ/tests/integration/targets/firewalld/tasks/icmp_block_inversion_test_cases.yml:35
Using module file /root/ansible_collections/ansible/posix/plugins/modules/firewalld.py
Pipelining is enabled.
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<testhost> EXEC /bin/sh -c '/usr/bin/python3.10 && sleep 0'
ok: [testhost] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "icmp_block": null,
            "icmp_block_inversion": "False",
            "immediate": false,
            "interface": null,
            "masquerade": null,
            "offline": null,
            "permanent": true,
            "port": null,
            "port_forward": null,
            "rich_rule": null,
            "service": null,
            "source": null,
            "state": "enabled",
            "target": null,
            "timeout": 0,
            "zone": "trusted"
        }
    },
    "msg": "Permanent operation"
}

After
TASK [firewalld : Testing disable icmp block inversion] ************************
task path: /root/ansible_collections/ansible/posix/tests/output/.tmp/integration/firewalld-nxphh1pk-ÅÑŚÌβŁÈ/tests/integration/targets/firewalld/tasks/icmp_block_inversion_test_cases.yml:35
Using module file /root/ansible_collections/ansible/posix/plugins/modules/firewalld.py
Pipelining is enabled.
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<testhost> EXEC /bin/sh -c '/usr/bin/python3.10 && sleep 0'
changed: [testhost] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "icmp_block": null,
            "icmp_block_inversion": "False",
            "immediate": false,
            "interface": null,
            "masquerade": null,
            "offline": null,
            "permanent": true,
            "port": null,
            "port_forward": null,
            "rich_rule": null,
            "service": null,
            "source": null,
            "state": "enabled",
            "target": null,
            "timeout": 0,
            "zone": "trusted"
        }
    },
    "msg": "Permanent operation, Changed icmp-block-inversion False to enabled"
}

Reviewed-by: Adam Miller <admiller@redhat.com>
2023-04-12 23:01:44 +00:00
Adam Miller
9d1f67042e Merge branch 'main' into bugfix_masquerade_icmp_block_inversion 2023-04-12 17:09:22 -05:00
softwarefactory-project-zuul[bot]
cddfa80d84 Merge pull request #402 from gnfzdz/bugfix_offline_add_interface
Fix adding interface to zone when firewalld is offline

SUMMARY

Fixes issue #357
The existing implementation had several issues which have been resolved by this PR:

incorrectly assumed some zone always exists that contains the interface
incorrectly included the logic to add the interface to the target zone inside of the condition checking if the interface is already assigned to a different zone (and needs to be removed)
passed an invalid argument to the constructor for FirewallClientZoneSettings

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
ansible.posix.firewalld
ADDITIONAL INFORMATION


  - name: Add lo interface to trusted zone
    ansible.posix.firewalld:
      interface: lo
      zone: trusted
      permanent: Yes
      state: enabled


Before
TASK [firewalld : Add lo interface to trusted zone] ****************************
task path: /root/ansible_collections/ansible/posix/tests/output/.tmp/integration/firewalld-gpgqwc7n-ÅÑŚÌβŁÈ/tests/integration/targets/firewalld/tasks/interface_test_cases.yml:7
Using module file /root/ansible_collections/ansible/posix/plugins/modules/firewalld.py
Pipelining is enabled.
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<testhost> EXEC /bin/sh -c '/usr/bin/python3.10 && sleep 0'
The full traceback is:
  File "/tmp/ansible_ansible.posix.firewalld_payload_2vetziz9/ansible_ansible.posix.firewalld_payload.zip/ansible_collections/ansible/posix/plugins/module_utils/firewalld.py", line 112, in action_handler
    return action_func(*action_func_args)
  File "/tmp/ansible_ansible.posix.firewalld_payload_2vetziz9/ansible_ansible.posix.firewalld_payload.zip/ansible_collections/ansible/posix/plugins/modules/firewalld.py", line 481, in set_enabled_permanent
fatal: [testhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "icmp_block": null,
            "icmp_block_inversion": null,
            "immediate": false,
            "interface": "lo",
            "masquerade": null,
            "offline": null,
            "permanent": true,
            "port": null,
            "port_forward": null,
            "rich_rule": null,
            "service": null,
            "source": null,
            "state": "enabled",
            "target": null,
            "timeout": 0,
            "zone": "trusted"
        }
    },
    "msg": "ERROR: Exception caught: list index out of range Permanent operation"
}

After
TASK [firewalld : Add lo interface to trusted zone] ****************************
task path: /root/ansible_collections/ansible/posix/tests/output/.tmp/integration/firewalld-tr92i6e1-ÅÑŚÌβŁÈ/tests/integration/targets/firewalld/tasks/interface_test_cases.yml:7
Using module file /root/ansible_collections/ansible/posix/plugins/modules/firewalld.py
Pipelining is enabled.
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<testhost> EXEC /bin/sh -c '/usr/bin/python3.10 && sleep 0'
changed: [testhost] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "icmp_block": null,
            "icmp_block_inversion": null,
            "immediate": false,
            "interface": "lo",
            "masquerade": null,
            "offline": null,
            "permanent": true,
            "port": null,
            "port_forward": null,
            "rich_rule": null,
            "service": null,
            "source": null,
            "state": "enabled",
            "target": null,
            "timeout": 0,
            "zone": "trusted"
        }
    },
    "msg": "Permanent operation, Changed lo to zone trusted, (offline operation: only on-disk configs were altered)"
}

Reviewed-by: Adam Miller <admiller@redhat.com>
2023-04-12 16:59:23 +00:00
Hideki Saito
91a6e30d78 Update AZP to support stable-2.15 branch
- Fixes #444

Signed-off-by: Hideki Saito <saito@fgrep.org>
2023-04-13 00:34:37 +09:00
Jeff Squyres
940d914904 json[l] callback: add play/task path info
Add the play and task path info (i.e., filename and line number) to
the JSON that is emitted from the json and jsonl callback plugins,
allowing more accurate post-mortem analysis.

Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
2023-04-12 09:55:44 -04:00
softwarefactory-project-zuul[bot]
b6587a783e Merge pull request #443 from saito-hideki/pr/bump_release_version
Bump release version in galaxy.yml for the next release

SUMMARY
Bump release version in galaxy.yml for the next release
ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2023-04-10 14:31:54 +00:00
Daniel Ziegenberg
7d069b597f add changelog fragment
Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2023-04-10 15:13:22 +02:00
Hideki Saito
38dd009615 Bump release version in galaxy.yml for the next release number.
Signed-off-by: Hideki Saito <saito@fgrep.org>
2023-04-10 17:45:13 +09:00
Daniel Ziegenberg
009ed3bed5 docs: fix profile_tasks callback documentation
Fixes: #412

Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2023-03-24 11:47:00 +01:00
Gregory Furlong
cc93ee8232 Add a changelog fragment in preparation for the pull request. 2022-12-14 11:14:35 -05:00
Gregory Furlong
e97087e616 Update firewalld module to consider the value of the icmp_block_inversion parameter when determining if icmp_block_inversion should be enabled/disabled. 2022-12-14 11:07:53 -05:00
Gregory Furlong
e647e147a1 Update firewalld module to consider the value of the masquerade parameter when determining if masquerade should be enabled/disabled. 2022-12-14 10:50:15 -05:00
Gregory Furlong
9575b9be64 Add changelog fragment documenting PR #402 2022-12-13 18:02:56 -05:00
Gregory Furlong
4229db1bbe Fix issue where interfaces could not be added to a zone when firewalld is offline. Resolves issue #357. 2022-12-13 17:27:59 -05:00
NdFeB
fa4dd35d66 Add changelog fragment for PR 333 2022-03-12 15:37:13 +01:00
NdFeB
211e6c74b5 Fix absent state documentation 2022-03-12 15:25:38 +01:00
139 changed files with 4486 additions and 7218 deletions

11
.ansible-lint Normal file
View File

@@ -0,0 +1,11 @@
---
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2024, Ansible Project
skip_list:
- meta-runtime[unsupported-version] # This rule doesn't make any sense
- fqcn[deep] # This rule produces false positives for files in tests/unit/plugins/action/fixtures/
- sanity[cannot-ignore] # This rule is skipped to keep backward compatibility with Python 2
exclude_paths:
- changelogs/

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,102 @@ variables:
resources: resources:
containers: containers:
- container: default - container: default
image: quay.io/ansible/azure-pipelines-test-container:3.0.0 image: quay.io/ansible/azure-pipelines-test-container:7.0.0
pool: Standard pool: Standard
stages: stages:
- stage: Sanity_devel
## Docker displayName: Ansible devel Sanity & Units & Lint
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_20
displayName: Ansible 2.20 Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.20/{0}
targets:
- name: Sanity
test: sanity
- name: Units
test: units
- name: Lint
test: lint
- stage: Sanity_2_19
displayName: Ansible 2.19 Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.19/{0}
targets:
- name: Sanity
test: sanity
- name: Units
test: units
- name: Lint
test: lint
- stage: Sanity_2_18
displayName: Ansible 2.18 Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.18/{0}
targets:
- name: Sanity
test: sanity
- name: Units
test: units
- name: Lint
test: lint
- stage: Sanity_2_17
displayName: Ansible 2.17 Sanity & Units & Lint
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
nameFormat: "{0}"
testFormat: 2.17/{0}
targets:
- name: Sanity
test: sanity
- name: Units
test: units
- name: Lint
test: lint
- stage: Sanity_2_16
displayName: Ansible 2.16 Sanity & Units & Lint
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
## Docker
- stage: Docker_devel - stage: Docker_devel
displayName: Docker devel displayName: Docker devel
dependsOn: [] dependsOn: []
@@ -51,138 +141,82 @@ stages:
parameters: parameters:
testFormat: devel/linux/{0}/1 testFormat: devel/linux/{0}/1
targets: targets:
- name: CentOS 7 - name: Fedora 42
test: centos7 test: fedora42
- name: Fedora 37
test: fedora37
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 20.04
test: ubuntu2004
- name: Ubuntu 22.04 - name: Ubuntu 22.04
test: ubuntu2204 test: ubuntu2204
- stage: Docker_2_14 - name: Ubuntu 24.04
displayName: Docker 2.14 test: ubuntu2404
- stage: Docker_2_20
displayName: Docker 2.20
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.14/linux/{0}/1 testFormat: 2.20/linux/{0}/1
targets: targets:
- name: CentOS 7 - name: Fedora 42
test: centos7 test: fedora42
- name: Fedora 36
test: fedora36
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 20.04
test: ubuntu2004
- name: Ubuntu 22.04 - name: Ubuntu 22.04
test: ubuntu2204 test: ubuntu2204
- stage: Docker_2_13 - name: Ubuntu 24.04
displayName: Docker 2.13 test: ubuntu2404
- stage: Docker_2_19
displayName: Docker 2.19
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.13/linux/{0}/1 testFormat: 2.19/linux/{0}/1
targets: targets:
- name: CentOS 7 - name: Fedora 41
test: centos7 test: fedora41
- name: Fedora 34 - name: Ubuntu 22.04
test: fedora34 test: ubuntu2204
- name: Fedora 35 - name: Ubuntu 24.04
test: fedora35 test: ubuntu2404
- name: openSUSE 15 py3 - stage: Docker_2_18
test: opensuse15 displayName: Docker 2.18
- name: Ubuntu 18.04
test: ubuntu1804
- name: Ubuntu 20.04
test: ubuntu2004
- stage: Docker_2_12
displayName: Docker 2.12
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.12/linux/{0}/1 testFormat: 2.18/linux/{0}/1
targets: targets:
- name: CentOS 6 - name: Fedora 40
test: centos6 test: fedora40
- name: CentOS 7 - name: Ubuntu 22.04
test: centos7 test: ubuntu2204
- name: Fedora 33 - name: Ubuntu 24.04
test: fedora33 test: ubuntu2404
- name: Fedora 34 - stage: Docker_2_17
test: fedora34 displayName: Docker 2.17
- 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: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.11/linux/{0}/1 testFormat: 2.17/linux/{0}/1
targets: targets:
- name: CentOS 6 - name: Fedora 39
test: centos6 test: fedora39
- name: CentOS 7 - name: Ubuntu 22.04
test: centos7 test: ubuntu2204
- name: openSUSE 15 py2 - stage: Docker_2_16
test: opensuse15py2 displayName: Docker 2.16
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 18.04
test: ubuntu1804
- stage: Docker_2_10
displayName: Docker 2.10
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.10/linux/{0}/1 testFormat: 2.16/linux/{0}/1
targets: targets:
- name: CentOS 6
test: centos6
- name: CentOS 7 - name: CentOS 7
test: centos7 test: centos7
- name: openSUSE 15 py2 - name: Fedora 38
test: opensuse15py2 test: fedora38
- name: openSUSE 15 py3 - name: Ubuntu 22.04
test: opensuse15 test: ubuntu2204
- 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: openSUSE 15 py2
test: opensuse15py2
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 16.04
test: ubuntu1604
- name: Ubuntu 18.04
test: ubuntu1804
## Remote ## Remote
- stage: Remote_devel - stage: Remote_devel
displayName: Remote devel displayName: Remote devel
dependsOn: [] dependsOn: []
@@ -191,136 +225,106 @@ stages:
parameters: parameters:
testFormat: devel/{0}/1 testFormat: devel/{0}/1
targets: targets:
- name: MacOS 13.2 - name: RHEL 10.0
test: macos/13.2 test: rhel/10.0
- name: RHEL 7.9 - name: RHEL 9.6
test: rhel/7.9 test: rhel/9.6
- name: RHEL 8.7 - name: FreeBSD 14.3
test: rhel/8.7 test: freebsd/14.3
- name: RHEL 9.1 - name: FreeBSD 13.5
test: rhel/9.1 test: freebsd/13.5
- name: FreeBSD 12.4 - stage: Remote_2_20
test: freebsd/12.4 displayName: Remote 2.20
- name: FreeBSD 13.1
test: freebsd/13.1
- stage: Remote_2_14
displayName: Remote 2.14
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.14/{0}/1 testFormat: 2.20/{0}/1
targets: targets:
- name: MacOS 12.0 - name: RHEL 10.0
test: macos/12.0 test: rhel/10.0
- name: RHEL 7.9 - name: RHEL 9.6
test: rhel/7.9 test: rhel/9.6
- name: RHEL 8.6 - name: FreeBSD 14.3
test: rhel/8.6 test: freebsd/14.3
- name: RHEL 9.0 - name: FreeBSD 13.5
test: rhel/9.0 test: freebsd/13.5
- name: FreeBSD 12.3 - stage: Remote_2_19
test: freebsd/12.3 displayName: Remote 2.19
- name: FreeBSD 13.1
test: freebsd/13.1
- 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.19/{0}/1
targets: targets:
- name: MacOS 12.0 - name: RHEL 10.0
test: macos/12.0 test: rhel/10.0
- name: RHEL 7.9 - name: RHEL 9.5
test: rhel/7.9 test: rhel/9.5
- name: RHEL 8.5 - name: FreeBSD 14.2
test: rhel/8.5 test: freebsd/14.2
- name: FreeBSD 12.3 - name: FreeBSD 13.5
test: freebsd/12.3 test: freebsd/13.5
- name: FreeBSD 13.0 - stage: Remote_2_18
test: freebsd/13.0 displayName: Remote 2.18
- stage: Remote_2_12
displayName: Remote 2.12
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.12/{0}/1 testFormat: 2.18/{0}/1
targets: targets:
- name: MacOS 11.1 - name: RHEL 10.0
test: macos/11.1 test: rhel/10.0
- name: RHEL 7.9 - name: RHEL 9.4
test: rhel/7.9 test: rhel/9.4
- name: RHEL 8.4 - name: FreeBSD 13.5
test: rhel/8.4 test: freebsd/13.5
- name: FreeBSD 12.2 - stage: Remote_2_17
test: freebsd/12.2 displayName: Remote 2.17
- name: FreeBSD 13.0
test: freebsd/13.0
- stage: Remote_2_11
displayName: Remote 2.11
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.11/{0}/1 testFormat: 2.17/{0}/1
targets: targets:
- name: MacOS 11.1 # 2.17 remote target doesn't have RHEL 9 image
test: macos/11.1 - name: RHEL 10.0
- name: RHEL 7.9 test: rhel/10.0
test: rhel/7.9 - name: FreeBSD 13.5
- name: RHEL 8.3 test: freebsd/13.5
test: rhel/8.3 - stage: Remote_2_16
- name: FreeBSD 12.2 displayName: Remote 2.16
test: freebsd/12.2
- stage: Remote_2_10
displayName: Remote 2.10
dependsOn: [] dependsOn: []
jobs: jobs:
- template: templates/matrix.yml - template: templates/matrix.yml
parameters: parameters:
testFormat: 2.10/{0}/1 testFormat: 2.16/{0}/1
targets: targets:
- name: OS X 10.11 # 2.16 remote target only has RHEL 9.6 image
test: osx/10.11 - name: RHEL 9.6
- name: RHEL 7.9 test: rhel/9.6
test: rhel/7.9
- name: RHEL 8.2
test: rhel/8.2
- stage: Remote_2_9
displayName: Remote 2.9
dependsOn: []
jobs:
- template: templates/matrix.yml
parameters:
testFormat: 2.9/{0}/1
targets:
- name: OS X 10.11
test: osx/10.11
- name: RHEL 7.9
test: rhel/7.9
- name: RHEL 8.1
test: rhel/8.1
## Finally ## Finally
- stage: Summary - stage: Summary
condition: succeededOrFailed() condition: succeededOrFailed()
dependsOn: dependsOn:
- Remote_2_9 - Sanity_2_16
- Docker_2_9 - Remote_2_16
- Remote_2_10 - Docker_2_16
- Docker_2_10 - Sanity_2_17
- Remote_2_11 - Remote_2_17
- Docker_2_11 - Docker_2_17
- Remote_2_12 - Sanity_2_18
- Docker_2_12 - Remote_2_18
- Remote_2_13 - Docker_2_18
- Docker_2_13 - Sanity_2_19
- Remote_2_14 - Remote_2_19
- Docker_2_14 - Docker_2_19
- Sanity_2_20
- Remote_2_20
- Docker_2_20
- Sanity_devel
- Remote_devel - Remote_devel
- Docker_devel - Docker_devel
jobs: jobs:

2
.github/BOTMETA.yml vendored
View File

@@ -1,3 +1,4 @@
---
automerge: false automerge: false
files: files:
$module_utils/mount.py: $module_utils/mount.py:
@@ -39,7 +40,6 @@ files:
labels: debug labels: debug
$plugins/patch.py: $plugins/patch.py:
labels: patch labels: patch
$plugins/skippy.py:
$plugins/synchronize.py: $plugins/synchronize.py:
labels: synchronize labels: synchronize
$plugins/timer.py: $plugins/timer.py:

View File

@@ -4,6 +4,134 @@ ansible.posix Release Notes
.. contents:: Topics .. contents:: Topics
v2.0.0
======
Release Summary
---------------
This is the major 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.6.2
Minor Changes
-------------
- authorized_keys - allow using absolute path to a file as a SSH key(s) source (https://github.com/ansible-collections/ansible.posix/pull/568)
- callback plugins - Add recap information to timer, profile_roles and profile_tasks callback outputs (https://github.com/ansible-collections/ansible.posix/pull/387).
Breaking Changes / Porting Guide
--------------------------------
- firewalld - Changed the type of forward and masquerade options from str to bool (https://github.com/ansible-collections/ansible.posix/issues/582).
- firewalld - Changed the type of icmp_block_inversion option from str to bool (https://github.com/ansible-collections/ansible.posix/issues/586).
Removed Features (previously deprecated)
----------------------------------------
- skippy - Remove skippy pluglin as it is no longer supported(https://github.com/ansible-collections/ansible.posix/issues/350).
Bugfixes
--------
- acl - Fixed to set ACLs on paths mounted with NFS version 4 correctly (https://github.com/ansible-collections/ansible.posix/issues/240).
- mount - Handle ``boot`` option on Linux, NetBSD and OpenBSD correctly (https://github.com/ansible-collections/ansible.posix/issues/364).
- mount - If a comment is appended to a fstab entry, state present creates a double-entry (https://github.com/ansible-collections/ansible.posix/issues/595).
v1.6.2
======
Release Summary
---------------
This is the bugfix release of the stable version ``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.6.1.
Bugfixes
--------
- backport - Drop ansible-core 2.14 and set 2.15 minimum version (https://github.com/ansible-collections/ansible.posix/issues/578).
v1.6.1
======
Release Summary
---------------
This is the bugfix release of the stable version ``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.6.1.
Bugfixes
--------
- acl - Fixed to set ACLs on paths mounted with NFS version 4 correctly (https://github.com/ansible-collections/ansible.posix/issues/240).
- mount - Handle ``boot`` option on Linux, NetBSD and OpenBSD correctly (https://github.com/ansible-collections/ansible.posix/issues/364).
- skippy - Revert removal of skippy plugin. It will be removed in version 2.0.0 (https://github.com/ansible-collections/ansible.posix/issues/573).
v1.6.0
======
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.4.
Major Changes
-------------
- Dropping support for Ansible 2.9, ansible-core 2.15 will be minimum required version for this release
Minor Changes
-------------
- Add summary_only parameter to profile_roles and profile_tasks callbacks.
- firewalld - add functionality to set forwarding (https://github.com/ansible-collections/ansible.posix/pull/548).
- firewalld - added offline flag implementation (https://github.com/ansible-collections/ansible.posix/pull/484)
- 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 - Only warn about ignored zones, when there are zones ignored.
- 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).
- mount - add no_log option for opts parameter (https://github.com/ansible-collections/ansible.posix/pull/563).
- 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).
Removed Features (previously deprecated)
----------------------------------------
- skippy - Remove skippy pluglin as it is no longer supported(https://github.com/ansible-collections/ansible.posix/issues/350).
Bugfixes
--------
- Bugfix in the documentation regarding the path option for authorised_key(https://github.com/ansible-collections/ansible.posix/issues/483).
- seboolean - make it work with disabled SELinux
- synchronize - maintain proper formatting of the remote paths (https://github.com/ansible-collections/ansible.posix/pull/361).
- sysctl - fix sysctl to work properly on symlinks (https://github.com/ansible-collections/ansible.posix/issues/111).
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 v1.5.2
====== ======

149
README.md
View File

@@ -2,116 +2,111 @@
<!-- Add CI and code coverage badges here. Samples included below. --> <!-- Add CI and code coverage badges here. Samples included below. -->
[![Build Status]( [![Build Status](
https://dev.azure.com/ansible/ansible.posix/_apis/build/status/CI?branchName=main)](https://dev.azure.com/ansible/ansible.posix/_build?definitionId=26) https://dev.azure.com/ansible/ansible.posix/_apis/build/status/CI?branchName=main)](https://dev.azure.com/ansible/ansible.posix/_build?definitionId=26)
[![Run Status](https://api.shippable.com/projects/5e669aaf8b17a60007e4d18d/badge?branch=main)]() <!--[![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/ansible.posix)](https://codecov.io/gh/ansible-collections/ansible.posix)--> [![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/ansible.posix)](https://codecov.io/gh/ansible-collections/ansible.posix)
## Communication
* Join the Ansible forum:
* [Get Help](https://forum.ansible.com/c/help/6): get help or help others.
* [Social Spaces](https://forum.ansible.com/c/chat/4): gather and interact with fellow enthusiasts.
* [News & Announcements](https://forum.ansible.com/c/news/5): track project-wide announcements including social events.
## Description
<!-- Describe the collection and why a user would want to use it. What does the collection do? --> <!-- Describe the collection and why a user would want to use it. What does the collection do? -->
An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and derivative Operating Systems. An Ansible Collection of modules and plugins that target POSIX UNIX/Linux and derivative Operating Systems.
## Supported Versions of Ansible ## Requirements
<!--start requires_ansible-->
## Ansible version compatibility
This collection has been tested against following Ansible versions: **>=2.9**. * Python:
* The Python interpreter version must meet Ansible Core's requirements.
* Ansible Core:
- ansible-core 2.16 or later
For collections that support Ansible 2.9, please ensure you update your `network_os` to use the ## Installation
fully qualified collection name (for example, `cisco.ios.ios`).
Plugins and modules within a collection may be tested with only specific Ansible versions.
A collection may contain metadata that identifies these versions.
PEP440 is the schema used to describe the versions of Ansible.
<!--end requires_ansible-->
## Included content Before using this collection, you need to install it with the Ansible Galaxy command-line tool:
<!-- Galaxy will eventually list the module docs within the UI, but until that is ready, you may need to either describe your plugins etc here, or point to an external docsite to cover that information. -->
<!--start collection content-->
### Modules
Name | Description
--- | ---
[ansible.posix.acl](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.acl_module.rst)|Set and retrieve file ACL information.
[ansible.posix.at](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.at_module.rst)|Schedule the execution of a command or script file via the at command
[ansible.posix.authorized_key](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.authorized_key_module.rst)|Adds or removes an SSH authorized key
[ansible.posix.firewalld](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.firewalld_module.rst)|Manage arbitrary ports/services with 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.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.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.sysctl](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.sysctl_module.rst)|Manage entries in sysctl.conf.
<!--end collection content--> ```shell
ansible-galaxy collection install ansible.posix
```
## Installing this collection You can also include it in a requirements.yml file and install it with ansible-galaxy collection install -r requirements.yml, using the format:
You can install the ``ansible.posix`` collection with the Ansible Galaxy CLI:
ansible-galaxy collection install ansible.posix
You can also include it in a `requirements.yml` file and install it with `ansible-galaxy collection install -r requirements.yml`, using the format:
```yaml ```yaml
---
collections: collections:
- name: ansible.posix - name: ansible.posix
``` ```
## Using this collection Note that if you install any collections from Ansible Galaxy, they will not be upgraded automatically when you upgrade the Ansible package.
To upgrade the collection to the latest available version, run the following command:
<!--Include some quick examples that cover the most common use cases for your collection content. --> ```shell
ansible-galaxy collection install ansible.posix --upgrade
```
See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details. You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version 2.0.0:
**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. ```shell
ansible-galaxy collection install ansible.posix:==2.0.0
```
## Contributing to this collection See [using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for more details.
<!--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). --> * The Ansible [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn): used to announce releases and important changes.
We welcome community contributions to this collection. See [Contributing to Ansible-maintained collections](https://docs.ansible.com/ansible/devel/community/contributing_maintained_collections.html#contributing-maintained-collections) for complete details. For more information about communication, see the [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
## Use Cases
You can see the general use-cases as an example by `ansible-doc` command like below.
For example, ansible.posix.firewalld module:
```shell
ansible-doc ansible.posix.firewalld
```
Also, if you want to confirm the plugins descriptions, you can follow the following option with `ansible-doc` command:
For example, ansible.posix.profile_tasks callback plugin:
```shell
ansible-doc -t callback ansible.posix.profile_tasks
```
## Testing
The following ansible-core versions have been tested with this collection:
- ansible-core 2.20 (devel)
- ansible-core 2.19 (stable) *
- ansible-core 2.18 (stable)
- ansible-core 2.17 (stable)
## Contributing
We welcome community contributions to this collection. For more details, see [Contributing to Ansible-maintained collections](https://docs.ansible.com/ansible/devel/community/contributing_maintained_collections.html#contributing-maintained-collections) for complete details.
* [Issues](https://github.com/ansible-collections/ansible.posix/issues) * [Issues](https://github.com/ansible-collections/ansible.posix/issues)
* [Pull Requests](https://github.com/ansible-collections/ansible.posix/pulls) * [Pull Requests](https://github.com/ansible-collections/ansible.posix/pulls)
* [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html) * [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html)
### Code of Conduct
This collection follows the Ansible project's
[Code of Conduct](https://docs.ansible.com/ansible/devel/community/code_of_conduct.html).
Please read and familiarize yourself with this document.
## Release notes ## Support
See [Communication](#Communication) section.
## Release Notes and Roadmap
See [changelog](https://github.com/ansible-collections/ansible.posix/blob/main/CHANGELOG.rst) for more details. See [changelog](https://github.com/ansible-collections/ansible.posix/blob/main/CHANGELOG.rst) for more details.
## External requirements ## Related Information
None This document was written using the following [template](https://access.redhat.com/articles/7068606).
## Tested with Ansible The README has been carefully prepared to cover the [community template](https://github.com/ansible-collections/collection_template/blob/main/README.md), but if you find any problems, please file a [documentation issue](https://github.com/ansible-collections/ansible.posix/issues/new?assignees=&labels=&projects=&template=documentation_report.md).
<!-- List the versions of Ansible the collection has been tested with. Must match what is in galaxy.yml. --> ## License Information
- ansible-core 2.14 (devel)
- ansible-core 2.13 (stable)
- ansible-core 2.12 (stable)
- ansible-core 2.11 (stable)
- ansible-base 2.10 (stable)
- ansible 2.9 (stable)
## Roadmap
<!-- Optional. Include the roadmap for this collection, and the proposed release/versioning strategy so users can anticipate the upgrade/update cycle. -->
## More information
<!-- List out where the user can find additional information, such as working group meeting times, slack/IRC channels, or documentation for the product this collection automates. At a minimum, link to: -->
- [Ansible Collection overview](https://github.com/ansible-collections/overview)
- [Ansible User guide](https://docs.ansible.com/ansible/latest/user_guide/index.html)
- [Ansible Developer guide](https://docs.ansible.com/ansible/latest/dev_guide/index.html)
- [Ansible Community code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html)
## Licensing
GNU General Public License v3.0 or later. GNU General Public License v3.0 or later.

View File

@@ -321,3 +321,172 @@ releases:
- 434-fix-rhel_facts-exit_json.yml - 434-fix-rhel_facts-exit_json.yml
- 535-add-jsonl-callback.yml - 535-add-jsonl-callback.yml
release_date: '2023-04-07' 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'
1.6.0:
changes:
bugfixes:
- Bugfix in the documentation regarding the path option for authorised_key(https://github.com/ansible-collections/ansible.posix/issues/483).
- seboolean - make it work with disabled SELinux
- synchronize - maintain proper formatting of the remote paths (https://github.com/ansible-collections/ansible.posix/pull/361).
- sysctl - fix sysctl to work properly on symlinks (https://github.com/ansible-collections/ansible.posix/issues/111).
major_changes:
- Dropping support for Ansible 2.9, ansible-core 2.15 will be minimum required
version for this release
minor_changes:
- Add summary_only parameter to profile_roles and profile_tasks callbacks.
- firewalld - add functionality to set forwarding (https://github.com/ansible-collections/ansible.posix/pull/548).
- firewalld - added offline flag implementation (https://github.com/ansible-collections/ansible.posix/pull/484)
- 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 - Only warn about ignored zones, when there are zones ignored.
- 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).
- mount - add no_log option for opts parameter (https://github.com/ansible-collections/ansible.posix/pull/563).
- 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).
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.4.'
removed_features:
- skippy - Remove skippy pluglin as it is no longer supported(https://github.com/ansible-collections/ansible.posix/issues/350).
fragments:
- 1.6.0.yml
- 206_fix_sysctl_to_work_on_symlinks.yml
- 333_doc_absent_precision.yml
- 361_maintain_proper_formating_remote_paths.yml
- 421-remove-deprecation-warning.yml
- 460-respawn.yaml
- 466-tests.yml
- 477_ci_update.yml
- 484-firewalld-offline.yml
- 487_ci_update.yml
- 490_doc_authorized_key_path.yml
- 496_seboolean-make-it-wrk-with-SELinux-disabled.yaml
- 504-firewalld_info-warning.yaml
- 508_ci_update.yml
- 510_ci_update.yml
- 511_profile-callbacks-add-summary-only-parameter.yml
- 548_add_foward.yml
- 556_remove_skippy_callback.yml
- 562_update_core_version.yml
- 563_add_no_log_option.yml
- dropping-ansible29.yml
- test-reqs.yml
release_date: '2024-09-11'
1.6.1:
changes:
bugfixes:
- acl - Fixed to set ACLs on paths mounted with NFS version 4 correctly (https://github.com/ansible-collections/ansible.posix/issues/240).
- mount - Handle ``boot`` option on Linux, NetBSD and OpenBSD correctly (https://github.com/ansible-collections/ansible.posix/issues/364).
- skippy - Revert removal of skippy plugin. It will be removed in version 2.0.0
(https://github.com/ansible-collections/ansible.posix/issues/573).
release_summary: 'This is the bugfix release of the stable version ``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.6.1.'
fragments:
- 1.6.1.yml
- 365-boot-linux.yml
- 566_bump_version_161.yml
- 567_remove_version_added.yml
- 570_nfs4_acl.yml
- 571_ci_bump_core_version.yml
- 572_revert_removal_of_skippy.yml
release_date: '2024-10-11'
1.6.2:
changes:
bugfixes:
- backport - Drop ansible-core 2.14 and set 2.15 minimum version (https://github.com/ansible-collections/ansible.posix/issues/578).
release_summary: 'This is the bugfix release of the stable version ``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.6.1.'
fragments:
- 1.6.2.yml
- 580_drop_ansible214.yml
release_date: '2024-10-22'
2.0.0:
changes:
breaking_changes:
- firewalld - Changed the type of forward and masquerade options from str to
bool (https://github.com/ansible-collections/ansible.posix/issues/582).
- firewalld - Changed the type of icmp_block_inversion option from str to bool
(https://github.com/ansible-collections/ansible.posix/issues/586).
bugfixes:
- acl - Fixed to set ACLs on paths mounted with NFS version 4 correctly (https://github.com/ansible-collections/ansible.posix/issues/240).
- mount - Handle ``boot`` option on Linux, NetBSD and OpenBSD correctly (https://github.com/ansible-collections/ansible.posix/issues/364).
- mount - If a comment is appended to a fstab entry, state present creates a
double-entry (https://github.com/ansible-collections/ansible.posix/issues/595).
minor_changes:
- authorized_keys - allow using absolute path to a file as a SSH key(s) source
(https://github.com/ansible-collections/ansible.posix/pull/568)
- callback plugins - Add recap information to timer, profile_roles and profile_tasks
callback outputs (https://github.com/ansible-collections/ansible.posix/pull/387).
release_summary: 'This is the major 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.6.2'
removed_features:
- skippy - Remove skippy pluglin as it is no longer supported(https://github.com/ansible-collections/ansible.posix/issues/350).
fragments:
- 2.0.0.yml
- 365-boot-linux.yml
- 387_callback_output_header.yml
- 556_remove_skippy_callback.yml
- 566_bump_version_161.yml
- 567_remove_version_added.yml
- 568_update_authorized_key.yml
- 570_nfs4_acl.yml
- 571_ci_bump_core_version.yml
- 576_bump_version_2.yml
- 581_ci_selinux.yml
- 584_firewalld_opt_type.yml
- 587_update_README.yml
- 588_ci_enable_devel.yml
- 593_replace_freebsd_version.yml
- 597_remove_fstab_comment_on_updating.yml
- 598_icmp_block_inversion.yml
release_date: '2024-12-04'

View File

@@ -0,0 +1,2 @@
trivial:
- Bump version to 3.0.0 for the next release (https://github.com/ansible-collections/ansible.posix/issues/603).

View File

@@ -0,0 +1,2 @@
trivial:
- Remove ubuntu20.04 from CI tests (https://github.com/ansible-collections/ansible.posix/issues/612).

View File

@@ -0,0 +1,3 @@
---
minor_changes:
- profile_tasks - Add option to provide a different date/time format (https://github.com/ansible-collections/ansible.posix/issues/279).

View File

@@ -0,0 +1,6 @@
---
bugfixes:
- ansible.posix.cgroup_perf_recap - fixes json module load path (https://github.com/ansible-collections/ansible.posix/issues/630).
trivial:
- ansible.posix.seboolean - remove unnecessary condition from seboolean integration tests (https://github.com/ansible-collections/ansible.posix/issues/630).
- ansible.posix.selinux - optimize conditions for selinux integration tests (https://github.com/ansible-collections/ansible.posix/issues/630).

View File

@@ -0,0 +1,3 @@
---
bugfixes:
- ansible.posix.authorized_key - fixes error on permission denied in authorized_key module (https://github.com/ansible-collections/ansible.posix/issues/462).

View File

@@ -0,0 +1,2 @@
trivial:
- Add Red Hat Enterprise Linux 10.0 to the CI matrix (https://github.com/ansible-collections/ansible.posix/issues/642).

View File

@@ -0,0 +1,2 @@
minor_changes:
- "profile_tasks and profile_roles callback plugins - avoid deleted/deprecated callback functions, instead use modern interface that was introduced a longer time ago (https://github.com/ansible-collections/ansible.posix/issues/650)."

View File

@@ -0,0 +1,3 @@
---
trivial:
- Bump ansible-core version to 2.20 of devel branch and add 2.19 to CI

View File

@@ -0,0 +1,2 @@
trivial:
- AZP - fixed syntax error in CI test.

View File

@@ -0,0 +1,3 @@
---
trivial:
- README - Update README to reflect Ansible Core 2.19 release.

View File

@@ -0,0 +1,3 @@
---
trivial:
- AZP - Update AZP matrix to follow ansible-test changes.

View File

@@ -0,0 +1,3 @@
bugfixes:
- "firewalld_info - stop returning warnings as return values; this has been deprecated by ansible-core (https://github.com/ansible-collections/ansible.posix/pull/670)."
- "mount - stop returning warnings as return values; this has been deprecated by ansible-core (https://github.com/ansible-collections/ansible.posix/pull/670)."

View File

@@ -0,0 +1,2 @@
trivial:
- Update AZP CI matrix (https://github.com/ansible-collections/ansible.posix/issues/673).

View File

@@ -0,0 +1,4 @@
trivial:
- Updatng AZP CI matrix to ignore ansible-bad-import-from on six(https://github.com/ansible-collections/ansible.posix/pull/682).
- Skipped sanity[cannot-ignore] to keep backward compatibility with Python2.
- Consolidate all ansible-lint option locations into .ansible-lint file.

View File

@@ -0,0 +1,5 @@
---
trivial:
- AZP - Update AZP matrix to follow ansible-test changes.
- Add ignore file for Ansible Core 2.21.
- Remove ignore lines for ansible-bad-import-from in 2.20 sanity tests.

View File

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

View File

@@ -1,346 +0,0 @@
.. _ansible.posix.acl_module:
*****************
ansible.posix.acl
*****************
**Set and retrieve file ACL information.**
Version added: 1.0.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Set and retrieve file ACL information.
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>default</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>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>true</code> causes an error if the path is a file.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>entity</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 actual user or group that the ACL applies to when matching entity types user or group are selected.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>entry</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>DEPRECATED.</div>
<div>The ACL to set or remove.</div>
<div>This must always be quoted in the form of <code>&lt;etype&gt;:&lt;qualifier&gt;:&lt;perms&gt;</code>.</div>
<div>The qualifier may be empty for some types, but the type and perms are always required.</div>
<div><code>-</code> can be used as placeholder when you do not care about permissions.</div>
<div>This is now superseded by entity, type and permissions fields.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>etype</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>group</li>
<li>mask</li>
<li>other</li>
<li>user</li>
</ul>
</td>
<td>
<div>The entity type of the ACL to apply, see <code>setfacl</code> documentation for more info.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>follow</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>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Whether to follow symlinks on the path if a symlink is encountered.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>path</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>The full path of the file or object.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: name</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>permissions</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>The permissions to apply/remove can be any combination of <code>r</code>, <code>w</code>, <code>x</code></div>
<div>(read, write and execute respectively), and <code>X</code> (execute permission if the file is a directory or already has execute permission for some user)</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>recalculate_mask</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><div style="color: blue"><b>default</b>&nbsp;&larr;</div></li>
<li>mask</li>
<li>no_mask</li>
</ul>
</td>
<td>
<div>Select if and when to recalculate the effective right masks of the files.</div>
<div>See <code>setfacl</code> documentation for more info.</div>
<div>Incompatible with <code>state=query</code>.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>recursive</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>Recursively sets the specified ACL.</div>
<div>Incompatible with <code>state=query</code>.</div>
<div>Alias <code>recurse</code> added in version 1.3.0.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: recurse</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>present</li>
<li><div style="color: blue"><b>query</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Define whether the ACL should be present or not.</div>
<div>The <code>query</code> state gets the current ACL without changing it, for use in <code>register</code> operations.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>use_nfsv4_acls</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>Use NFSv4 ACLs instead of POSIX ACLs.</div>
</td>
</tr>
</table>
<br/>
Notes
-----
.. note::
- The ``acl`` module requires that ACLs are enabled on the target filesystem and that the ``setfacl`` and ``getfacl`` binaries are installed.
- As of Ansible 2.0, this module only supports Linux distributions.
- As of Ansible 2.3, the *name* option has been changed to *path* as default, but *name* still works as well.
Examples
--------
.. code-block:: yaml
- name: Grant user Joe read access to a file
ansible.posix.acl:
path: /etc/foo.conf
entity: joe
etype: user
permissions: r
state: present
- name: Removes the ACL for Joe on a specific file
ansible.posix.acl:
path: /etc/foo.conf
entity: joe
etype: user
state: absent
- name: Sets default ACL for joe on /etc/foo.d/
ansible.posix.acl:
path: /etc/foo.d/
entity: joe
etype: user
permissions: rw
default: true
state: present
- name: Same as previous but using entry shorthand
ansible.posix.acl:
path: /etc/foo.d/
entry: default:user:joe:rw-
state: present
- name: Obtain the ACL for a specific file
ansible.posix.acl:
path: /etc/foo.conf
register: acl_info
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>acl</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>Current ACL on provided path (after changes, if any)</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;user::rwx&#x27;, &#x27;group::rwx&#x27;, &#x27;other::rwx&#x27;]</div>
</td>
</tr>
</table>
<br/><br/>
Status
------
Authors
~~~~~~~
- Brian Coca (@bcoca)
- Jérémie Astori (@astorije)

View File

@@ -1,186 +0,0 @@
.. _ansible.posix.at_module:
****************
ansible.posix.at
****************
**Schedule the execution of a command or script file via the at command**
Version added: 1.0.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Use this module to schedule a command or script file to run once in the future.
- All jobs are executed in the 'a' queue.
Requirements
------------
The below requirements are needed on the host that executes this module.
- at
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>command</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>A command to be executed in the future.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>count</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
</div>
</td>
<td>
</td>
<td>
<div>The count of units in the future to execute the command or script file.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>script_file</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>An existing script file to be executed in the future.</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><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>The state dictates if the command or script file should be evaluated as present(added) or absent(deleted).</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>unique</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>If a matching job is present a new job will not be added.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>units</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>minutes</li>
<li>hours</li>
<li>days</li>
<li>weeks</li>
</ul>
</td>
<td>
<div>The type of units in the future to execute the command or script file.</div>
</td>
</tr>
</table>
<br/>
Examples
--------
.. code-block:: yaml
- name: Schedule a command to execute in 20 minutes as root
ansible.posix.at:
command: ls -d / >/dev/null
count: 20
units: minutes
- name: Match a command to an existing job and delete the job
ansible.posix.at:
command: ls -d / >/dev/null
state: absent
- name: Schedule a command to execute in 20 minutes making sure it is unique in the queue
ansible.posix.at:
command: ls -d / >/dev/null
count: 20
units: minutes
unique: true
Status
------
Authors
~~~~~~~
- Richard Isaacson (@risaacson)

View File

@@ -1,480 +0,0 @@
.. _ansible.posix.authorized_key_module:
****************************
ansible.posix.authorized_key
****************************
**Adds or removes an SSH authorized key**
Version added: 1.0.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Adds or removes SSH authorized keys for particular user accounts.
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>comment</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>Change the comment on the public key.</div>
<div>Rewriting the comment is useful in cases such as fetching it from GitHub or GitLab.</div>
<div>If no comment is specified, the existing comment will be kept.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>exclusive</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>Whether to remove all other non-specified keys from the authorized_keys file.</div>
<div>Multiple keys can be specified in a single <code>key</code> string value by separating them by newlines.</div>
<div>This option is not loop aware, so if you use <code>with_</code> , it will be exclusive per iteration of the loop.</div>
<div>If you want multiple keys in the file you need to pass them all to <code>key</code> in a single batch as mentioned above.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>follow</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>Follow path symlink instead of replacing it.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>key</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>The SSH public key(s), as a string or (since Ansible 1.9) url (https://github.com/username.keys).</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>key_options</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>A string of ssh key options to be prepended to the key in the authorized_keys file.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>manage_dir</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>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Whether this module should manage the directory of the authorized key file.</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=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>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>path</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
</div>
</td>
<td>
</td>
<td>
<div>Alternate path to the authorized_keys file.</div>
<div>When unset, this value defaults to <em>~/.ssh/authorized_keys</em>.</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><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Whether the given key (with the given key_options) should or should not be in the file.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>user</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>The username on the remote host whose authorized_keys file will be modified.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>validate_certs</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>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>This only applies if using a https url as the source of the keys.</div>
<div>If set to <code>false</code>, the SSL certificates will not be validated.</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>true</code>.</div>
</td>
</tr>
</table>
<br/>
Examples
--------
.. code-block:: yaml
- name: Set authorized key taken from file
ansible.posix.authorized_key:
user: charlie
state: present
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
- name: Set authorized keys taken from url
ansible.posix.authorized_key:
user: charlie
state: present
key: https://github.com/charlie.keys
- name: Set authorized keys taken from url using lookup
ansible.posix.authorized_key:
user: charlie
state: present
key: "{{ lookup('url', 'https://github.com/charlie.keys', split_lines=False) }}"
- name: Set authorized key in alternate location
ansible.posix.authorized_key:
user: charlie
state: present
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
path: /etc/ssh/authorized_keys/charlie
manage_dir: false
- name: Set up multiple authorized keys
ansible.posix.authorized_key:
user: deploy
state: present
key: '{{ item }}'
with_file:
- public_keys/doe-jane
- public_keys/doe-john
- name: Set authorized key defining key options
ansible.posix.authorized_key:
user: charlie
state: present
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
key_options: 'no-port-forwarding,from="10.0.1.1"'
- name: Set authorized key without validating the TLS/SSL certificates
ansible.posix.authorized_key:
user: charlie
state: present
key: https://github.com/user.keys
validate_certs: false
- name: Set authorized key, removing all the authorized keys already set
ansible.posix.authorized_key:
user: root
key: "{{ lookup('file', 'public_keys/doe-jane') }}"
state: present
exclusive: true
- name: Set authorized key for user ubuntu copying it from current user
ansible.posix.authorized_key:
user: ubuntu
state: present
key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
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>exclusive</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>success</td>
<td>
<div>If the key has been forced to be exclusive or not.</div>
<br/>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>key</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>success</td>
<td>
<div>The key that the module was running against.</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;">https://github.com/user.keys</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>key_option</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>success</td>
<td>
<div>Key options related to the key.</div>
<br/>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>keyfile</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>success</td>
<td>
<div>Path for authorized key file.</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;">/home/user/.ssh/authorized_keys</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>manage_dir</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>success</td>
<td>
<div>Whether this module managed the directory of the authorized key file.</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;">True</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>path</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>success</td>
<td>
<div>Alternate path to the authorized_keys file</div>
<br/>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>state</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>success</td>
<td>
<div>Whether the given key (with the given key_options) should or should not be in the file</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;">present</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>unique</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>success</td>
<td>
<div>Whether the key is unique</div>
<br/>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>user</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>success</td>
<td>
<div>The username on the remote host whose authorized_keys file will be modified</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;">user</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>validate_certs</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>success</td>
<td>
<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/>
<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>
</td>
</tr>
</table>
<br/><br/>
Status
------
Authors
~~~~~~~
- Ansible Core Team

View File

@@ -1,526 +0,0 @@
.. _ansible.posix.firewalld_info_module:
****************************
ansible.posix.firewalld_info
****************************
**Gather information about firewalld**
.. contents::
:local:
:depth: 1
Synopsis
--------
- This module gathers information about firewalld rules.
Requirements
------------
The below requirements are needed on the host that executes this module.
- firewalld >= 0.2.11
- python-firewall
- python-dbus
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>active_zones</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>Gather information about active zones.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>zones</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>
</td>
<td>
<div>Gather information about specific zones.</div>
<div>If only works if <code>active_zones</code> is set to <code>false</code>.</div>
</td>
</tr>
</table>
<br/>
Examples
--------
.. code-block:: yaml
- name: Gather information about active zones
ansible.posix.firewalld_info:
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
ansible.posix.firewalld_info:
zones:
- public
- external
- internal
register: result
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="4">Key</th>
<th>Returned</th>
<th width="100%">Description</th>
</tr>
<tr>
<td colspan="4">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>active_zones</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>success</td>
<td>
<div>Gather active zones only if turn it <code>true</code>.</div>
<br/>
</td>
</tr>
<tr>
<td colspan="4">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>collected_zones</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of collected zones.</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;external&#x27;, &#x27;internal&#x27;]</div>
</td>
</tr>
<tr>
<td colspan="4">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>firewalld_info</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>
<div>Returns various information about firewalld configuration.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="3">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>default_zone</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>success</td>
<td>
<div>The zone name of default zone.</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;">public</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="3">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>version</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>success</td>
<td>
<div>The version information of firewalld.</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;">0.8.2</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="3">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>zones</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>
<div>A dict of zones to gather information.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>zone</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">complex</span>
</div>
</td>
<td>success</td>
<td>
<div>The zone name registered in firewalld.</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;">external</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>forward</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>success</td>
<td>
<div>The network interface forwarding.</div>
<div>This parameter supports on python-firewall 0.9.0(or later) and is not collected in earlier versions.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>forward_ports</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of forwarding port pair with protocol.</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;icmp&#x27;, &#x27;ipv6-icmp&#x27;]</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>icmp_block_inversion</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>success</td>
<td>
<div>The ICMP block inversion to block all ICMP requests.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>icmp_blocks</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of blocking icmp protocol.</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;echo-request&#x27;]</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>interfaces</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of network interfaces.</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;eth0&#x27;, &#x27;eth1&#x27;]</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>masquerade</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>success</td>
<td>
<div>The network interface masquerading.</div>
<br/>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>ports</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of network port with protocol.</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;22&#x27;, &#x27;tcp&#x27;], [&#x27;80&#x27;, &#x27;tcp&#x27;]]</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>protocols</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of network protocol.</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;icmp&#x27;, &#x27;ipv6-icmp&#x27;]</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>rich_rules</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of rich language rule.</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;rule protocol value=&quot;icmp&quot; reject&#x27;, &#x27;rule priority=&quot;32767&quot; reject&#x27;]</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>services</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of network services.</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;dhcp&#x27;, &#x27;dns&#x27;, &#x27;ssh&#x27;]</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>source_ports</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of network source port with protocol.</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;30000&#x27;, &#x27;tcp&#x27;], [&#x27;30001&#x27;, &#x27;tcp&#x27;]]</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>sources</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of source network address.</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;172.16.30.0/24&#x27;, &#x27;172.16.31.0/24&#x27;]</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td class="elbow-placeholder">&nbsp;</td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>target</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>success</td>
<td>
<div>A list of services in the zone.</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;">ACCEPT</div>
</td>
</tr>
<tr>
<td colspan="4">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>undefined_zones</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>success</td>
<td>
<div>A list of undefined zones in <code>zones</code> option.</div>
<div><code>undefined_zones</code> will be ignored for gathering process.</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;foo&#x27;, &#x27;bar&#x27;]</div>
</td>
</tr>
</table>
<br/><br/>
Status
------
Authors
~~~~~~~
- Hideki Saito (@saito-hideki)

View File

@@ -1,521 +0,0 @@
.. _ansible.posix.firewalld_module:
***********************
ansible.posix.firewalld
***********************
**Manage arbitrary ports/services with firewalld**
.. contents::
:local:
:depth: 1
Synopsis
--------
- This module allows for addition or deletion of services and ports (either TCP or UDP) in either running or permanent firewalld rules.
Requirements
------------
The below requirements are needed on the host that executes this module.
- firewalld >= 0.2.11
- python-firewall >= 0.2.11
Parameters
----------
.. raw:: html
<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="2">Parameter</th>
<th>Choices/<font color="blue">Defaults</font></th>
<th width="100%">Comments</th>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>icmp_block</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>The ICMP block you would like to add/remove to/from a zone in firewalld.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>icmp_block_inversion</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>Enable/Disable inversion of ICMP blocks for a zone in firewalld.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>immediate</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>Should this configuration be applied immediately, if set as permanent.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>interface</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>The interface you would like to add/remove to/from a zone in firewalld.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>masquerade</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>The masquerade setting you would like to enable/disable to/from zones within firewalld.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>offline</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>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Whether to run this module even when firewalld is offline.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>permanent</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>no</li>
<li>yes</li>
</ul>
</td>
<td>
<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>Note that if this is <code>false</code>, immediate is assumed <code>true</code>.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>port</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 port or port range to add/remove to/from firewalld.</div>
<div>Must be in the form PORT/PROTOCOL or PORT-PORT/PROTOCOL for port ranges.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>port_forward</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=dictionary</span>
</div>
</td>
<td>
</td>
<td>
<div>Port and protocol to forward using firewalld.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>port</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Source port to forward from</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>proto</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>udp</li>
<li>tcp</li>
</ul>
</td>
<td>
<div>protocol to forward</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>toaddr</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>Optional address to forward to</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>toport</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>destination port</div>
</td>
</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>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>rich_rule</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>Rich rule to add/remove to/from firewalld.</div>
<div>See <a href='https://firewalld.org/documentation/man-pages/firewalld.richlanguage.html'>Syntax for firewalld rich language rules</a>.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>service</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 service to add/remove to/from firewalld.</div>
<div>The service must be listed in output of firewall-cmd --get-services.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>source</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>The source/network you would like to add/remove to/from firewalld.</div>
</td>
</tr>
<tr>
<td colspan="2">
<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>
/ <span style="color: red">required</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>absent</li>
<li>disabled</li>
<li>enabled</li>
<li>present</li>
</ul>
</td>
<td>
<div>Enable or disable a setting.</div>
<div>For ports: Should this port accept (enabled) or reject (disabled) connections.</div>
<div>The states <code>present</code> and <code>absent</code> can only be used in zone level operations (i.e. when no other parameters but zone and state are set).</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>target</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 1.2.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>default</li>
<li>ACCEPT</li>
<li>DROP</li>
<li>%%REJECT%%</li>
</ul>
</td>
<td>
<div>firewalld Zone target</div>
<div>If state is set to <code>absent</code>, this will reset the target to default</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>timeout</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">0</div>
</td>
<td>
<div>The amount of time in seconds the rule should be in effect for when non-permanent.</div>
</td>
</tr>
<tr>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>zone</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>The firewalld zone to add/remove to/from.</div>
<div>Note that the default zone can be configured per system but <code>public</code> is default from upstream.</div>
<div>Available choices can be extended based on per-system configs, listed here are &quot;out of the box&quot; defaults.</div>
<div>Possible values include <code>block</code>, <code>dmz</code>, <code>drop</code>, <code>external</code>, <code>home</code>, <code>internal</code>, <code>public</code>, <code>trusted</code>, <code>work</code>.</div>
</td>
</tr>
</table>
<br/>
Notes
-----
.. note::
- Not tested on any Debian based system.
- Requires the python2 bindings of firewalld, which may not be installed by default.
- For distributions where the python2 firewalld bindings are unavailable (e.g Fedora 28 and later) you will have to set the ansible_python_interpreter for these hosts to the python3 interpreter path and install the python3 bindings.
- Zone transactions (creating, deleting) can be performed by using only the zone and state parameters "present" or "absent". Note that zone transactions must explicitly be permanent. This is a limitation in firewalld. This also means that you will have to reload firewalld after adding a zone that you wish to perform immediate actions on. The module will not take care of this for you implicitly because that would undo any previously performed immediate actions which were not permanent. Therefore, if you require immediate access to a newly created zone it is recommended you reload firewalld immediately after the zone creation returns with a changed state and before you perform any other immediate, non-permanent actions on that zone.
- This module needs ``python-firewall`` or ``python3-firewall`` on managed nodes. It is usually provided as a subset with ``firewalld`` from the OS distributor for the OS default Python interpreter.
Examples
--------
.. code-block:: yaml
- name: permit traffic in default zone for https service
ansible.posix.firewalld:
service: https
permanent: true
state: enabled
- name: permit ospf traffic
ansible.posix.firewalld:
protocol: ospf
permanent: true
state: enabled
- name: do not permit traffic in default zone on port 8081/tcp
ansible.posix.firewalld:
port: 8081/tcp
permanent: true
state: disabled
- ansible.posix.firewalld:
port: 161-162/udp
permanent: true
state: enabled
- ansible.posix.firewalld:
zone: dmz
service: http
permanent: true
state: enabled
- ansible.posix.firewalld:
rich_rule: rule service name="ftp" audit limit value="1/m" accept
permanent: true
state: enabled
- ansible.posix.firewalld:
source: 192.0.2.0/24
zone: internal
state: enabled
- ansible.posix.firewalld:
zone: trusted
interface: eth2
permanent: true
state: enabled
- ansible.posix.firewalld:
masquerade: true
state: enabled
permanent: true
zone: dmz
- ansible.posix.firewalld:
zone: custom
state: present
permanent: true
- ansible.posix.firewalld:
zone: drop
state: enabled
permanent: true
icmp_block_inversion: true
- ansible.posix.firewalld:
zone: drop
state: enabled
permanent: true
icmp_block: echo-request
- ansible.posix.firewalld:
zone: internal
state: present
permanent: true
target: ACCEPT
- name: Redirect port 443 to 8443 with Rich Rule
ansible.posix.firewalld:
rich_rule: rule family=ipv4 forward-port port=443 protocol=tcp to-port=8443
zone: public
permanent: true
immediate: true
state: enabled
Status
------
Authors
~~~~~~~
- Adam Miller (@maxamillion)

View File

@@ -1,336 +0,0 @@
.. _ansible.posix.mount_module:
*******************
ansible.posix.mount
*******************
**Control active and configured mount points**
Version added: 1.0.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- This module controls active and configured mount points in ``/etc/fstab``.
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>backup</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>Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>boot</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>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Determines if the filesystem should be mounted on boot.</div>
<div>Only applies to Solaris and Linux systems.</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>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>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>dump</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">"0"</div>
</td>
<td>
<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>Has no effect on Solaris systems or when used with <code>ephemeral</code>.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>fstab</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>File to use instead of <code>/etc/fstab</code>.</div>
<div>You should not use this option unless you really know what you are doing.</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>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>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>fstype</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>Filesystem type.</div>
<div>Required when <em>state</em> is <code>present</code>, <code>mounted</code> or <code>ephemeral</code>.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>opts</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>Mount options (see fstab(5), or vfstab(4) on Solaris).</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>passno</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">"0"</div>
</td>
<td>
<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>Deprecated on Solaris systems. Has no effect when used with <code>ephemeral</code>.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>path</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Path to the mount point (e.g. <code>/mnt/files</code>).</div>
<div>Before Ansible 2.3 this option was only usable as <em>dest</em>, <em>destfile</em> and <em>name</em>.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: name</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>src</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
</div>
</td>
<td>
</td>
<td>
<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>, <code>mounted</code> or <code>ephemeral</code>.</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>
/ <span style="color: red">required</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>absent</li>
<li>absent_from_fstab</li>
<li>mounted</li>
<li>present</li>
<li>unmounted</li>
<li>remounted</li>
<li>ephemeral</li>
</ul>
</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>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>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>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>
</tr>
</table>
<br/>
Notes
-----
.. note::
- As of Ansible 2.3, the *name* option has been changed to *path* as default, but *name* still works as well.
- Using ``remounted`` with *opts* set may create unexpected results based on the existing options already defined on mount, so care should be taken to ensure that conflicting options are not present before hand.
Examples
--------
.. code-block:: yaml
# Before 2.3, option 'name' was used instead of 'path'
- name: Mount DVD read-only
ansible.posix.mount:
path: /mnt/dvd
src: /dev/sr0
fstype: iso9660
opts: ro,noauto
state: present
- name: Mount up device by label
ansible.posix.mount:
path: /srv/disk
src: LABEL=SOME_LABEL
fstype: ext4
state: present
- name: Mount up device by UUID
ansible.posix.mount:
path: /home
src: UUID=b3e48f45-f933-4c8e-a700-22a159ec9077
fstype: xfs
opts: noatime
state: present
- name: Unmount a mounted volume
ansible.posix.mount:
path: /tmp/mnt-pnt
state: unmounted
- name: Remount a mounted volume
ansible.posix.mount:
path: /tmp/mnt-pnt
state: remounted
# The following will not save changes to fstab, and only be temporary until
# a reboot, or until calling "state: unmounted" followed by "state: mounted"
# on the same "path"
- name: Remount a mounted volume and append exec to the existing options
ansible.posix.mount:
path: /tmp
state: remounted
opts: exec
- name: Mount and bind a volume
ansible.posix.mount:
path: /system/new_volume/boot
src: /boot
opts: bind
state: mounted
fstype: none
- name: Mount an NFS volume
ansible.posix.mount:
src: 192.168.1.100:/nfs/ssd/shared_data
path: /mnt/shared_data
opts: rw,sync,hard
state: mounted
fstype: nfs
- name: Mount NFS volumes with noauto according to boot option
ansible.posix.mount:
src: 192.168.1.100:/nfs/ssd/shared_data
path: /mnt/shared_data
opts: rw,sync,hard
boot: false
state: mounted
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
Status
------
Authors
~~~~~~~
- Ansible Core Team
- Seth Vidal (@skvidal)

View File

@@ -1,245 +0,0 @@
.. _ansible.posix.patch_module:
*******************
ansible.posix.patch
*******************
**Apply patch files using the GNU patch tool**
Version added: 1.0.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Apply patch files using the GNU patch tool.
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>backup</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>Passes <code>--backup --version-control=numbered</code> to patch, producing numbered backup copies.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>basedir</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
</div>
</td>
<td>
</td>
<td>
<div>Path of a base directory in which the patch file will be applied.</div>
<div>May be omitted when <code>dest</code> option is specified, otherwise required.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>binary</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>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>If set to <code>false</code>, <code>patch</code> will replace CRLF in <code>src</code> files on POSIX.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>dest</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
</div>
</td>
<td>
</td>
<td>
<div>Path of the file on the remote machine to be patched.</div>
<div>The names of the files to be patched are usually taken from the patch file, but if there&#x27;s just one file to be patched it can specified with this option.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: originalfile</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>ignore_whitespace</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>Setting to <code>true</code> will ignore white space changes between patch and input.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>remote_src</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>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>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>src</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<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>
</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><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Whether the patch should be applied or reverted.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>strip</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">0</div>
</td>
<td>
<div>Number that indicates the smallest prefix containing leading slashes that will be stripped from each file name found in the patch file.</div>
<div>For more information see the strip parameter of the GNU patch tool.</div>
</td>
</tr>
</table>
<br/>
Notes
-----
.. note::
- This module requires GNU *patch* utility to be installed on the remote host.
Examples
--------
.. code-block:: yaml
- name: Apply patch to one file
ansible.posix.patch:
src: /tmp/index.html.patch
dest: /var/www/index.html
- name: Apply patch to multiple files under basedir
ansible.posix.patch:
src: /tmp/customize.patch
basedir: /var/www
strip: 1
- name: Revert patch to one file
ansible.posix.patch:
src: /tmp/index.html.patch
dest: /var/www/index.html
state: absent
Status
------
Authors
~~~~~~~
- Jakub Jirutka (@jirutka)
- Luis Alberto Perez Lazaro (@luisperlaz)

View File

@@ -1,103 +0,0 @@
.. _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

@@ -1,156 +0,0 @@
.. _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

@@ -1,175 +0,0 @@
.. _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

@@ -1,151 +0,0 @@
.. _ansible.posix.seboolean_module:
***********************
ansible.posix.seboolean
***********************
**Toggles SELinux booleans**
Version added: 1.0.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Toggles SELinux booleans.
Requirements
------------
The below requirements are needed on the host that executes this module.
- libselinux-python
- libsemanage-python
- python3-libsemanage
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>ignore_selinux_state</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>Useful for scenarios (chrooted environment) that you can&#x27;t get the real SELinux state.</div>
</td>
</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">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Name of the boolean to configure.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>persistent</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>Set to <code>true</code> if the boolean setting should survive a reboot.</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">boolean</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Desired boolean value</div>
</td>
</tr>
</table>
<br/>
Notes
-----
.. note::
- Not tested on any Debian based system.
Examples
--------
.. code-block:: yaml
- name: Set httpd_can_network_connect flag on and keep it persistent across reboots
ansible.posix.seboolean:
name: httpd_can_network_connect
state: true
persistent: true
Status
------
Authors
~~~~~~~
- Stephen Fromm (@sfromm)

View File

@@ -1,253 +0,0 @@
.. _ansible.posix.selinux_module:
*********************
ansible.posix.selinux
*********************
**Change policy and state of SELinux**
Version added: 1.0.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- Configures the SELinux mode and policy.
- A reboot may be required after usage.
- Ansible will not issue this reboot but will let you know when it is required.
Requirements
------------
The below requirements are needed on the host that executes this module.
- libselinux-python
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>configfile</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">"/etc/selinux/config"</div>
</td>
<td>
<div>The path to the SELinux configuration file, if non-standard.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: conf, file</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>policy</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>The name of the SELinux policy to use (e.g. <code>targeted</code>) will be required if <em>state</em> is not <code>disabled</code>.</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>
/ <span style="color: red">required</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>disabled</li>
<li>enforcing</li>
<li>permissive</li>
</ul>
</td>
<td>
<div>The SELinux mode.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>update_kernel_param</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 1.4.0</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>If set to <em>true</em>, will update also the kernel boot parameters when disabling/enabling SELinux.</div>
<div>The <code>grubby</code> tool must be present on the target system for this to work.</div>
</td>
</tr>
</table>
<br/>
Examples
--------
.. code-block:: yaml
- name: Enable SELinux
ansible.posix.selinux:
policy: targeted
state: enforcing
- name: Put SELinux in permissive mode, logging actions that would be blocked.
ansible.posix.selinux:
policy: targeted
state: permissive
- name: Disable SELinux
ansible.posix.selinux:
state: disabled
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>configfile</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>Path to SELinux configuration file.</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;">/etc/selinux/config</div>
</td>
</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>Messages that describe changes that were made.</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;">Config SELinux state changed from &#x27;disabled&#x27; to &#x27;permissive&#x27;</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>policy</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>Name of the SELinux policy.</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;">targeted</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>reboot_required</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>always</td>
<td>
<div>Whether or not an reboot is required for the changes to take effect.</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;">True</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>state</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>SELinux mode.</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;">enforcing</div>
</td>
</tr>
</table>
<br/><br/>
Status
------
Authors
~~~~~~~
- Derek Carter (@goozbach) <goozbach@friocorte.com>

View File

@@ -1,744 +0,0 @@
.. _ansible.posix.synchronize_module:
*************************
ansible.posix.synchronize
*************************
**A wrapper around rsync to make common tasks in your playbooks quick and easy**
Version added: 1.0.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- ``synchronize`` is a wrapper around rsync to make common tasks in your playbooks quick and easy.
- It is run and originates on the local host where Ansible is being run.
- Of course, you could just use the ``command`` action to call rsync yourself, but you also have to add a fair number of boilerplate options and host facts.
- This module is not intended to provide access to the full power of rsync, but does make the most common invocations easier to implement. You `still` may need to call rsync directly via ``command`` or ``shell`` depending on your use case.
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>archive</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>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Mirrors the rsync archive flag, enables recursive, links, perms, times, owner, group flags and -D.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>checksum</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>Skip based on checksum, rather than mod-time &amp; size; Note that that &quot;archive&quot; option is still enabled by default - the &quot;checksum&quot; option will not disable it.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>compress</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>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Compress file data during the transfer.</div>
<div>In most cases, leave this enabled unless it causes problems.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>copy_links</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>Copy symlinks as the item that they point to (the referent) is copied, rather than the symlink.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>delay_updates</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
<div style="font-style: italic; font-size: small; color: darkgreen">added in 1.3.0</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>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.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>delete</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>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=true</em>.</div>
<div>This option ignores excluded files and behaves like the rsync opt <code>--delete-after</code>.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>dest</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Path on the destination host that will be synchronized from the source.</div>
<div>The path can be absolute or relative.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>dest_port</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
</div>
</td>
<td>
</td>
<td>
<div>Port number for ssh on the destination host.</div>
<div>Prior to Ansible 2.0, the ansible_ssh_port inventory var took precedence over this value.</div>
<div>This parameter defaults to the value of <code>ansible_port</code>, the <code>remote_port</code> config setting or the value from ssh client configuration if none of the former have been set.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>dirs</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>Transfer directories without recursing.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>existing_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>Skip creating new files on receiver.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>group</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>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Preserve group.</div>
<div>This parameter defaults to the value of the archive option.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>link_dest</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">null</div>
</td>
<td>
<div>Add a destination to hard link against during the rsync.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>links</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>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Copy symlinks as symlinks.</div>
<div>This parameter defaults to the value of the archive option.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>mode</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>pull</li>
<li><div style="color: blue"><b>push</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>Specify the direction of the synchronization.</div>
<div>In push mode the localhost or delegate is the source.</div>
<div>In pull mode the remote host in context is the source.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>owner</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>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Preserve owner (super user only).</div>
<div>This parameter defaults to the value of the archive option.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>partial</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>Tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>perms</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>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Preserve permissions.</div>
<div>This parameter defaults to the value of the archive option.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>private_key</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
</div>
</td>
<td>
</td>
<td>
<div>Specify the private key to use for SSH-based rsync connections (e.g. <code>~/.ssh/id_rsa</code>).</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>recursive</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>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Recurse into directories.</div>
<div>This parameter defaults to the value of the archive option.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>rsync_opts</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">null</div>
</td>
<td>
<div>Specify additional rsync options by passing in an array.</div>
<div>Note that an empty string in <code>rsync_opts</code> will end up transfer the current working directory.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>rsync_path</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>Specify the rsync command to run on the remote host. See <code>--rsync-path</code> on the rsync man page.</div>
<div>To specify the rsync command to run on the local host, you need to set this your task var <code>ansible_rsync_path</code>.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>rsync_timeout</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">0</div>
</td>
<td>
<div>Specify a <code>--timeout</code> for the rsync command in seconds.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>set_remote_user</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>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<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>false</code>.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>src</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Path on the source host that will be synchronized to the destination.</div>
<div>The path can be absolute or relative.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>ssh_connection_multiplexing</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>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>true</code> to allow multiplexing and reduce SSH connection overhead.</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>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>times</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>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>Preserve modification times.</div>
<div>This parameter defaults to the value of the archive option.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>use_ssh_args</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>In Ansible 2.10 and lower, it uses the ssh_args specified in <code>ansible.cfg</code>.</div>
<div>In Ansible 2.11 and onwards, when set to <code>true</code>, it uses all SSH connection configurations like <code>ansible_ssh_args</code>, <code>ansible_ssh_common_args</code>, and <code>ansible_ssh_extra_args</code>.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>verify_host</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>Verify destination host key.</div>
</td>
</tr>
</table>
<br/>
Notes
-----
.. note::
- rsync must be installed on both the local and remote host.
- For the ``synchronize`` module, the "local host" is the host `the synchronize task originates on`, and the "destination host" is the host `synchronize is connecting to`.
- The "local host" can be changed to a different host by using `delegate_to`. This enables copying between two remote hosts or entirely on one remote machine.
- The user and permissions for the synchronize `src` are those of the user running the Ansible task on the local host (or the remote_user for a delegate_to host when delegate_to is used).
- The user and permissions for the synchronize `dest` are those of the `remote_user` on the destination host or the `become_user` if `become=yes` is active.
- In Ansible 2.0 a bug in the synchronize module made become occur on the "local host". This was fixed in Ansible 2.0.1.
- Currently, synchronize is limited to elevating permissions via passwordless sudo. This is because rsync itself is connecting to the remote machine and rsync doesn't give us a way to pass sudo credentials in.
- Currently there are only a few connection types which support synchronize (ssh, paramiko, local, and docker) because a sync strategy has been determined for those connection types. Note that the connection for these must not need a password as rsync itself is making the connection and rsync does not provide us a way to pass a password to the connection.
- Expect that dest=~/x will be ~<remote_user>/x even if using sudo.
- Inspect the verbose output to validate the destination user/host/path are what was expected.
- To exclude files and directories from being synchronized, you may add ``.rsync-filter`` files to the source directory.
- rsync daemon must be up and running with correct permission when using rsync protocol in source or destination path.
- The ``synchronize`` module enables `--delay-updates` by default to avoid leaving a destination in a broken in-between state if the underlying rsync process encounters an error. Those synchronizing large numbers of files that are willing to trade safety for performance should disable this option.
- 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.
See Also
--------
.. seealso::
:ref:`ansible.builtin.copy_module`
The official documentation on the **ansible.builtin.copy** module.
:ref:`community.windows.win_robocopy_module`
The official documentation on the **community.windows.win_robocopy** module.
Examples
--------
.. code-block:: yaml
- name: Synchronization of src on the control machine to dest on the remote hosts
ansible.posix.synchronize:
src: some/relative/path
dest: /some/absolute/path
- name: Synchronization using rsync protocol (push)
ansible.posix.synchronize:
src: some/relative/path/
dest: rsync://somehost.com/path/
- name: Synchronization using rsync protocol (pull)
ansible.posix.synchronize:
mode: pull
src: rsync://somehost.com/path/
dest: /some/absolute/path/
- name: Synchronization using rsync protocol on delegate host (push)
ansible.posix.synchronize:
src: /some/absolute/path/
dest: rsync://somehost.com/path/
delegate_to: delegate.host
- name: Synchronization using rsync protocol on delegate host (pull)
ansible.posix.synchronize:
mode: pull
src: rsync://somehost.com/path/
dest: /some/absolute/path/
delegate_to: delegate.host
- name: Synchronization without any --archive options enabled
ansible.posix.synchronize:
src: some/relative/path
dest: /some/absolute/path
archive: false
- name: Synchronization with --archive options enabled except for --recursive
ansible.posix.synchronize:
src: some/relative/path
dest: /some/absolute/path
recursive: false
- name: Synchronization with --archive options enabled except for --times, with --checksum option enabled
ansible.posix.synchronize:
src: some/relative/path
dest: /some/absolute/path
checksum: true
times: false
- name: Synchronization without --archive options enabled except use --links
ansible.posix.synchronize:
src: some/relative/path
dest: /some/absolute/path
archive: false
links: true
- name: Synchronization of two paths both on the control machine
ansible.posix.synchronize:
src: some/relative/path
dest: /some/absolute/path
delegate_to: localhost
- name: Synchronization of src on the inventory host to the dest on the localhost in pull mode
ansible.posix.synchronize:
mode: pull
src: some/relative/path
dest: /some/absolute/path
- name: Synchronization of src on delegate host to dest on the current inventory host.
ansible.posix.synchronize:
src: /first/absolute/path
dest: /second/absolute/path
delegate_to: delegate.host
- name: Synchronize two directories on one remote host.
ansible.posix.synchronize:
src: /first/absolute/path
dest: /second/absolute/path
delegate_to: "{{ inventory_hostname }}"
- name: Synchronize and delete files in dest on the remote host that are not found in src of localhost.
ansible.posix.synchronize:
src: some/relative/path
dest: /some/absolute/path
delete: true
recursive: true
# This specific command is granted su privileges on the destination
- name: Synchronize using an alternate rsync command
ansible.posix.synchronize:
src: some/relative/path
dest: /some/absolute/path
rsync_path: su -c rsync
# Example .rsync-filter file in the source directory
# - var # exclude any path whose last part is 'var'
# - /var # exclude any path starting with 'var' starting at the source directory
# + /var/conf # include /var/conf even though it was previously excluded
- name: Synchronize passing in extra rsync options
ansible.posix.synchronize:
src: /tmp/helloworld
dest: /var/www/helloworld
rsync_opts:
- "--no-motd"
- "--exclude=.git"
# Hardlink files if they didn't change
- name: Use hardlinks when synchronizing filesystems
ansible.posix.synchronize:
src: /tmp/path_a/foo.txt
dest: /tmp/path_b/foo.txt
link_dest: /tmp/path_a/
# Specify the rsync binary to use on remote host and on local host
- hosts: groupofhosts
vars:
ansible_rsync_path: /usr/gnu/bin/rsync
tasks:
- name: copy /tmp/localpath/ to remote location /tmp/remotepath
ansible.posix.synchronize:
src: /tmp/localpath/
dest: /tmp/remotepath
rsync_path: /usr/gnu/bin/rsync
Status
------
Authors
~~~~~~~
- Timothy Appnel (@tima)

View File

@@ -1,215 +0,0 @@
.. _ansible.posix.sysctl_module:
********************
ansible.posix.sysctl
********************
**Manage entries in sysctl.conf.**
Version added: 1.0.0
.. contents::
:local:
:depth: 1
Synopsis
--------
- This module manipulates sysctl entries and optionally performs a ``/sbin/sysctl -p`` after changing them.
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>ignoreerrors</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>Use this option to ignore errors about unknown keys.</div>
</td>
</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">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>The dot-separated path (also known as <em>key</em>) specifying the sysctl variable.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: key</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>reload</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>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<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>
</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><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
<li>absent</li>
</ul>
</td>
<td>
<div>Whether the entry should be present or absent in the sysctl file.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>sysctl_file</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">path</span>
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">"/etc/sysctl.conf"</div>
</td>
<td>
<div>Specifies the absolute path to <code>sysctl.conf</code>, if not <code>/etc/sysctl.conf</code>.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>sysctl_set</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>Verify token value with the sysctl command and set with -w if necessary.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>value</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>Desired value of the sysctl key.</div>
<div style="font-size: small; color: darkgreen"><br/>aliases: val</div>
</td>
</tr>
</table>
<br/>
Examples
--------
.. code-block:: yaml
# Set vm.swappiness to 5 in /etc/sysctl.conf
- ansible.posix.sysctl:
name: vm.swappiness
value: '5'
state: present
# Remove kernel.panic entry from /etc/sysctl.conf
- ansible.posix.sysctl:
name: kernel.panic
state: absent
sysctl_file: /etc/sysctl.conf
# Set kernel.panic to 3 in /tmp/test_sysctl.conf
- ansible.posix.sysctl:
name: kernel.panic
value: '3'
sysctl_file: /tmp/test_sysctl.conf
reload: false
# Set ip forwarding on in /proc and verify token value with the sysctl command
- ansible.posix.sysctl:
name: net.ipv4.ip_forward
value: '1'
sysctl_set: true
# Set ip forwarding on in /proc and in the sysctl file and reload if necessary
- ansible.posix.sysctl:
name: net.ipv4.ip_forward
value: '1'
sysctl_set: true
state: present
reload: true
Status
------
Authors
~~~~~~~
- David CHANIAL (@davixx)

View File

@@ -1,6 +1,7 @@
---
namespace: ansible namespace: ansible
name: posix name: posix
version: 1.5.2 version: 3.0.0
readme: README.md readme: README.md
authors: authors:
- Ansible (github.com/ansible) - Ansible (github.com/ansible)
@@ -9,6 +10,6 @@ license_file: COPYING
tags: [posix, networking, shell, unix] tags: [posix, networking, shell, unix]
dependencies: {} dependencies: {}
repository: https://github.com/ansible-collections/ansible.posix repository: https://github.com/ansible-collections/ansible.posix
documentation: https://github.com/ansible-collections/ansible.posix/tree/main/docs documentation: https://docs.ansible.com/ansible/latest/collections/ansible/posix/
homepage: https://github.com/ansible-collections/ansible.posix homepage: https://github.com/ansible-collections/ansible.posix
issues: https://github.com/ansible-collections/ansible.posix issues: https://github.com/ansible-collections/ansible.posix

View File

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

View File

@@ -77,7 +77,14 @@ class ActionModule(ActionBase):
if self._host_is_ipv6_address(host): if self._host_is_ipv6_address(host):
return '[%s%s]:%s' % (user_prefix, host, path) return '[%s%s]:%s' % (user_prefix, host, path)
return '%s%s:%s' % (user_prefix, host, path)
# preserve formatting of remote paths if host or user@host is explicitly defined in the path
if ':' not in path:
return '%s%s:%s' % (user_prefix, host, path)
elif '@' not in path:
return '%s%s' % (user_prefix, path)
else:
return path
def _process_origin(self, host, path, user): def _process_origin(self, host, path, user):
@@ -177,7 +184,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 +192,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:
@@ -284,9 +291,6 @@ class ActionModule(ActionBase):
# told (via delegate_to) that a different host is the source of the # told (via delegate_to) that a different host is the source of the
# rsync # rsync
if not use_delegate and remote_transport: if not use_delegate and remote_transport:
# Create a connection to localhost to run rsync on
new_stdin = self._connection._new_stdin
# Unlike port, there can be only one shell # Unlike port, there can be only one shell
localhost_shell = None localhost_shell = None
for host in C.LOCALHOST: for host in C.LOCALHOST:
@@ -315,7 +319,11 @@ class ActionModule(ActionBase):
localhost_executable = C.DEFAULT_EXECUTABLE localhost_executable = C.DEFAULT_EXECUTABLE
self._play_context.executable = localhost_executable self._play_context.executable = localhost_executable
new_connection = connection_loader.get('local', self._play_context, new_stdin) try:
new_connection = connection_loader.get('local', self._play_context)
except TypeError:
# Needed for ansible-core < 2.15
new_connection = connection_loader.get('local', self._play_context, self._connection._new_stdin)
self._connection = new_connection self._connection = new_connection
# Override _remote_is_local as an instance attribute specifically for the synchronize use case # Override _remote_is_local as an instance attribute specifically for the synchronize use case
# ensuring we set local tmpdir correctly # ensuring we set local tmpdir correctly

View File

@@ -132,6 +132,7 @@ DOCUMENTATION = '''
import csv import csv
import datetime import datetime
import json
import os import os
import time import time
import threading import threading
@@ -142,7 +143,7 @@ from functools import partial
from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils._text import to_bytes, to_text
from ansible.module_utils.six import with_metaclass from ansible.module_utils.six import with_metaclass
from ansible.parsing.ajson import AnsibleJSONEncoder, json from ansible.parsing.ajson import AnsibleJSONEncoder
from ansible.plugins.callback import CallbackBase from ansible.plugins.callback import CallbackBase

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"""

View File

@@ -26,6 +26,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 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: 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
@@ -63,12 +73,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()
} }
@@ -81,6 +98,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()
} }
@@ -156,7 +174,7 @@ class CallbackModule(CallbackBase):
def _write_event(self, event_name, output): def _write_event(self, event_name, output):
output['_event'] = event_name output['_event'] = event_name
output['_timestamp'] = current_time() output['_timestamp'] = current_time()
self._display.display(json.dumps(output, cls=AnsibleJSONEncoder, separators=',:', sort_keys=True)) 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): 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""" """This function is used as a partial to add failed/skipped info in a single method"""

View File

@@ -14,6 +14,19 @@ DOCUMENTATION = '''
- This callback module provides profiling for ansible roles. - This callback module provides profiling for ansible roles.
requirements: requirements:
- whitelisting in configuration - whitelisting in configuration
options:
summary_only:
description:
- Only show summary, not individual task profiles.
Especially usefull in combination with C(DISPLAY_SKIPPED_HOSTS=false) and/or C(ANSIBLE_DISPLAY_OK_HOSTS=false).
type: bool
default: False
env:
- name: PROFILE_ROLES_SUMMARY_ONLY
ini:
- section: callback_profile_roles
key: summary_only
version_added: 1.5.0
''' '''
import collections import collections
@@ -76,13 +89,26 @@ class CallbackModule(CallbackBase):
self.stats = collections.Counter() self.stats = collections.Counter()
self.totals = collections.Counter() self.totals = collections.Counter()
self.current = None self.current = None
self.summary_only = None
super(CallbackModule, self).__init__() super(CallbackModule, self).__init__()
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.summary_only = self.get_option('summary_only')
def _display_tasktime(self):
if not self.summary_only:
self._display.display(tasktime())
def _record_task(self, task): def _record_task(self, task):
""" """
Logs the start of each task Logs the start of each task
""" """
self._display.display(tasktime()) self._display_tasktime()
timestamp(self) timestamp(self)
if task._role: if task._role:
@@ -98,10 +124,10 @@ class CallbackModule(CallbackBase):
def v2_playbook_on_handler_task_start(self, task): def v2_playbook_on_handler_task_start(self, task):
self._record_task(task) self._record_task(task)
def playbook_on_setup(self): def v2_playbook_on_stats(self, stats):
self._display.display(tasktime()) # Align summary report header with other callback plugin summary
self._display.banner("ROLES RECAP")
def playbook_on_stats(self, stats):
self._display.display(tasktime()) self._display.display(tasktime())
self._display.display(filled("", fchar="=")) self._display.display(filled("", fchar="="))

View File

@@ -17,7 +17,7 @@ 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:
@@ -40,6 +40,29 @@ DOCUMENTATION = '''
ini: ini:
- section: callback_profile_tasks - section: callback_profile_tasks
key: sort_order key: sort_order
summary_only:
description:
- Only show summary, not individual task profiles.
Especially usefull in combination with C(DISPLAY_SKIPPED_HOSTS=false) and/or C(ANSIBLE_DISPLAY_OK_HOSTS=false).
type: bool
default: False
env:
- name: PROFILE_TASKS_SUMMARY_ONLY
ini:
- section: callback_profile_tasks
key: summary_only
version_added: 1.5.0
datetime_format:
description:
- Datetime format, as expected by the C(strftime) and C(strptime) methods.
An C(iso8601) alias will be translated to C('%Y-%m-%dT%H:%M:%S.%f') if that datetime standard wants to be used.
default: '%A %d %B %Y %H:%M:%S %z'
env:
- name: PROFILE_TASKS_DATETIME_FORMAT
ini:
- section: callback_profile_tasks
key: datetime_format
version_added: 3.0.0
''' '''
EXAMPLES = ''' EXAMPLES = '''
@@ -60,14 +83,15 @@ sample output: >
''' '''
import collections import collections
import time
from datetime import datetime
from ansible.module_utils.six.moves import reduce from ansible.module_utils.six.moves import reduce
from ansible.plugins.callback import CallbackBase from ansible.plugins.callback import CallbackBase
# define start time # define start time
t0 = tn = time.time() dt0 = dtn = datetime.now().astimezone()
def secondsToStr(t): def secondsToStr(t):
@@ -92,17 +116,18 @@ def filled(msg, fchar="*"):
def timestamp(self): def timestamp(self):
if self.current is not None: if self.current is not None:
elapsed = time.time() - self.stats[self.current]['started'] elapsed = (datetime.now().astimezone() - self.stats[self.current]['started']).total_seconds()
self.stats[self.current]['elapsed'] += elapsed self.stats[self.current]['elapsed'] += elapsed
def tasktime(): def tasktime(self):
global tn global dtn
time_current = time.strftime('%A %d %B %Y %H:%M:%S %z') cdtn = datetime.now().astimezone()
time_elapsed = secondsToStr(time.time() - tn) datetime_current = cdtn.strftime(self.datetime_format)
time_total_elapsed = secondsToStr(time.time() - t0) time_elapsed = secondsToStr((cdtn - dtn).total_seconds())
tn = time.time() time_total_elapsed = secondsToStr((cdtn - dt0).total_seconds())
return filled('%s (%s)%s%s' % (time_current, time_elapsed, ' ' * 7, time_total_elapsed)) dtn = cdtn
return filled('%s (%s)%s%s' % (datetime_current, time_elapsed, ' ' * 7, time_total_elapsed))
class CallbackModule(CallbackBase): class CallbackModule(CallbackBase):
@@ -120,7 +145,9 @@ class CallbackModule(CallbackBase):
self.current = None self.current = None
self.sort_order = None self.sort_order = None
self.summary_only = None
self.task_output_limit = None self.task_output_limit = None
self.datetime_format = None
super(CallbackModule, self).__init__() super(CallbackModule, self).__init__()
@@ -137,6 +164,8 @@ class CallbackModule(CallbackBase):
elif self.sort_order == 'none': elif self.sort_order == 'none':
self.sort_order = None self.sort_order = None
self.summary_only = self.get_option('summary_only')
self.task_output_limit = self.get_option('output_limit') self.task_output_limit = self.get_option('output_limit')
if self.task_output_limit is not None: if self.task_output_limit is not None:
if self.task_output_limit == 'all': if self.task_output_limit == 'all':
@@ -144,11 +173,20 @@ class CallbackModule(CallbackBase):
else: else:
self.task_output_limit = int(self.task_output_limit) self.task_output_limit = int(self.task_output_limit)
self.datetime_format = self.get_option('datetime_format')
if self.datetime_format is not None:
if self.datetime_format == 'iso8601':
self.datetime_format = '%Y-%m-%dT%H:%M:%S.%f'
def _display_tasktime(self):
if not self.summary_only:
self._display.display(tasktime(self))
def _record_task(self, task): def _record_task(self, task):
""" """
Logs the start of each task Logs the start of each task
""" """
self._display.display(tasktime()) self._display_tasktime()
timestamp(self) timestamp(self)
# Record the start time of the current task # Record the start time of the current task
@@ -157,10 +195,11 @@ class CallbackModule(CallbackBase):
# with the same UUID is executed when `serial` is specified in a playbook. # with the same UUID is executed when `serial` is specified in a playbook.
# elapsed: Elapsed time since the first serialized task was started # elapsed: Elapsed time since the first serialized task was started
self.current = task._uuid self.current = task._uuid
dtn = datetime.now().astimezone()
if self.current not in self.stats: if self.current not in self.stats:
self.stats[self.current] = {'started': time.time(), 'elapsed': 0.0, 'name': task.get_name()} self.stats[self.current] = {'started': dtn, 'elapsed': 0.0, 'name': task.get_name()}
else: else:
self.stats[self.current]['started'] = time.time() self.stats[self.current]['started'] = dtn
if self._display.verbosity >= 2: if self._display.verbosity >= 2:
self.stats[self.current]['path'] = task.get_path() self.stats[self.current]['path'] = task.get_path()
@@ -170,11 +209,11 @@ class CallbackModule(CallbackBase):
def v2_playbook_on_handler_task_start(self, task): def v2_playbook_on_handler_task_start(self, task):
self._record_task(task) self._record_task(task)
def playbook_on_setup(self): def v2_playbook_on_stats(self, stats):
self._display.display(tasktime()) # Align summary report header with other callback plugin summary
self._display.banner("TASKS RECAP")
def playbook_on_stats(self, stats): self._display.display(tasktime(self))
self._display.display(tasktime())
self._display.display(filled("", fchar="=")) self._display.display(filled("", fchar="="))
timestamp(self) timestamp(self)

View File

@@ -1,43 +0,0 @@
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
# (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: skippy
type: stdout
requirements:
- set as main display callback
short_description: Ansible screen output that ignores skipped status
deprecated:
why: The 'default' callback plugin now supports this functionality
removed_at_date: '2022-06-01'
alternative: "'default' callback plugin with 'display_skipped_hosts = no' option"
extends_documentation_fragment:
- default_callback
description:
- This callback does the same as the default except it does not output skipped host/task/item status
'''
from ansible.plugins.callback.default import CallbackModule as CallbackModule_default
class CallbackModule(CallbackModule_default):
'''
This is the default callback interface, which simply prints messages
to stdout when new callback events are received.
'''
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'stdout'
CALLBACK_NAME = 'ansible.posix.skippy'
def v2_runner_on_skipped(self, result):
pass
def v2_runner_item_on_skipped(self, result):
pass

View File

@@ -46,4 +46,6 @@ class CallbackModule(CallbackBase):
def v2_playbook_on_stats(self, stats): def v2_playbook_on_stats(self, stats):
end_time = datetime.utcnow() end_time = datetime.utcnow()
runtime = end_time - self.start_time runtime = end_time - self.start_time
self._display.display("Playbook run took %s days, %s hours, %s minutes, %s seconds" % (self.days_hours_minutes_seconds(runtime))) # Align summary report header with other callback plugin summary
self._display.banner("PLAYBOOK RECAP")
self._display.display("Playbook run took %s days, %s hours, %s minutes, %s seconds\n\r" % (self.days_hours_minutes_seconds(runtime)))

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,7 @@
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 from ansible.module_utils.basic import missing_required_lib
__metaclass__ = type __metaclass__ = type
@@ -314,6 +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=missing_required_lib('firewall') + '. Version 0.2.11 or newer required (0.3.9 or newer for offline operations)' msg=missing_required_lib('firewall') + '. Version 0.2.11 or newer required (0.3.9 or newer for offline operations)'
) )

View File

@@ -25,7 +25,7 @@ options:
state: state:
description: description:
- Define whether the ACL should be present or not. - Define whether the ACL should be present or not.
- The C(query) state gets the current ACL without changing it, for use in C(register) operations. - The V(query) state gets the current ACL without changing it, for use in C(register) operations.
choices: [ absent, present, query ] choices: [ absent, present, query ]
default: query default: query
type: str type: str
@@ -36,8 +36,8 @@ options:
default: true default: true
default: default:
description: description:
- If the target is a directory, setting this to C(true) will make it the default ACL for entities created inside the directory. - If O(path) is a directory, setting this to V(true) will make it the default ACL for entities created inside the directory.
- Setting C(default) to C(true) causes an error if the path is a file. - Setting O(default=true) causes an error if O(path) is a file.
type: bool type: bool
default: false default: false
entity: entity:
@@ -53,7 +53,7 @@ options:
permissions: permissions:
description: description:
- The permissions to apply/remove can be any combination of C(r), C(w), C(x) - The permissions to apply/remove can be any combination of C(r), C(w), C(x)
- (read, write and execute respectively), and C(X) (execute permission if the file is a directory or already has execute permission for some user) (read, write and execute respectively), and C(X) (execute permission if the file is a directory or already has execute permission for some user)
type: str type: str
entry: entry:
description: description:
@@ -67,21 +67,25 @@ options:
recursive: recursive:
description: description:
- Recursively sets the specified ACL. - Recursively sets the specified ACL.
- Incompatible with C(state=query). - Incompatible with O(state=query).
- Alias C(recurse) added in version 1.3.0. - Alias O(recurse) added in version 1.3.0.
type: bool type: bool
default: false 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.
- This feature uses C(nfs4_setfacl) and C(nfs4_getfacl). The behavior depends on those implementation.
And currently it only supports C(A) in ACE, so C(D) must be replaced with the appropriate C(A).
- Permission is set as optimised ACLs by the system. You can check the actual ACLs that has been set using the return value.
- More info C(man nfs4_setfacl)
type: bool type: bool
default: false 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.
- See C(setfacl) documentation for more info. - See C(setfacl) documentation for more info.
- Incompatible with C(state=query). - Incompatible with O(state=query).
choices: [ default, mask, no_mask ] choices: [ default, mask, no_mask ]
default: default default: default
type: str type: str
@@ -89,9 +93,9 @@ author:
- Brian Coca (@bcoca) - Brian Coca (@bcoca)
- Jérémie Astori (@astorije) - Jérémie Astori (@astorije)
notes: notes:
- The C(acl) module requires that ACLs are enabled on the target filesystem and that the C(setfacl) and C(getfacl) binaries are installed. - The M(ansible.posix.acl) module requires that ACLs are enabled on the target filesystem and that the C(setfacl) and C(getfacl) binaries are installed.
- As of Ansible 2.0, this module only supports Linux distributions. - As of Ansible 2.0, this module only supports Linux distributions.
- As of Ansible 2.3, the I(name) option has been changed to I(path) as default, but I(name) still works as well. - As of Ansible 2.3, the O(name) option has been changed to O(path) as default, but O(name) still works as well.
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@@ -179,7 +183,7 @@ def split_entry(entry):
def build_entry(etype, entity, permissions=None, use_nfsv4_acls=False): def build_entry(etype, entity, permissions=None, use_nfsv4_acls=False):
'''Builds and returns an entry string. Does not include the permissions bit if they are not provided.''' '''Builds and returns an entry string. Does not include the permissions bit if they are not provided.'''
if use_nfsv4_acls: if use_nfsv4_acls:
return ':'.join([etype, entity, permissions, 'allow']) return ':'.join(['A', 'g' if etype == 'group' else '', entity, permissions + 'tcy'])
if permissions: if permissions:
return etype + ':' + entity + ':' + permissions return etype + ':' + entity + ':' + permissions
@@ -187,22 +191,27 @@ def build_entry(etype, entity, permissions=None, use_nfsv4_acls=False):
return etype + ':' + entity return etype + ':' + entity
def build_command(module, mode, path, follow, default, recursive, recalculate_mask, entry=''): def build_command(module, mode, path, follow, default, recursive, recalculate_mask, use_nfsv4_acls, entry=''):
'''Builds and returns a getfacl/setfacl command.''' '''Builds and returns a getfacl/setfacl command.'''
if mode == 'set': if mode == 'set':
cmd = [module.get_bin_path('setfacl', True)] cmd = [module.get_bin_path('nfs4_setfacl' if use_nfsv4_acls else 'setfacl', True)]
cmd.extend(['-m', entry]) cmd.extend(['-a' if use_nfsv4_acls else '-m', entry])
elif mode == 'rm': elif mode == 'rm':
cmd = [module.get_bin_path('setfacl', True)] cmd = [module.get_bin_path('nfs4_setfacl' if use_nfsv4_acls else 'setfacl', True)]
cmd.extend(['-x', entry]) cmd.extend(['-x', entry])
else: # mode == 'get' else: # mode == 'get'
cmd = [module.get_bin_path('getfacl', True)] cmd = [module.get_bin_path('getfacl', True)]
# prevents absolute path warnings and removes headers # prevents absolute path warnings and removes headers
if platform.system().lower() == 'linux': if platform.system().lower() == 'linux':
if use_nfsv4_acls:
# use nfs4_getfacl instead of getfacl if use_nfsv4_acls is True
cmd = [module.get_bin_path('nfs4_getfacl', True)]
else:
cmd = [module.get_bin_path('getfacl', True)]
cmd.append('--absolute-names')
cmd.append('--omit-header') cmd.append('--omit-header')
cmd.append('--absolute-names')
if recursive: if recursive and not use_nfsv4_acls:
cmd.append('--recursive') cmd.append('--recursive')
if recalculate_mask == 'mask' and mode in ['set', 'rm']: if recalculate_mask == 'mask' and mode in ['set', 'rm']:
@@ -210,7 +219,7 @@ def build_command(module, mode, path, follow, default, recursive, recalculate_ma
elif recalculate_mask == 'no_mask' and mode in ['set', 'rm']: elif recalculate_mask == 'no_mask' and mode in ['set', 'rm']:
cmd.append('--no-mask') cmd.append('--no-mask')
if not follow: if not follow and not use_nfsv4_acls:
if platform.system().lower() == 'linux': if platform.system().lower() == 'linux':
cmd.append('--physical') cmd.append('--physical')
elif platform.system().lower() == 'freebsd': elif platform.system().lower() == 'freebsd':
@@ -223,24 +232,34 @@ def build_command(module, mode, path, follow, default, recursive, recalculate_ma
return cmd return cmd
def acl_changed(module, cmd): def acl_changed(module, cmd, entry, use_nfsv4_acls=False):
'''Returns true if the provided command affects the existing ACLs, false otherwise.''' '''Returns true if the provided command affects the existing ACLs, false otherwise.'''
# FreeBSD do not have a --test flag, so by default, it is safer to always say "true" # To check the ACL changes, use the output of setfacl or nfs4_setfacl with '--test'.
# FreeBSD do not have a --test flag, so by default, it is safer to always say "true".
if platform.system().lower() == 'freebsd': if platform.system().lower() == 'freebsd':
return True return True
cmd = cmd[:] # lists are mutables so cmd would be overwritten without this cmd = cmd[:] # lists are mutables so cmd would be overwritten without this
cmd.insert(1, '--test') cmd.insert(1, '--test')
lines = run_acl(module, cmd) lines = run_acl(module, cmd)
counter = 0
for line in lines: for line in lines:
if not line.endswith('*,*'): if line.endswith('*,*') and not use_nfsv4_acls:
return True return False
return False # if use_nfsv4_acls and entry is listed
if use_nfsv4_acls and entry == line:
counter += 1
# The current 'nfs4_setfacl --test' lists a new entry,
# which will be added at the top of list, followed by the existing entries.
# So if the entry has already been registered, the entry should be find twice.
if counter == 2:
return False
return True
def run_acl(module, cmd, check_rc=True): def run_acl(module, cmd, check_rc=True):
'''Runs the provided command and returns the output as a list of lines.'''
try: try:
(rc, out, err) = module.run_command(cmd, check_rc=check_rc) (rc, out, err) = module.run_command(cmd, check_rc=check_rc)
except Exception as e: except Exception as e:
@@ -313,7 +332,7 @@ def main():
module.fail_json(msg="'recalculate_mask' MUST NOT be set to 'mask' or 'no_mask' when 'state=query'.") module.fail_json(msg="'recalculate_mask' MUST NOT be set to 'mask' or 'no_mask' when 'state=query'.")
if not entry: if not entry:
if state == 'absent' and permissions: if state == 'absent' and permissions and not use_nfsv4_acls:
module.fail_json(msg="'permissions' MUST NOT be set when 'state=absent'.") module.fail_json(msg="'permissions' MUST NOT be set when 'state=absent'.")
if state == 'absent' and not entity: if state == 'absent' and not entity:
@@ -350,21 +369,24 @@ def main():
entry = build_entry(etype, entity, permissions, use_nfsv4_acls) entry = build_entry(etype, entity, permissions, use_nfsv4_acls)
command = build_command( command = build_command(
module, 'set', path, follow, module, 'set', path, follow,
default, recursive, recalculate_mask, entry default, recursive, recalculate_mask, use_nfsv4_acls, entry
) )
changed = acl_changed(module, command) changed = acl_changed(module, command, entry, use_nfsv4_acls)
if changed and not module.check_mode: if changed and not module.check_mode:
run_acl(module, command) run_acl(module, command)
msg = "%s is present" % entry msg = "%s is present" % entry
elif state == 'absent': elif state == 'absent':
entry = build_entry(etype, entity, use_nfsv4_acls) if use_nfsv4_acls:
entry = build_entry(etype, entity, permissions, use_nfsv4_acls)
else:
entry = build_entry(etype, entity, use_nfsv4_acls)
command = build_command( command = build_command(
module, 'rm', path, follow, module, 'rm', path, follow,
default, recursive, recalculate_mask, entry default, recursive, recalculate_mask, use_nfsv4_acls, entry
) )
changed = acl_changed(module, command) changed = acl_changed(module, command, entry, use_nfsv4_acls)
if changed and not module.check_mode: if changed and not module.check_mode:
run_acl(module, command, False) run_acl(module, command, False)
@@ -375,7 +397,10 @@ def main():
acl = run_acl( acl = run_acl(
module, module,
build_command(module, 'get', path, follow, default, recursive, recalculate_mask) build_command(
module, 'get', path, follow, default, recursive,
recalculate_mask, use_nfsv4_acls
)
) )
module.exit_json(changed=changed, msg=msg, acl=acl) module.exit_json(changed=changed, msg=msg, acl=acl)

View File

@@ -36,7 +36,7 @@ options:
choices: [ minutes, hours, days, weeks ] choices: [ minutes, hours, days, weeks ]
state: state:
description: description:
- The state dictates if the command or script file should be evaluated as present(added) or absent(deleted). - The state dictates if the command or script file should be evaluated as V(present) (added) or V(absent) (deleted).
type: str type: str
choices: [ absent, present ] choices: [ absent, present ]
default: present default: present

View File

@@ -24,20 +24,23 @@ options:
key: key:
description: description:
- The SSH public key(s), as a string or (since Ansible 1.9) url (https://github.com/username.keys). - The SSH public key(s), as a string or (since Ansible 1.9) url (https://github.com/username.keys).
- You can also use V(file://) prefix to search remote for a file with SSH key(s).
type: str type: str
required: true required: true
path: path:
description: description:
- Alternate path to the authorized_keys file. - Alternative path to the authorized_keys file.
- When unset, this value defaults to I(~/.ssh/authorized_keys). - The default value is the V(.ssh/authorized_keys) of the home of the user specified in the O(user) parameter.
- Most of the time, it is not necessary to set this key.
- Use the path to your target authorized_keys if you need to explicitly point on it.
type: path type: path
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(true), the module will create the directory, as well as set the owner and permissions - If set to V(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=false) if you are using an alternate directory for authorized_keys, - Be sure to set O(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 O(path), since you could lock yourself out of SSH access.
- See the example below. - See the example below.
type: bool type: bool
default: true default: true
@@ -54,17 +57,17 @@ options:
exclusive: exclusive:
description: description:
- Whether to remove all other non-specified keys from the authorized_keys file. - Whether to remove all other non-specified keys from the authorized_keys file.
- Multiple keys can be specified in a single C(key) string value by separating them by newlines. - Multiple keys can be specified in a single O(key) string value by separating them by newlines.
- 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 O(key) in a single batch as mentioned above.
type: bool type: bool
default: false 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(false), the SSL certificates will not be validated. - If set to V(false), the SSL certificates will not be validated.
- This should only set to C(false) used on personally controlled sites using self-signed certificates as it avoids verifying the source site. - This should only set to V(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(true). - Prior to 2.1 the code worked as if this was set to V(true).
type: bool type: bool
default: true default: true
comment: comment:
@@ -94,6 +97,12 @@ EXAMPLES = r'''
state: present state: present
key: https://github.com/charlie.keys key: https://github.com/charlie.keys
- name: Set authorized keys taken from path on controller node
ansible.posix.authorized_key:
user: charlie
state: present
key: file:///home/charlie/.ssh/id_rsa.pub
- name: Set authorized keys taken from url using lookup - name: Set authorized keys taken from url using lookup
ansible.posix.authorized_key: ansible.posix.authorized_key:
user: charlie user: charlie
@@ -216,11 +225,14 @@ import os.path
import tempfile import tempfile
import re import re
import shlex import shlex
import errno
import traceback
from operator import itemgetter from operator import itemgetter
from ansible.module_utils._text import to_native from ansible.module_utils._text import to_native
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url from ansible.module_utils.urls import fetch_url
from ansible.module_utils.six.moves.urllib.parse import urlparse
class keydict(dict): class keydict(dict):
@@ -465,16 +477,18 @@ def parsekey(module, raw_key, rank=None):
return (key, key_type, options, comment, rank) return (key, key_type, options, comment, rank)
def readfile(filename): def readfile(module, filename):
if not os.path.isfile(filename):
return ''
f = open(filename)
try: try:
return f.read() with open(filename, 'r') as f:
finally: return f.read()
f.close() except IOError as e:
if e.errno == errno.EACCES:
module.fail_json(msg="Permission denied on file or path for authorized keys file: %s" % filename,
exception=traceback.format_exc())
elif e.errno == errno.ENOENT:
return ''
else:
raise
def parsekeys(module, lines): def parsekeys(module, lines):
@@ -554,7 +568,7 @@ def enforce_state(module, params):
follow = params.get('follow', False) follow = params.get('follow', False)
error_msg = "Error getting key from: %s" error_msg = "Error getting key from: %s"
# if the key is a url, request it and use it as key source # if the key is a url or file, request it and use it as key source
if key.startswith("http"): if key.startswith("http"):
try: try:
resp, info = fetch_url(module, key) resp, info = fetch_url(module, key)
@@ -568,13 +582,26 @@ def enforce_state(module, params):
# resp.read gives bytes on python3, convert to native string type # resp.read gives bytes on python3, convert to native string type
key = to_native(key, errors='surrogate_or_strict') key = to_native(key, errors='surrogate_or_strict')
if key.startswith("file"):
# if the key is an absolute path, check for existense and use it as a key source
key_path = urlparse(key).path
if not os.path.exists(key_path):
module.fail_json(msg="Path to a key file not found: %s" % key_path)
if not os.path.isfile(key_path):
module.fail_json(msg="Path to a key is a directory and must be a file: %s" % key_path)
try:
with open(key_path, 'r') as source_fh:
key = source_fh.read()
except OSError as e:
module.fail_json(msg="Failed to read key file %s : %s" % (key_path, to_native(e)))
# extract individual keys into an array, skipping blank lines and comments # extract individual keys into an array, skipping blank lines and comments
new_keys = [s for s in key.splitlines() if s and not s.startswith('#')] new_keys = [s for s in key.splitlines() if s and not s.startswith('#')]
# check current state -- just get the filename, don't create file # check current state -- just get the filename, don't create file
do_write = False do_write = False
params["keyfile"] = keyfile(module, user, do_write, path, manage_dir) params["keyfile"] = keyfile(module, user, do_write, path, manage_dir)
existing_content = readfile(params["keyfile"]) existing_content = readfile(module, params["keyfile"])
existing_keys = parsekeys(module, existing_content) existing_keys = parsekeys(module, existing_content)
# Add a place holder for keys that should exist in the state=present and # Add a place holder for keys that should exist in the state=present and

View File

@@ -17,7 +17,7 @@ options:
service: service:
description: description:
- 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 C(firewall-cmd --get-services).
type: str type: str
protocol: protocol:
description: description:
@@ -38,22 +38,22 @@ options:
type: str type: str
required: true required: true
description: description:
- Source port to forward from - Source port to forward from.
proto: proto:
type: str type: str
required: true required: true
description: description:
- protocol to forward - protocol to forward.
choices: [udp, tcp] choices: [udp, tcp]
toport: toport:
type: str type: str
required: true required: true
description: description:
- destination port - destination port.
toaddr: toaddr:
type: str type: str
description: description:
- Optional address to forward to - Optional address to forward to.
rich_rule: rich_rule:
description: description:
- Rich rule to add/remove to/from firewalld. - Rich rule to add/remove to/from firewalld.
@@ -74,30 +74,33 @@ options:
icmp_block_inversion: icmp_block_inversion:
description: description:
- Enable/Disable inversion of ICMP blocks for a zone in firewalld. - Enable/Disable inversion of ICMP blocks for a zone in firewalld.
type: str - Note that the option type is changed to bool in ansible.posix version 2.0.0 and later.
type: bool
zone: zone:
description: description:
- The firewalld zone to add/remove to/from. - The firewalld zone to add/remove to/from.
- Note that the default zone can be configured per system but C(public) is default from upstream. - Note that the default zone can be configured per system but V(public) is default from upstream.
- Available choices can be extended based on per-system configs, listed here are "out of the box" defaults. - Available choices can be extended based on per-system configs, listed here are "out of the box" defaults.
- Possible values include C(block), C(dmz), C(drop), C(external), C(home), C(internal), C(public), C(trusted), C(work). - Possible values include V(block), V(dmz), V(drop), V(external), V(home), V(internal), V(public), V(trusted), V(work).
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(false), immediate is assumed C(true). - Note that if this is V(false), O(immediate=true) by default.
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 V(true) if O(permanent=false).
type: bool type: bool
default: false default: false
state: state:
description: description:
- Enable or disable a setting. - Enable or disable a setting.
- 'For ports: Should this port accept (enabled) or reject (disabled) connections.' - 'For ports: Should this port accept (V(enabled)) or reject (V(disabled)) connections.'
- The states C(present) and C(absent) can only be used in zone level operations (i.e. when no other parameters but zone and state are set). - The states V(present) and V(absent) can only be used in zone level operations (i.e. when no other parameters but zone and state are set).
type: str type: str
required: true required: true
choices: [ absent, disabled, enabled, present ] choices: [ absent, disabled, enabled, present ]
@@ -106,18 +109,26 @@ options:
- The amount of time in seconds the rule should be in effect for when non-permanent. - The amount of time in seconds the rule should be in effect for when non-permanent.
type: int type: int
default: 0 default: 0
forward:
description:
- The forward setting you would like to enable/disable to/from zones within firewalld.
- This option only is supported by firewalld v0.9.0 or later.
- Note that the option type is changed to bool in ansible.posix version 2.0.0 and later.
type: bool
masquerade: masquerade:
description: description:
- The masquerade setting you would like to enable/disable to/from zones within firewalld. - The masquerade setting you would like to enable/disable to/from zones within firewalld.
type: str - Note that the option type is changed to bool in ansible.posix version 2.0.0 and later.
type: bool
offline: offline:
description: description:
- Whether to run this module even when firewalld is offline. - Ignores O(immediate) if O(permanent=true) and firewalld is not running.
type: bool type: bool
default: false
target: target:
description: description:
- firewalld Zone target - firewalld Zone target.
- If state is set to C(absent), this will reset the target to default - If O(state=absent), this will reset the target to default.
choices: [ default, ACCEPT, DROP, "%%REJECT%%" ] choices: [ default, ACCEPT, DROP, "%%REJECT%%" ]
type: str type: str
version_added: 1.2.0 version_added: 1.2.0
@@ -135,82 +146,107 @@ notes:
- This module needs C(python-firewall) or C(python3-firewall) on managed nodes. - This module needs C(python-firewall) or C(python3-firewall) on managed nodes.
It is usually provided as a subset with C(firewalld) from the OS distributor for the OS default Python interpreter. It is usually provided as a subset with C(firewalld) from the OS distributor for the OS default Python interpreter.
requirements: requirements:
- firewalld >= 0.2.11 - firewalld >= 0.9.0
- python-firewall >= 0.2.11 - python-firewall >= 0.9.0
author: author:
- Adam Miller (@maxamillion) - Adam Miller (@maxamillion)
''' '''
EXAMPLES = r''' EXAMPLES = r'''
- name: permit traffic in default zone for https service - 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
ansible.posix.firewalld: ansible.posix.firewalld:
service: https service: https
permanent: true permanent: true
state: enabled state: enabled
- name: permit ospf traffic - name: Permit ospf traffic
ansible.posix.firewalld: ansible.posix.firewalld:
protocol: ospf protocol: ospf
permanent: true 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: true permanent: true
state: disabled state: disabled
- ansible.posix.firewalld: - name: Permit traffic in default zone on port 161-162/ucp
ansible.posix.firewalld:
port: 161-162/udp port: 161-162/udp
permanent: true permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - name: Permit traffic in dmz zone on http service
ansible.posix.firewalld:
zone: dmz zone: dmz
service: http service: http
permanent: true permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - name: Enable FTP service with rate limiting using firewalld rich rule
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: true permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - name: Allow traffic from 192.0.2.0/24 in internal zone
ansible.posix.firewalld:
source: 192.0.2.0/24 source: 192.0.2.0/24
zone: internal zone: internal
state: enabled state: enabled
- ansible.posix.firewalld: - name: Assign eth2 interface to trusted zone
ansible.posix.firewalld:
zone: trusted zone: trusted
interface: eth2 interface: eth2
permanent: true permanent: true
state: enabled state: enabled
- ansible.posix.firewalld: - name: Enable forwarding in internal zone
ansible.posix.firewalld:
forward: true
state: enabled
permanent: true
zone: internal
- name: Enable masquerade in dmz zone
ansible.posix.firewalld:
masquerade: true masquerade: true
state: enabled state: enabled
permanent: true permanent: true
zone: dmz zone: dmz
- ansible.posix.firewalld: - name: Create custom zone if not already present
ansible.posix.firewalld:
zone: custom zone: custom
state: present state: present
permanent: true permanent: true
- ansible.posix.firewalld: - name: Enable ICMP block inversion in drop zone
ansible.posix.firewalld:
zone: drop zone: drop
state: enabled state: enabled
permanent: true permanent: true
icmp_block_inversion: true icmp_block_inversion: true
- ansible.posix.firewalld: - name: Block ICMP echo requests in drop zone
ansible.posix.firewalld:
zone: drop zone: drop
state: enabled state: enabled
permanent: true permanent: true
icmp_block: echo-request icmp_block: echo-request
- ansible.posix.firewalld: - name: Set internal zone target to ACCEPT
ansible.posix.firewalld:
zone: internal zone: internal
state: present state: present
permanent: true permanent: true
@@ -226,7 +262,6 @@ EXAMPLES = r'''
''' '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.parsing.convert_bool import boolean
from ansible_collections.ansible.posix.plugins.module_utils.firewalld import FirewallTransaction, fw_offline from ansible_collections.ansible.posix.plugins.module_utils.firewalld import FirewallTransaction, fw_offline
try: try:
@@ -394,6 +429,49 @@ class ProtocolTransaction(FirewallTransaction):
self.update_fw_settings(fw_zone, fw_settings) self.update_fw_settings(fw_zone, fw_settings)
class ForwardTransaction(FirewallTransaction):
"""
ForwardTransaction
"""
def __init__(self, module, action_args=None, zone=None, desired_state=None, permanent=False, immediate=False):
super(ForwardTransaction, self).__init__(
module, action_args=action_args, desired_state=desired_state, zone=zone, permanent=permanent, immediate=immediate
)
self.enabled_msg = "Added forward to zone %s" % self.zone
self.disabled_msg = "Removed forward from zone %s" % self.zone
def get_enabled_immediate(self):
if self.fw.queryForward(self.zone) is True:
return True
else:
return False
def get_enabled_permanent(self):
fw_zone, fw_settings = self.get_fw_zone_settings()
if fw_settings.queryForward() is True:
return True
else:
return False
def set_enabled_immediate(self):
self.fw.addForward(self.zone)
def set_enabled_permanent(self):
fw_zone, fw_settings = self.get_fw_zone_settings()
fw_settings.setForward(True)
self.update_fw_settings(fw_zone, fw_settings)
def set_disabled_immediate(self):
self.fw.removeForward(self.zone)
def set_disabled_permanent(self):
fw_zone, fw_settings = self.get_fw_zone_settings()
fw_settings.setForward(False)
self.update_fw_settings(fw_zone, fw_settings)
class MasqueradeTransaction(FirewallTransaction): class MasqueradeTransaction(FirewallTransaction):
""" """
MasqueradeTransaction MasqueradeTransaction
@@ -520,6 +598,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
@@ -529,18 +608,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:
@@ -797,7 +875,7 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
icmp_block=dict(type='str'), icmp_block=dict(type='str'),
icmp_block_inversion=dict(type='str'), icmp_block_inversion=dict(type='bool'),
service=dict(type='str'), service=dict(type='str'),
protocol=dict(type='str'), protocol=dict(type='str'),
port=dict(type='str'), port=dict(type='str'),
@@ -806,12 +884,13 @@ def main():
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'), forward=dict(type='bool'),
offline=dict(type='bool'), masquerade=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,
@@ -822,7 +901,7 @@ def main():
), ),
mutually_exclusive=[ mutually_exclusive=[
['icmp_block', 'icmp_block_inversion', 'service', 'protocol', 'port', 'port_forward', 'rich_rule', ['icmp_block', 'icmp_block_inversion', 'service', 'protocol', 'port', 'port_forward', 'rich_rule',
'interface', 'masquerade', 'source', 'target'] 'interface', 'forward', 'masquerade', 'source', 'target']
], ],
) )
@@ -831,20 +910,31 @@ def main():
immediate = module.params['immediate'] immediate = module.params['immediate']
timeout = module.params['timeout'] timeout = module.params['timeout']
interface = module.params['interface'] interface = module.params['interface']
forward = module.params['forward']
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']
@@ -856,15 +946,16 @@ def main():
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
@@ -883,7 +974,7 @@ def main():
modification = False modification = False
if any([icmp_block, icmp_block_inversion, service, protocol, port, port_forward, rich_rule, if any([icmp_block, icmp_block_inversion, service, protocol, port, port_forward, rich_rule,
interface, masquerade, source, target]): interface, forward, 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:
module.fail_json( module.fail_json(
@@ -907,12 +998,12 @@ 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:
expected_state = 'enabled' if (desired_state == 'enabled') == icmp_block_inversion 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,
) )
@@ -922,14 +1013,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(
@@ -980,7 +1063,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,
@@ -992,7 +1075,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
) )
) )
@@ -1049,13 +1132,13 @@ def main():
changed, transaction_msgs = transaction.run() changed, transaction_msgs = transaction.run()
msgs = msgs + transaction_msgs msgs = msgs + transaction_msgs
if masquerade is not None: if forward is not None:
expected_state = 'enabled' if (desired_state == 'enabled') == forward else 'disabled'
transaction = MasqueradeTransaction( transaction = ForwardTransaction(
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,
) )
@@ -1063,13 +1146,19 @@ 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. if masquerade is not None:
try: expected_state = 'enabled' if (desired_state == 'enabled') == masquerade else 'disabled'
boolean(masquerade, True) transaction = MasqueradeTransaction(
except TypeError: module,
module.warn('The value of the masquerade option is "%s". ' action_args=(),
'The type of the option will be changed from string to boolean in a future release. ' zone=zone,
'To avoid unexpected behavior, please change the value to boolean.' % masquerade) desired_state=expected_state,
permanent=permanent,
immediate=immediate,
)
changed, transaction_msgs = transaction.run()
msgs = msgs + transaction_msgs
if target is not None: if target is not None:

View File

@@ -21,7 +21,7 @@ options:
zones: zones:
description: description:
- Gather information about specific zones. - Gather information about specific zones.
- If only works if C(active_zones) is set to C(false). - If only works if O(active_zones=false).
required: false required: false
type: list type: list
elements: str elements: str
@@ -211,6 +211,7 @@ 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._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
@@ -318,10 +319,15 @@ def main():
active_zones=module.params['active_zones'], active_zones=module.params['active_zones'],
collected_zones=list(), collected_zones=list(),
undefined_zones=list(), undefined_zones=list(),
warnings=list(),
) )
# 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:
@@ -349,8 +355,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

@@ -24,70 +24,80 @@ options:
path: path:
description: description:
- Path to the mount point (e.g. C(/mnt/files)). - Path to the mount point (e.g. C(/mnt/files)).
- Before Ansible 2.3 this option was only usable as I(dest), I(destfile) and I(name). - Before Ansible 2.3 this option was only usable as O(ignore:dest), O(ignore:destfile), and O(name).
type: path type: path
required: true required: true
aliases: [ name ] aliases: [ name ]
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), C(mounted) or C(ephemeral). - Required when O(state) set to V(present), V(mounted), or V(ephemeral).
- Ignored when O(state) set to V(absent) or V(unmounted).
type: path type: path
fstype: fstype:
description: description:
- Filesystem type. - Filesystem type.
- Required when I(state) is C(present), C(mounted) or C(ephemeral). - Required when O(state) is V(present), V(mounted), or V(ephemeral).
type: str type: str
opts: opts:
description: description:
- Mount options (see fstab(5), or vfstab(4) on Solaris). - Mount options (see fstab(5), or vfstab(4) on Solaris).
type: str type: str
opts_no_log:
description:
- Do not log opts.
type: bool
default: false
dump: dump:
description: description:
- Dump (see fstab(5)). - Dump (see fstab(5)).
- Note that if set to C(null) and I(state) set to C(present), - Note that if set to C(null) and O(state=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 or when used with C(ephemeral). - Has no effect on Solaris systems or when used with O(state=ephemeral).
type: str type: str
default: '0' default: '0'
passno: passno:
description: description:
- Passno (see fstab(5)). - Passno (see fstab(5)).
- Note that if set to C(null) and I(state) set to C(present), - Note that if set to C(null) and O(state=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. Has no effect when used with C(ephemeral). - Deprecated on Solaris systems. Has no effect when used with O(state=ephemeral).
type: str type: str
default: '0' default: '0'
state: state:
description: description:
- If C(mounted), the device will be actively mounted and appropriately - If V(mounted), the device will be actively mounted and appropriately
configured in I(fstab). If the mount point is not present, the mount configured in I(fstab). If the mount point is not present, the mount
point will be created. point will be created.
- If C(unmounted), the device will be unmounted without changing I(fstab). - If V(unmounted), the device will be unmounted without changing I(fstab).
- C(present) only specifies that the device is to be configured in - V(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 - V(ephemeral) only specifies that the device is to be mounted, without changing
I(fstab). If it is already mounted, a remount will be triggered. I(fstab). If it is already mounted, a remount will be triggered.
This will always return changed=True. If the mount point I(path) This will always return RV(ignore:changed=true). If the mount point O(path)
has already a device mounted on, and its source is different than I(src), has already a device mounted on, and its source is different than O(src),
the module will fail to avoid unexpected unmount or mount point override. 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. 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. 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 - V(absent) specifies that the mount point entry O(path) will be removed
I(fstab) and will also unmount the device and remove the mount from I(fstab) and will also unmount the mounted device and remove the
point. mount point. A mounted device will be unmounted regardless of O(src) or its
- C(remounted) specifies that the device will be remounted for when you real source. V(absent) does not unmount recursively, and the module will
fail if multiple devices are mounted on the same mount point. Using
V(absent) with a mount point that is not registered in the I(fstab) has
no effect, use V(unmounted) instead.
- V(remounted) 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 want to force a refresh on the mount itself (added in 2.9). This will
always return changed=true. If I(opts) is set, the options will be always return RV(ignore:changed=true). If O(opts) is set, the options will be
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 O(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 V(mounted)
instead to work around this issue. C(remounted) expects the mount point instead to work around this issue. V(remounted) expects the mount point
to be present in the I(fstab). To remount a mount point not registered 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. in I(fstab), use V(ephemeral) instead, especially with BSD nodes.
- C(absent_from_fstab) specifies that the device mount's entry will be - V(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 removed from I(fstab). This option does not unmount it or delete the
mountpoint. mountpoint.
type: str type: str
@@ -100,20 +110,20 @@ options:
- This might be useful if you need to configure mountpoints in a chroot environment. - This might be useful if you need to configure mountpoints in a chroot environment.
- 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 C(/etc/fstab) or C(/etc/vfstab) on Solaris.
- This parameter is ignored when I(state) is set to C(ephemeral). - This parameter is ignored when O(state=ephemeral).
type: str type: str
boot: boot:
description: description:
- Determines if the filesystem should be mounted on boot. - Determines if the filesystem should be mounted on boot.
- Only applies to Solaris and Linux systems. - Only applies to Solaris and Linux systems.
- For Solaris systems, C(true) will set C(yes) as the value of mount at boot - For Solaris systems, C(true) will set C(yes) as the value of mount at boot
in I(/etc/vfstab). in C(/etc/vfstab).
- For Linux, FreeBSD, NetBSD and OpenBSD systems, C(false) will add C(noauto) - For Linux, FreeBSD, NetBSD and OpenBSD systems, C(false) will add C(noauto)
to mount options in I(/etc/fstab). to mount options in C(/etc/fstab).
- To avoid mount option conflicts, if C(noauto) specified in C(opts), - To avoid mount option conflicts, if C(noauto) specified in O(opts),
mount module will ignore C(boot). mount module will ignore O(boot).
- This parameter is ignored when I(state) is set to C(ephemeral). - This parameter is ignored when O(state=ephemeral).
type: bool type: bool
default: true default: true
backup: backup:
@@ -123,9 +133,9 @@ options:
type: bool type: bool
default: false 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 O(name) option has been changed to O(path) as
default, but I(name) still works as well. default, but O(name) still works as well.
- Using C(remounted) with I(opts) set may create unexpected results based on - Using O(state=remounted) with O(opts) set may create unexpected results based on
the existing options already defined on mount, so care should be taken to the existing options already defined on mount, so care should be taken to
ensure that conflicting options are not present before hand. ensure that conflicting options are not present before hand.
''' '''
@@ -204,6 +214,7 @@ EXAMPLES = r'''
src: //192.168.1.200/share src: //192.168.1.200/share
path: /mnt/smb_share path: /mnt/smb_share
opts: "rw,vers=3,file_mode=0600,dir_mode=0700,dom={{ ad_domain }},username={{ ad_username }},password={{ ad_password }}" opts: "rw,vers=3,file_mode=0600,dir_mode=0700,dom={{ ad_domain }},username={{ ad_username }},password={{ ad_password }}"
opts_no_log: true
fstype: cifs fstype: cifs
state: ephemeral state: ephemeral
''' '''
@@ -268,7 +279,7 @@ def _set_mount_save_old(module, args):
old_lines = [] old_lines = []
exists = False exists = False
changed = False changed = False
escaped_args = dict([(k, _escape_fstab(v)) for k, v in iteritems(args) if k != 'warnings']) escaped_args = dict([(k, _escape_fstab(v)) for k, v in iteritems(args)])
new_line = '%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s\n' new_line = '%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s\n'
if platform.system() == 'SunOS': if platform.system() == 'SunOS':
@@ -292,7 +303,7 @@ def _set_mount_save_old(module, args):
continue continue
fields = line.split() fields = line.split('#')[0].split()
# Check if we got a valid line for splitting # Check if we got a valid line for splitting
# (on Linux the 5th and the 6th field is optional) # (on Linux the 5th and the 6th field is optional)
@@ -763,6 +774,7 @@ def main():
fstype=dict(type='str'), fstype=dict(type='str'),
path=dict(type='path', required=True, aliases=['name']), path=dict(type='path', required=True, aliases=['name']),
opts=dict(type='str'), opts=dict(type='str'),
opts_no_log=dict(type='bool', default=False),
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),
@@ -776,6 +788,9 @@ def main():
), ),
) )
if module.params['opts_no_log']:
module.no_log_values.add(module.params['opts'])
# solaris args: # solaris args:
# name, src, fstype, opts, boot, passno, state, fstab=/etc/vfstab # name, src, fstype, opts, boot, passno, state, fstab=/etc/vfstab
# linux args: # linux args:
@@ -789,7 +804,6 @@ def main():
passno='-', passno='-',
fstab=module.params['fstab'], fstab=module.params['fstab'],
boot='yes' if module.params['boot'] else 'no', boot='yes' if module.params['boot'] else 'no',
warnings=[]
) )
if args['fstab'] is None: if args['fstab'] is None:
args['fstab'] = '/etc/vfstab' args['fstab'] = '/etc/vfstab'
@@ -801,7 +815,6 @@ def main():
passno='0', passno='0',
fstab=module.params['fstab'], fstab=module.params['fstab'],
boot='yes', boot='yes',
warnings=[]
) )
if args['fstab'] is None: if args['fstab'] is None:
args['fstab'] = '/etc/fstab' args['fstab'] = '/etc/fstab'
@@ -819,8 +832,7 @@ def main():
linux_mounts = get_linux_mounts(module) linux_mounts = get_linux_mounts(module)
if linux_mounts is None: if linux_mounts is None:
args['warnings'].append('Cannot open file /proc/self/mountinfo.' module.warn('Cannot open file /proc/self/mountinfo. Bind mounts might be misinterpreted.')
' Bind mounts might be misinterpreted.')
# Override defaults with user specified params # Override defaults with user specified params
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'): for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
@@ -831,15 +843,12 @@ 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'.") module.warn("Ignore the 'boot' due to 'opts' contains 'noauto'.")
elif not module.params['boot']: elif not module.params['boot']:
args['boot'] = 'no' args['boot'] = 'no'
if 'defaults' in opts: opts.append('noauto')
args['warnings'].append("Ignore the 'boot' due to 'opts' contains 'defaults'.") args['opts'] = ','.join(opts)
else:
opts.append('noauto')
args['opts'] = ','.join(opts)
# If fstab file does not exist, we first need to create it. This mainly # If fstab file does not exist, we first need to create it. This mainly
# happens when fstab option is passed to the module. # happens when fstab option is passed to the module.

View File

@@ -24,7 +24,7 @@ options:
basedir: basedir:
description: description:
- Path of a base directory in which the patch file will be applied. - Path of a base directory in which the patch file will be applied.
- May be omitted when C(dest) option is specified, otherwise required. - May be omitted when O(dest) option is specified, otherwise required.
type: path type: path
dest: dest:
description: description:
@@ -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 C(false), the patch source file is looked up from the O(remote_src=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,8 +50,8 @@ options:
default: present default: present
remote_src: remote_src:
description: description:
- If C(false), it will search for src at originating/controller machine, if C(true) it will - If V(false), it will search for src at originating/controller machine,
go to the remote/target machine for the C(src). - If C(true), it will go to the remote/target machine for the O(src).
type: bool type: bool
default: false default: false
strip: strip:
@@ -68,15 +68,15 @@ options:
default: false default: false
binary: binary:
description: description:
- Setting to C(true) will disable patch's heuristic for transforming CRLF - Setting to V(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 O(src) and O(dest) must match.
- If set to C(false), C(patch) will replace CRLF in C(src) files on POSIX. - If set to V(false), C(patch) will replace CRLF in O(src) files on POSIX.
type: bool type: bool
default: false default: false
ignore_whitespace: ignore_whitespace:
description: description:
- Setting to C(true) will ignore white space changes between patch and input. - Setting to V(true) will ignore white space changes between patch and input.
type: bool type: bool
default: false default: false
notes: notes:

View File

@@ -13,7 +13,7 @@ module: rhel_facts
version_added: 1.5.0 version_added: 1.5.0
short_description: Facts module to set or override RHEL specific facts. short_description: Facts module to set or override RHEL specific facts.
description: description:
- Compatibility layer for using the "package" module for rpm-ostree based systems via setting the "pkg_mgr" fact correctly. - Compatibility layer for using the M(ansible.builtin.package) module for rpm-ostree based systems via setting the C(pkg_mgr) fact correctly.
author: author:
- Adam Miller (@maxamillion) - Adam Miller (@maxamillion)
requirements: requirements:

View File

@@ -25,12 +25,12 @@ requirements:
options: options:
name: name:
description: description:
- A package name or package specifier with version, like C(name-1.0). - A package name or package specifier with version, like V(name-1.0).
- Comparison operators for package version are valid here C(>), C(<), C(>=), C(<=). Example - 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. - 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. 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). - When using O(state=latest), this can be V('*') which means run C(yum -y update).
- You can also pass a url or a local path to a rpm file (using state=present). - You can also pass a url or a local path to a rpm file (using O(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. 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 ] aliases: [ pkg ]
type: list type: list
@@ -38,12 +38,12 @@ options:
default: [] default: []
state: state:
description: description:
- Whether to install (C(present) or C(installed), C(latest)), or remove (C(absent) or C(removed)) a package. - Whether to install (V(present) or V(installed), V(latest)), or remove (V(absent) or V(removed)) a package.
- C(present) and C(installed) will simply ensure that a desired package is installed. - V(present) and V(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. - V(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. - V(absent) and V(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 - Default is C(null), however in effect the default action is V(present) unless the C(autoremove) option is
enabled for this module, then C(absent) is inferred. enabled for this module, then V(absent) is inferred.
type: str type: str
choices: [ absent, installed, latest, present, removed ] choices: [ absent, installed, latest, present, removed ]
notes: notes:

View File

@@ -22,12 +22,12 @@ options:
type: str type: str
persistent: persistent:
description: description:
- Set to C(true) if the boolean setting should survive a reboot. - Set to V(true) if the boolean setting should survive a reboot.
type: bool type: bool
default: false default: false
state: state:
description: description:
- Desired boolean value - Desired boolean value.
type: bool type: bool
required: true required: true
ignore_selinux_state: ignore_selinux_state:
@@ -73,31 +73,14 @@ except ImportError:
HAVE_SEMANAGE = False HAVE_SEMANAGE = False
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._text import 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):
return True if ignore_selinux_state is True else selinux.is_selinux_enabled() return True if ignore_selinux_state is True else selinux.is_selinux_enabled()
def has_boolean_value(module, name):
bools = []
try:
rc, bools = selinux.security_get_boolean_names()
except OSError:
module.fail_json(msg="Failed to get list of boolean names")
# work around for selinux who changed its API, see
# https://github.com/ansible/ansible/issues/25651
if len(bools) > 0:
if isinstance(bools[0], binary_type):
name = to_bytes(name)
if name in bools:
return True
else:
return False
def get_boolean_value(module, name): def get_boolean_value(module, name):
state = 0 state = 0
try: try:
@@ -173,7 +156,10 @@ def semanage_set_boolean_value(module, handle, name, value):
semanage.semanage_handle_destroy(handle) semanage.semanage_handle_destroy(handle)
module.fail_json(msg="Failed to modify boolean key with semanage") module.fail_json(msg="Failed to modify boolean key with semanage")
if semanage.semanage_bool_set_active(handle, boolkey, sebool) < 0: if (
selinux.is_selinux_enabled()
and semanage.semanage_bool_set_active(handle, boolkey, sebool) < 0
):
semanage.semanage_handle_destroy(handle) semanage.semanage_handle_destroy(handle)
module.fail_json(msg="Failed to set boolean key active with semanage") module.fail_json(msg="Failed to set boolean key active with semanage")
@@ -281,6 +267,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)
@@ -308,12 +300,9 @@ def main():
# Feature only available in selinux library since 2012. # Feature only available in selinux library since 2012.
name = selinux.selinux_boolean_sub(name) name = selinux.selinux_boolean_sub(name)
if not has_boolean_value(module, name):
module.fail_json(msg="SELinux boolean %s does not exist." % name)
if persistent: if persistent:
changed = semanage_boolean_value(module, name, state) changed = semanage_boolean_value(module, name, state)
else: elif selinux.is_selinux_enabled():
cur_value = get_boolean_value(module, name) cur_value = get_boolean_value(module, name)
if cur_value != state: if cur_value != state:
changed = True changed = True

View File

@@ -20,7 +20,7 @@ version_added: "1.0.0"
options: options:
policy: policy:
description: description:
- The name of the SELinux policy to use (e.g. C(targeted)) will be required if I(state) is not C(disabled). - The name of the SELinux policy to use (e.g. C(targeted)) will be required unless O(state=disabled).
type: str type: str
state: state:
description: description:
@@ -30,7 +30,7 @@ options:
type: str type: str
update_kernel_param: update_kernel_param:
description: description:
- If set to I(true), will update also the kernel boot parameters when disabling/enabling SELinux. - If set to V(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: false default: false
type: bool type: bool
@@ -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

@@ -14,50 +14,51 @@ DOCUMENTATION = r'''
module: synchronize module: synchronize
short_description: A wrapper around rsync to make common tasks in your playbooks quick and easy short_description: A wrapper around rsync to make common tasks in your playbooks quick and easy
description: description:
- C(synchronize) is a wrapper around rsync to make common tasks in your playbooks quick and easy. - M(ansible.posix.synchronize) is a wrapper around C(rsync) to make common tasks in your playbooks quick and easy.
- It is run and originates on the local host where Ansible is being run. - It is run and originates on the local host where Ansible is being run.
- Of course, you could just use the C(command) action to call rsync yourself, but you also have to add a fair number of - Of course, you could just use the M(ansible.builtin.command) action to call C(rsync) yourself, but you also have to add a fair number of
boilerplate options and host facts. boilerplate options and host facts.
- This module is not intended to provide access to the full power of rsync, but does make the most common - This module is not intended to provide access to the full power of C(rsync), but does make the most common
invocations easier to implement. You `still` may need to call rsync directly via C(command) or C(shell) depending on your use case. invocations easier to implement.
You I(still) may need to call C(rsync) directly via M(ansible.builtin.command) or M(ansible.builtin.shell) depending on your use case.
version_added: "1.0.0" version_added: "1.0.0"
options: options:
src: src:
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:
- Port number for ssh on the destination host. - Port number for ssh on the destination host.
- Prior to Ansible 2.0, the ansible_ssh_port inventory var took precedence over this value. - Prior to Ansible 2.0, the C(ansible_ssh_port) inventory var took precedence over this value.
- This parameter defaults to the value of C(ansible_port), the C(remote_port) config setting - This parameter defaults to the value of C(ansible_port), the C(remote_port) config setting
or the value from ssh client configuration if none of the former have been set. or the value from ssh client configuration if none of the former have been set.
type: int type: int
mode: mode:
description: description:
- Specify the direction of the synchronization. - Specify the direction of the synchronization.
- In push mode the localhost or delegate is the source. - In V(push) mode the localhost or delegate is the source.
- In pull mode the remote host in context is the source. - In V(pull) mode the remote host in context is the source.
type: str type: str
choices: [ pull, push ] choices: [ pull, push ]
default: push default: push
archive: archive:
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 C(-D).
type: bool type: bool
default: true 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 O(archive) option is still enabled by default -
not disable it. the O(checksum) option will not disable it.
type: bool type: bool
default: false default: false
compress: compress:
@@ -73,8 +74,8 @@ options:
default: false 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 O(dest) that do not exist (after transfer, not before) in the O(src) path.
- This option requires I(recursive=true). - This option requires O(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: false default: false
@@ -130,24 +131,17 @@ options:
default: 0 default: 0
set_remote_user: set_remote_user:
description: description:
- Put user@ for the remote paths. - Put C(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(false). that does not match the inventory user, you should set this parameter to V(false).
type: bool type: bool
default: true default: true
use_ssh_args:
description:
- In Ansible 2.10 and lower, it uses the ssh_args specified in C(ansible.cfg).
- In Ansible 2.11 and onwards, when set to C(true), it uses all SSH connection configurations like
C(ansible_ssh_args), C(ansible_ssh_common_args), and C(ansible_ssh_extra_args).
type: bool
default: false
ssh_connection_multiplexing: ssh_connection_multiplexing:
description: description:
- SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections. - SSH connection multiplexing for rsync is disabled by default to prevent misconfigured ControlSockets from resulting in failed SSH connections.
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(true) to allow multiplexing and reduce SSH connection overhead. - Set this option to V(true) to allow multiplexing and reduce SSH connection overhead.
- Note that simply setting this option to C(true) is not enough; - Note that simply setting this option to V(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
@@ -157,7 +151,7 @@ options:
- Specify additional rsync options by passing in an array. - Specify additional rsync options by passing in an array.
- Note that an empty string in C(rsync_opts) will end up transfer the current working directory. - Note that an empty string in C(rsync_opts) will end up transfer the current working directory.
type: list type: list
default: default: []
elements: str elements: str
partial: partial:
description: description:
@@ -178,7 +172,7 @@ options:
- Add a destination to hard link against during the rsync. - Add a destination to hard link against during the rsync.
type: list type: list
default: default:
elements: str elements: path
delay_updates: delay_updates:
description: description:
- This option puts the temporary file from each updated file into a holding directory until the end of the transfer, - This option puts the temporary file from each updated file into a holding directory until the end of the transfer,
@@ -186,28 +180,52 @@ options:
type: bool type: bool
default: true default: true
version_added: '1.3.0' version_added: '1.3.0'
use_ssh_args:
description:
- In Ansible 2.10 and lower, it uses the ssh_args specified in C(ansible.cfg).
- In Ansible 2.11 and onwards, when set to V(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 O(use_ssh_args) for ssh arg settings.
type: str
required: false
notes: notes:
- rsync must be installed on both the local and remote host. - C(rsync) must be installed on both the local and remote host.
- For the C(synchronize) module, the "local host" is the host `the synchronize task originates on`, and the "destination host" is the host - For the M(ansible.posix.synchronize) module, the "local host" is the host I(the synchronize task originates on),
`synchronize is connecting to`. and the "destination host" is the host I(synchronize is connecting to).
- The "local host" can be changed to a different host by using `delegate_to`. This enables copying between two remote hosts or entirely on one - The "local host" can be changed to a different host by using C(delegate_to).
remote machine. This enables copying between two remote hosts or entirely on one remote machine.
- > - >
The user and permissions for the synchronize `src` are those of the user running the Ansible task on the local host (or the remote_user for a The user and permissions for the synchronize O(src) are those of the user running the Ansible task on the local host (or the remote_user for a
delegate_to host when delegate_to is used). C(delegate_to) host when C(delegate_to) is used).
- The user and permissions for the synchronize `dest` are those of the `remote_user` on the destination host or the `become_user` if `become=yes` is active. - The user and permissions for the synchronize `dest` are those of the `remote_user` on the destination host or the `become_user` if `become=yes` is active.
- In Ansible 2.0 a bug in the synchronize module made become occur on the "local host". This was fixed in Ansible 2.0.1. - In Ansible 2.0 a bug in the synchronize module made become occur on the "local host". This was fixed in Ansible 2.0.1.
- Currently, synchronize is limited to elevating permissions via passwordless sudo. This is because rsync itself is connecting to the remote machine - Currently, M(ansible.posix.synchronize) is limited to elevating permissions via passwordless sudo.
and rsync doesn't give us a way to pass sudo credentials in. This is because rsync itself is connecting to the remote machine and rsync doesn't give us a way to pass sudo credentials in.
- Currently there are only a few connection types which support synchronize (ssh, paramiko, local, and docker) because a sync strategy has been - Currently there are only a few connection types which support synchronize (ssh, paramiko, local, and docker) because a sync strategy has been
determined for those connection types. Note that the connection for these must not need a password as rsync itself is making the connection and determined for those connection types. Note that the connection for these must not need a password as rsync itself is making the connection and
rsync does not provide us a way to pass a password to the connection. rsync does not provide us a way to pass a password to the connection.
- Expect that dest=~/x will be ~<remote_user>/x even if using sudo. - Expect that O(dest=~/x) will be V(~<remote_user>/x) even if using sudo.
- Inspect the verbose output to validate the destination user/host/path are what was expected. - Inspect the verbose output to validate the destination user/host/path are what was expected.
- To exclude files and directories from being synchronized, you may add C(.rsync-filter) files to the source directory. - To exclude files and directories from being synchronized, you may add C(.rsync-filter) files to the source directory.
- rsync daemon must be up and running with correct permission when using rsync protocol in source or destination path. - rsync daemon must be up and running with correct permission when using rsync protocol in source or destination path.
- The C(synchronize) module enables `--delay-updates` by default to avoid leaving a destination in a broken in-between state if the underlying rsync process - The C(synchronize) module enables C(--delay-updates) by default to avoid leaving a destination in a broken in-between state if the underlying rsync process
encounters an error. Those synchronizing large numbers of files that are willing to trade safety for performance should disable this option. encounters an error. Those synchronizing large numbers of files that are willing to trade safety for performance should disable this option.
- 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.
@@ -235,7 +253,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/
@@ -362,11 +380,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 +406,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 +430,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 +473,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 +591,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 +600,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

@@ -19,7 +19,7 @@ version_added: "1.0.0"
options: options:
name: name:
description: description:
- The dot-separated path (also known as I(key)) specifying the sysctl variable. - The dot-separated path (also known as O(key)) specifying the sysctl variable.
required: true required: true
aliases: [ 'key' ] aliases: [ 'key' ]
type: str type: str
@@ -41,9 +41,9 @@ options:
default: false default: false
reload: reload:
description: description:
- If C(true), performs a I(/sbin/sysctl -p) if the C(sysctl_file) is - If V(true), performs a C(/sbin/sysctl -p) if the O(sysctl_file) is
updated. If C(false), does not reload I(sysctl) even if the updated. If V(false), does not reload C(sysctl) even if the
C(sysctl_file) is updated. O(sysctl_file) is updated.
type: bool type: bool
default: true default: true
sysctl_file: sysctl_file:
@@ -53,7 +53,7 @@ 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 C(-w) if necessary.
type: bool type: bool
default: false default: false
author: author:
@@ -80,6 +80,13 @@ EXAMPLES = r'''
sysctl_file: /tmp/test_sysctl.conf sysctl_file: /tmp/test_sysctl.conf
reload: false reload: false
# Enable resource limits management in FreeBSD
- ansible.posix.sysctl:
name: kern.racct.enable
value: '1'
sysctl_file: /boot/loader.conf
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
@@ -366,7 +373,7 @@ class SysctlModule(object):
# Completely rewrite the sysctl file # Completely rewrite the sysctl file
def write_sysctl(self): def write_sysctl(self):
# open a tmp file # open a tmp file
fd, tmp_path = tempfile.mkstemp('.conf', '.ansible_m_sysctl_', os.path.dirname(self.sysctl_file)) fd, tmp_path = tempfile.mkstemp('.conf', '.ansible_m_sysctl_', os.path.dirname(os.path.realpath(self.sysctl_file)))
f = open(tmp_path, "w") f = open(tmp_path, "w")
try: try:
for l in self.fixed_lines: for l in self.fixed_lines:
@@ -377,7 +384,7 @@ class SysctlModule(object):
f.close() f.close()
# replace the real one # replace the real one
self.module.atomic_move(tmp_path, self.sysctl_file) self.module.atomic_move(tmp_path, os.path.realpath(self.sysctl_file))
# ============================================================== # ==============================================================

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,44 @@
# 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: Install acl package
ansible.builtin.package:
name: acl
state: present
############################################################################## ##############################################################################
- 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 +62,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 +84,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 +117,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 +140,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 +163,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 +188,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 +209,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,29 +9,31 @@ 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
# I like adding comments yo-dude-this-is-not-a-key INVALID_DATA 2@testing # I like adding comments yo-dude-this-is-not-a-key INVALID_DATA 2@testing
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
key_path: /tmp/id_rsa.pub

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

@@ -0,0 +1,32 @@
---
- name: Create key file for test
ansible.builtin.copy:
dest: "{{ key_path }}"
content: "{{ rsa_key_basic }}"
mode: "0600"
- name: Add key using path
ansible.posix.authorized_key:
user: root
key: file://{{ key_path }}
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that the key was added
ansible.builtin.assert:
that:
- result.changed == true
- name: Add key using path again
ansible.posix.authorized_key:
user: root
key: file://{{ key_path }}
state: present
path: "{{ output_dir | expanduser }}/authorized_keys"
register: result
- name: Assert that no changes were applied
ansible.builtin.assert:
that:
- result.changed == false

View File

@@ -0,0 +1,41 @@
---
# -------------------------------------------------------------
# check permissions
- name: Create a file that is not accessible
ansible.builtin.file:
state: touch
path: "{{ output_dir | expanduser }}/file_permissions"
owner: root
mode: '0000'
- name: Create unprivileged user
ansible.builtin.user:
name: nopriv
create_home: true
- name: Try to delete a key from an unreadable file
become: true
become_user: nopriv
ansible.posix.authorized_key:
user: root
key: "{{ dss_key_basic }}"
state: absent
path: "{{ output_dir | expanduser }}/file_permissions"
register: result
ignore_errors: true
- name: Assert that the key deletion has failed
ansible.builtin.assert:
that:
- result is failed
- name: Remove the file
ansible.builtin.file:
state: absent
path: "{{ output_dir | expanduser }}/file_permissions"
- name: Remove the user
ansible.builtin.user:
name: nopriv
state: absent

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

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,3 +1,5 @@
needs/privileged
needs/root
destructive destructive
shippable/posix/group1 shippable/posix/group1
skip/aix skip/aix

View File

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

View File

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

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,116 @@
---
# 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

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

View File

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

View File

@@ -1,29 +1,50 @@
---
# Test playbook for the firewalld module # Test playbook for the firewalld module
# (c) 2017, Adam Miller <admiller@redhat.com> # (c) 2017, Adam Miller <admiller@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Ensure /run/firewalld exists - name: Ensure /run/firewalld exists
file: ansible.builtin.file:
path: /run/firewalld path: /run/firewalld
state: directory state: directory
mode: "0755"
# firewalld service operation test cases # firewalld service operation test cases
- include_tasks: service_test_cases.yml - name: Include service test cases for firewalld module
ansible.builtin.include_tasks: service_test_cases.yml
# firewalld protocol operation test cases # firewalld protocol operation test cases
- include_tasks: protocol_test_cases.yml - name: Include protocol test cases for firewalld module
ansible.builtin.include_tasks: protocol_test_cases.yml
# firewalld port operation test cases # firewalld port operation test cases
- include_tasks: port_test_cases.yml - name: Include port test cases for firewalld module
ansible.builtin.include_tasks: port_test_cases.yml
# firewalld source operation test cases # firewalld source operation test cases
- include_tasks: source_test_cases.yml - name: Include source test cases for firewalld module
ansible.builtin.include_tasks: source_test_cases.yml
# firewalld zone operation test cases # firewalld zone operation test cases
- include_tasks: zone_test_cases.yml - name: Include zone test cases for firewalld module
ansible.builtin.include_tasks: zone_test_cases.yml
# firewalld zone target operation test cases # firewalld zone target operation test cases
- include_tasks: zone_target_test_cases.yml - name: Include zone target test cases for firewalld module
ansible.builtin.include_tasks: zone_target_test_cases.yml
# firewalld port forwarding operation test cases # firewalld port forwarding operation test cases
- include_tasks: port_forward_test_cases.yml - name: Include port forward target test cases for firewalld module
ansible.builtin.include_tasks: port_forward_test_cases.yml
# firewalld masquerade operation test cases
- 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,72 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: firewalld source test permanent enabled - name: Firewalld source test permanent enabled
firewalld: ansible.posix.firewalld:
source: 192.0.2.0/24 source: 192.0.2.0/24
zone: internal zone: internal
permanent: True permanent: true
state: enabled state: enabled
register: result register: result
- name: assert firewalld source test permanent enabled worked - name: Assert firewalld source test permanent enabled worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld source test permanent enabled rerun (verify not changed) - name: Firewalld source test permanent enabled rerun (verify not changed)
firewalld: ansible.posix.firewalld:
source: 192.0.2.0/24 source: 192.0.2.0/24
zone: internal zone: internal
permanent: True permanent: true
state: enabled state: enabled
register: result register: result
- name: assert firewalld source test permanent enabled rerun worked (verify not changed) - name: Assert firewalld source test permanent enabled rerun worked (verify not changed)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed
- name: firewalld source test permanent disabled - name: Firewalld source test permanent disabled
firewalld: ansible.posix.firewalld:
source: 192.0.2.0/24 source: 192.0.2.0/24
zone: internal zone: internal
permanent: True permanent: true
state: disabled state: disabled
register: result register: result
- name: assert firewalld source test permanent disabled worked - name: Assert firewalld source test permanent disabled worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld source test permanent disabled rerun (verify not changed) - name: Firewalld source test permanent disabled rerun (verify not changed)
firewalld: ansible.posix.firewalld:
source: 192.0.2.0/24 source: 192.0.2.0/24
zone: internal zone: internal
permanent: True permanent: true
state: disabled state: disabled
register: result register: result
- name: assert firewalld source test permanent disabled rerun worked (verify not changed) - name: Assert firewalld source test permanent disabled rerun worked (verify not changed)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed
- name: firewalld source test permanent enabled is exclusive (verify exclusive error) - name: Firewalld source test permanent enabled is exclusive (verify exclusive error)
firewalld: ansible.posix.firewalld:
source: 192.0.2.0/24 source: 192.0.2.0/24
port: 8081/tcp port: 8081/tcp
zone: internal zone: internal
permanent: True permanent: true
state: enabled state: enabled
register: result register: result
ignore_errors: true ignore_errors: true
- name: assert firewalld source test permanent enabled is exclusive (verify exclusive error) - name: Assert firewalld source test permanent enabled is exclusive (verify exclusive error)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed
- "result.msg == 'parameters are mutually exclusive: icmp_block|icmp_block_inversion|service|protocol|port|port_forward|rich_rule|interface|masquerade|source|target'" - >
result.msg == 'parameters are mutually exclusive:
icmp_block|icmp_block_inversion|service|protocol|port|port_forward|rich_rule|interface|forward|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

@@ -1,47 +1,97 @@
- name: firewalld create zone custom ---
firewalld: - name: Firewalld create zone custom
ansible.posix.firewalld:
zone: custom zone: custom
permanent: True permanent: true
state: present state: present
register: result register: result
- name: assert firewalld custom zone created worked - name: Assert firewalld custom zone created worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld create zone custom rerun (verify not changed) - name: Firewalld create zone custom rerun (verify not changed)
firewalld: ansible.posix.firewalld:
zone: custom zone: custom
permanent: True permanent: true
state: present state: present
register: result register: result
- name: assert firewalld custom zone created worked (verify not changed) - name: Assert firewalld custom zone created worked (verify not changed)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed
- name: firewalld remove zone custom - name: Zone forwarding test
firewalld: when: (ansible_distribution == 'RedHat' and ansible_distribution_major_version is version('8', '>='))
block:
- name: Enable zone forwarding
ansible.posix.firewalld:
zone: custom
forward: true
permanent: true
state: enabled
register: result
- name: Assert zone forwarding is enabled
ansible.builtin.debug:
var: result is changed
- name: Enable zone forwarding (verify not changed)
ansible.posix.firewalld:
zone: custom
forward: true
permanent: true
state: enabled
register: result
- name: Assert zone forwarding is enabled (verify not changed)
ansible.builtin.debug:
var: result is not changed
- name: Disable zone forwarding
ansible.posix.firewalld:
zone: custom
forward: false
permanent: true
state: enabled
- name: Assert zone forwarding is disabled
ansible.builtin.debug:
var: result is changed
- name: Disable zone forwarding (verify not changed)
ansible.posix.firewalld:
zone: custom
forward: false
permanent: true
state: enabled
- name: Assert zone forwarding is disabled (verify not changed)
ansible.builtin.debug:
var: result is not changed
- name: Firewalld remove zone custom
ansible.posix.firewalld:
zone: custom zone: custom
permanent: True permanent: true
state: absent state: absent
register: result register: result
- name: assert firewalld custom zone removed worked - name: Assert firewalld custom zone removed worked
assert: ansible.builtin.assert:
that: that:
- result is changed - result is changed
- name: firewalld remove custom zone rerun (verify not changed) - name: Firewalld remove custom zone rerun (verify not changed)
firewalld: ansible.posix.firewalld:
zone: custom zone: custom
permanent: True permanent: true
state: absent state: absent
register: result register: result
- name: assert firewalld custom zone removed worked (verify not changed) - name: Assert firewalld custom zone removed worked (verify not changed)
assert: ansible.builtin.assert:
that: that:
- result is not changed - result is not changed

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,8 @@
# 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.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,24 @@
# 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 ansible_selinux.status == 'disabled'
- 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
- 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.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.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 | select("search", "^SELINUX=disabled\s*$") | list | length) > 0
- selinux_config_after[selinux_config_after.index('SELINUXTYPE=targeted')] is search("^SELINUXTYPE=\w+$") - (selinux_config_after | select("search", "^SELINUXTYPE=targeted\s*$") | list | length) > 0
- 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"

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