mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
Compare commits
66 commits
f854cca17d
...
a2e79c4e68
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2e79c4e68 | ||
|
|
2592341f3b | ||
|
|
4df43acac1 | ||
|
|
12a1c25f5e | ||
|
|
7062be892e | ||
|
|
20c2c30d23 | ||
|
|
4f1e6b4a6d | ||
|
|
806ab9ef9d | ||
|
|
2ed8bdc8e8 | ||
|
|
622aef2aad | ||
|
|
5165572e9e | ||
|
|
6c46a924b9 | ||
|
|
ab1bc5df9f | ||
|
|
4106ec65f9 | ||
|
|
f48515aad3 | ||
|
|
3bbf2e3cd5 | ||
|
|
ae0380d671 | ||
|
|
4f46ff218f | ||
|
|
07f1e11015 | ||
|
|
202609e425 | ||
|
|
f1b36ba1c2 | ||
|
|
0eb6a7a437 | ||
|
|
15954f8def | ||
|
|
41ce2cc8f9 | ||
|
|
b9feff586f | ||
|
|
281f957ece | ||
|
|
da1713ed3e | ||
|
|
7fb9cc95c3 | ||
|
|
3a5ba91d92 | ||
|
|
1c560e93d2 | ||
|
|
daf0b89fcb | ||
|
|
083f3aab64 | ||
|
|
9d1f67042e | ||
|
|
cddfa80d84 | ||
|
|
91a6e30d78 | ||
|
|
940d914904 | ||
|
|
b6587a783e | ||
|
|
7d069b597f | ||
|
|
38dd009615 | ||
|
|
7cf3934ef0 | ||
|
|
26c182c8ef | ||
|
|
ce24b6c746 | ||
|
|
a417ac80f0 | ||
|
|
009ed3bed5 | ||
|
|
1eb594b836 | ||
|
|
f47c5d6039 | ||
|
|
ab94cc7294 | ||
|
|
0e92d30fd3 | ||
|
|
583e4a6d6b | ||
|
|
dc7ee92827 | ||
|
|
a62acdfc5a | ||
|
|
01f19cde25 | ||
|
|
32742c3486 | ||
|
|
553b49245f | ||
|
|
84c56e1814 | ||
|
|
94523978d2 | ||
|
|
0d2ff1d2d8 | ||
|
|
2ac6fbb84b | ||
|
|
b2f053a856 | ||
|
|
a9920ae189 | ||
|
|
ee9df94762 | ||
|
|
cc93ee8232 | ||
|
|
e97087e616 | ||
|
|
e647e147a1 | ||
|
|
9575b9be64 | ||
|
|
4229db1bbe |
51 changed files with 1574 additions and 152 deletions
|
|
@ -36,7 +36,7 @@ variables:
|
|||
resources:
|
||||
containers:
|
||||
- container: default
|
||||
image: quay.io/ansible/azure-pipelines-test-container:3.0.0
|
||||
image: quay.io/ansible/azure-pipelines-test-container:4.0.1
|
||||
|
||||
pool: Standard
|
||||
|
||||
|
|
@ -50,6 +50,24 @@ stages:
|
|||
- template: templates/matrix.yml
|
||||
parameters:
|
||||
testFormat: devel/linux/{0}/1
|
||||
targets:
|
||||
- name: CentOS 7
|
||||
test: centos7
|
||||
- name: Fedora 38
|
||||
test: fedora38
|
||||
- name: openSUSE 15 py3
|
||||
test: opensuse15
|
||||
- name: Ubuntu 20.04
|
||||
test: ubuntu2004
|
||||
- name: Ubuntu 22.04
|
||||
test: ubuntu2204
|
||||
- stage: Docker_2_15
|
||||
displayName: Docker 2.15
|
||||
dependsOn: []
|
||||
jobs:
|
||||
- template: templates/matrix.yml
|
||||
parameters:
|
||||
testFormat: 2.15/linux/{0}/1
|
||||
targets:
|
||||
- name: CentOS 7
|
||||
test: centos7
|
||||
|
|
@ -135,18 +153,12 @@ stages:
|
|||
test: centos6
|
||||
- name: CentOS 7
|
||||
test: centos7
|
||||
- name: Fedora 32
|
||||
test: fedora32
|
||||
- name: Fedora 33
|
||||
test: fedora33
|
||||
- name: openSUSE 15 py2
|
||||
test: opensuse15py2
|
||||
- name: openSUSE 15 py3
|
||||
test: opensuse15
|
||||
- name: Ubuntu 18.04
|
||||
test: ubuntu1804
|
||||
- name: Ubuntu 20.04
|
||||
test: ubuntu2004
|
||||
- stage: Docker_2_10
|
||||
displayName: Docker 2.10
|
||||
dependsOn: []
|
||||
|
|
@ -159,10 +171,6 @@ stages:
|
|||
test: centos6
|
||||
- name: CentOS 7
|
||||
test: centos7
|
||||
- name: Fedora 30
|
||||
test: fedora30
|
||||
- name: Fedora 31
|
||||
test: fedora31
|
||||
- name: openSUSE 15 py2
|
||||
test: opensuse15py2
|
||||
- name: openSUSE 15 py3
|
||||
|
|
@ -183,10 +191,6 @@ stages:
|
|||
test: centos6
|
||||
- name: CentOS 7
|
||||
test: centos7
|
||||
- name: Fedora 30
|
||||
test: fedora30
|
||||
- name: Fedora 31
|
||||
test: fedora31
|
||||
- name: openSUSE 15 py2
|
||||
test: opensuse15py2
|
||||
- name: openSUSE 15 py3
|
||||
|
|
@ -205,8 +209,28 @@ stages:
|
|||
parameters:
|
||||
testFormat: devel/{0}/1
|
||||
targets:
|
||||
- name: MacOS 12.0
|
||||
test: macos/12.0
|
||||
- name: MacOS 13.2
|
||||
test: macos/13.2
|
||||
- name: RHEL 7.9
|
||||
test: rhel/7.9
|
||||
- name: RHEL 8.8
|
||||
test: rhel/8.8
|
||||
- name: RHEL 9.2
|
||||
test: rhel/9.2
|
||||
- name: FreeBSD 12.4
|
||||
test: freebsd/12.4
|
||||
- name: FreeBSD 13.2
|
||||
test: freebsd/13.2
|
||||
- stage: Remote_2_15
|
||||
displayName: Remote 2.15
|
||||
dependsOn: []
|
||||
jobs:
|
||||
- template: templates/matrix.yml
|
||||
parameters:
|
||||
testFormat: 2.15/{0}/1
|
||||
targets:
|
||||
- name: MacOS 13.2
|
||||
test: macos/13.2
|
||||
- name: RHEL 7.9
|
||||
test: rhel/7.9
|
||||
- name: RHEL 8.7
|
||||
|
|
@ -269,8 +293,6 @@ stages:
|
|||
test: rhel/7.9
|
||||
- name: RHEL 8.4
|
||||
test: rhel/8.4
|
||||
- name: FreeBSD 12.2
|
||||
test: freebsd/12.2
|
||||
- name: FreeBSD 13.0
|
||||
test: freebsd/13.0
|
||||
- stage: Remote_2_11
|
||||
|
|
@ -287,8 +309,6 @@ stages:
|
|||
test: rhel/7.9
|
||||
- name: RHEL 8.3
|
||||
test: rhel/8.3
|
||||
- name: FreeBSD 12.2
|
||||
test: freebsd/12.2
|
||||
- stage: Remote_2_10
|
||||
displayName: Remote 2.10
|
||||
dependsOn: []
|
||||
|
|
@ -335,6 +355,8 @@ stages:
|
|||
- Docker_2_13
|
||||
- Remote_2_14
|
||||
- Docker_2_14
|
||||
- Remote_2_15
|
||||
- Docker_2_15
|
||||
- Remote_devel
|
||||
- Docker_devel
|
||||
jobs:
|
||||
|
|
|
|||
|
|
@ -5,6 +5,47 @@ ansible.posix Release Notes
|
|||
.. contents:: Topics
|
||||
|
||||
|
||||
v1.5.4
|
||||
======
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- json and jsonl - Add the ``ANSIBLE_JSON_INDENT`` parameter
|
||||
- json and jsonl - Add the ``path`` attribute into the play and task output
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- Fix sysctl integration test failing on newer versions of core. Previously NoneType was allowable, now it fails to convert to a str type.
|
||||
- Support new sanity test for the ansible-core devel branch CI test (https://github.com/ansible-collections/ansible.posix/issues/446).
|
||||
- firewall - Fix issue where adding an interface to a zone would fail when the daemon is offline
|
||||
- firewall - Fix issue where opening a specific port resulted in opening the whole protocol of the specified port
|
||||
- firewalld - Consider value of masquerade and icmp_block_inversion parameters when a boolean like value is passed
|
||||
|
||||
v1.5.2
|
||||
======
|
||||
|
||||
Release Summary
|
||||
---------------
|
||||
|
||||
This is the minor release of the ``ansible.posix`` collection.
|
||||
This changelog contains all changes to the modules and plugins
|
||||
in this collection that have been added after the release of
|
||||
``ansible.posix`` 1.5.1.
|
||||
|
||||
Minor Changes
|
||||
-------------
|
||||
|
||||
- Add jsonl callback plugin to ansible.posix collection
|
||||
- firewalld - add `protocol` parameter
|
||||
|
||||
Bugfixes
|
||||
--------
|
||||
|
||||
- Fixed a bug where firewalld module fails to create/remove zones when the daemon is stopped
|
||||
- rhel_facts - Call exit_json with all keyword arguments
|
||||
|
||||
v1.5.1
|
||||
======
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ Name | Description
|
|||
[ansible.posix.firewalld_info](https://github.com/ansible-collections/ansible.posix/blob/main/docs/ansible.posix.firewalld_info_module.rst)|Gather information about firewalld
|
||||
[ansible.posix.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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# This is a cross-platform list tracking distribution packages needed by tests;
|
||||
# see https://docs.openstack.org/infra/bindep/ for additional information.
|
||||
|
||||
rsync [platform:rhel-8 platform:rhel-9]
|
||||
rsync [platform:redhat]
|
||||
|
|
|
|||
|
|
@ -294,3 +294,56 @@ releases:
|
|||
- 407_fix_firewalld_port_test.yml
|
||||
- 409_update_azp_matrix.yml
|
||||
release_date: '2023-01-20'
|
||||
1.5.2:
|
||||
changes:
|
||||
bugfixes:
|
||||
- Fixed a bug where firewalld module fails to create/remove zones when the daemon
|
||||
is stopped
|
||||
- rhel_facts - Call exit_json with all keyword arguments
|
||||
minor_changes:
|
||||
- Add jsonl callback plugin to ansible.posix collection
|
||||
- firewalld - add `protocol` parameter
|
||||
release_summary: 'This is the minor release of the ``ansible.posix`` collection.
|
||||
|
||||
This changelog contains all changes to the modules and plugins
|
||||
|
||||
in this collection that have been added after the release of
|
||||
|
||||
``ansible.posix`` 1.5.1.'
|
||||
fragments:
|
||||
- 1.5.2.yml
|
||||
- 399_firewalld_create_remove_zone_when_offline.yml
|
||||
- 413-synchronize-seealso.yml
|
||||
- 417-add-protocol-parameter.yml
|
||||
- 419-fix-patch-doc.yml
|
||||
- 425-support_test-sanity-docker-devel.yml
|
||||
- 426-firewalld_info-doc-update.yml
|
||||
- 434-fix-rhel_facts-exit_json.yml
|
||||
- 535-add-jsonl-callback.yml
|
||||
release_date: '2023-04-07'
|
||||
1.5.4:
|
||||
changes:
|
||||
bugfixes:
|
||||
- Fix sysctl integration test failing on newer versions of core. Previously
|
||||
NoneType was allowable, now it fails to convert to a str type.
|
||||
- Support new sanity test for the ansible-core devel branch CI test (https://github.com/ansible-collections/ansible.posix/issues/446).
|
||||
- firewall - Fix issue where adding an interface to a zone would fail when the
|
||||
daemon is offline
|
||||
- firewall - Fix issue where opening a specific port resulted in opening the
|
||||
whole protocol of the specified port
|
||||
- firewalld - Consider value of masquerade and icmp_block_inversion parameters
|
||||
when a boolean like value is passed
|
||||
minor_changes:
|
||||
- json and jsonl - Add the ``ANSIBLE_JSON_INDENT`` parameter
|
||||
- json and jsonl - Add the ``path`` attribute into the play and task output
|
||||
fragments:
|
||||
- 343-fix-profile_tasks-callback-documentation.yml
|
||||
- 402_firewall_fix_offline_interface_add.yml
|
||||
- 404_firewalld_masquerade_icmp_block_inversion_bugfixes.yml
|
||||
- 440-json-add-path-field.yaml
|
||||
- 441-json-add-indent-parameter.yaml
|
||||
- 445_ci_support_stable-215.yml
|
||||
- 448_support_new_sanity_test.yml
|
||||
- 451_firewall_fix_protocol_parameter.yml
|
||||
- 456_sysctl_fix_nonetype.yml
|
||||
release_date: '2023-05-10'
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
---
|
||||
bugfixes:
|
||||
- Fixed a bug where firewalld module fails to create/remove zones when the daemon is stopped
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
trivial:
|
||||
- "synchronize - fix broken ``seealso`` module reference (https://github.com/ansible-collections/ansible.posix/pull/413)."
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
trivial:
|
||||
- patch - fix format syntax and boolean values on document (https://github.com/ansible-collections/ansible.posix/pull/419).
|
||||
2
changelogs/fragments/421-remove-deprecation-warning.yml
Normal file
2
changelogs/fragments/421-remove-deprecation-warning.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
trivial:
|
||||
- synchronize - instantiate the connection plugin without the ``new_stdin`` argument, which is deprecated in ansible-core 2.15 (https://github.com/ansible-collections/ansible.posix/pull/421).
|
||||
2
changelogs/fragments/466-tests.yml
Normal file
2
changelogs/fragments/466-tests.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
trivial:
|
||||
- "Fix integration tests so they work with ansible-core devel / 2.16 (https://github.com/ansible-collections/ansible.posix/pull/466)."
|
||||
3
changelogs/fragments/477_ci_update.yml
Normal file
3
changelogs/fragments/477_ci_update.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
trivial:
|
||||
- "Drop Python3.9 and update versions of RHEL,Fedora and FreeBSD for ansible-core:devel test(https://github.com/ansible-collections/ansible.posix/issues/476)."
|
||||
2
changelogs/fragments/test-reqs.yml
Normal file
2
changelogs/fragments/test-reqs.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
trivial:
|
||||
- "Move Galaxy test requirements from old transitional format in tests/requirements.yml to standard Ansible Galaxy requirements files in tests/integration/requirements.yml and tests/unit/requirements.yml."
|
||||
|
|
@ -49,8 +49,8 @@ Parameters
|
|||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<div>If the target is a directory, setting this to <code>yes</code> will make it the default ACL for entities created inside the directory.</div>
|
||||
<div>Setting <code>default</code> to <code>yes</code> causes an error if the path is a file.</div>
|
||||
<div>If the target is a directory, setting this to <code>true</code> will make it the default ACL for entities created inside the directory.</div>
|
||||
<div>Setting <code>default</code> to <code>true</code> causes an error if the path is a file.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -63,6 +63,7 @@ Parameters
|
|||
</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>
|
||||
|
|
@ -285,7 +286,7 @@ Examples
|
|||
entity: joe
|
||||
etype: user
|
||||
permissions: rw
|
||||
default: yes
|
||||
default: true
|
||||
state: present
|
||||
|
||||
- name: Same as previous but using entry shorthand
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ Examples
|
|||
command: ls -d / >/dev/null
|
||||
count: 20
|
||||
units: minutes
|
||||
unique: yes
|
||||
unique: true
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ Parameters
|
|||
</td>
|
||||
<td>
|
||||
<div>Whether this module should manage the directory of the authorized key file.</div>
|
||||
<div>If set to <code>yes</code>, the module will create the directory, as well as set the owner and permissions of an existing directory.</div>
|
||||
<div>Be sure to set <code>manage_dir=no</code> if you are using an alternate directory for authorized_keys, as set with <code>path</code>, since you could lock yourself out of SSH access.</div>
|
||||
<div>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>
|
||||
|
|
@ -212,9 +212,9 @@ Parameters
|
|||
</td>
|
||||
<td>
|
||||
<div>This only applies if using a https url as the source of the keys.</div>
|
||||
<div>If set to <code>no</code>, the SSL certificates will not be validated.</div>
|
||||
<div>This should only set to <code>no</code> used on personally controlled sites using self-signed certificates as it avoids verifying the source site.</div>
|
||||
<div>Prior to 2.1 the code worked as if this was set to <code>yes</code>.</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>
|
||||
|
|
@ -252,7 +252,7 @@ Examples
|
|||
state: present
|
||||
key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"
|
||||
path: /etc/ssh/authorized_keys/charlie
|
||||
manage_dir: False
|
||||
manage_dir: false
|
||||
|
||||
- name: Set up multiple authorized keys
|
||||
ansible.posix.authorized_key:
|
||||
|
|
@ -275,14 +275,14 @@ Examples
|
|||
user: charlie
|
||||
state: present
|
||||
key: https://github.com/user.keys
|
||||
validate_certs: False
|
||||
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
|
||||
exclusive: true
|
||||
|
||||
- name: Set authorized key for user ubuntu copying it from current user
|
||||
ansible.posix.authorized_key:
|
||||
|
|
@ -460,7 +460,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
|
|||
</td>
|
||||
<td>success</td>
|
||||
<td>
|
||||
<div>This only applies if using a https url as the source of the keys. If set to <code>no</code>, the SSL certificates will not be validated.</div>
|
||||
<div>This only applies if using a https url as the source of the keys. If set to <code>false</code>, the SSL certificates will not be validated.</div>
|
||||
<br/>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -89,7 +89,12 @@ Examples
|
|||
|
||||
- name: Gather information about active zones
|
||||
ansible.posix.firewalld_info:
|
||||
active_zones: yes
|
||||
active_zones: true
|
||||
register: result
|
||||
|
||||
- name: Print default zone for debugging
|
||||
ansible.builtin.debug:
|
||||
var: result.firewalld_info.default_zone
|
||||
|
||||
- name: Gather information about specific zones
|
||||
ansible.posix.firewalld_info:
|
||||
|
|
@ -97,6 +102,7 @@ Examples
|
|||
- public
|
||||
- external
|
||||
- internal
|
||||
register: result
|
||||
|
||||
|
||||
|
||||
|
|
@ -163,7 +169,7 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
|
|||
<td class="elbow-placeholder"> </td>
|
||||
<td colspan="3">
|
||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||
<b>default_zones</b>
|
||||
<b>default_zone</b>
|
||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
|
||||
<div style="font-size: small">
|
||||
<span style="color: purple">string</span>
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ Parameters
|
|||
<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 >= 0.3.9).</div>
|
||||
<div>Note that if this is <code>no</code>, immediate is assumed <code>yes</code>.</div>
|
||||
<div>Note that if this is <code>false</code>, immediate is assumed <code>true</code>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -262,6 +262,21 @@ Parameters
|
|||
</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>
|
||||
|
|
@ -414,29 +429,35 @@ Examples
|
|||
- name: permit traffic in default zone for https service
|
||||
ansible.posix.firewalld:
|
||||
service: https
|
||||
permanent: yes
|
||||
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: yes
|
||||
permanent: true
|
||||
state: disabled
|
||||
|
||||
- ansible.posix.firewalld:
|
||||
port: 161-162/udp
|
||||
permanent: yes
|
||||
permanent: true
|
||||
state: enabled
|
||||
|
||||
- ansible.posix.firewalld:
|
||||
zone: dmz
|
||||
service: http
|
||||
permanent: yes
|
||||
permanent: true
|
||||
state: enabled
|
||||
|
||||
- ansible.posix.firewalld:
|
||||
rich_rule: rule service name="ftp" audit limit value="1/m" accept
|
||||
permanent: yes
|
||||
permanent: true
|
||||
state: enabled
|
||||
|
||||
- ansible.posix.firewalld:
|
||||
|
|
@ -447,44 +468,44 @@ Examples
|
|||
- ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
interface: eth2
|
||||
permanent: yes
|
||||
permanent: true
|
||||
state: enabled
|
||||
|
||||
- ansible.posix.firewalld:
|
||||
masquerade: yes
|
||||
masquerade: true
|
||||
state: enabled
|
||||
permanent: yes
|
||||
permanent: true
|
||||
zone: dmz
|
||||
|
||||
- ansible.posix.firewalld:
|
||||
zone: custom
|
||||
state: present
|
||||
permanent: yes
|
||||
permanent: true
|
||||
|
||||
- ansible.posix.firewalld:
|
||||
zone: drop
|
||||
state: enabled
|
||||
permanent: yes
|
||||
icmp_block_inversion: yes
|
||||
permanent: true
|
||||
icmp_block_inversion: true
|
||||
|
||||
- ansible.posix.firewalld:
|
||||
zone: drop
|
||||
state: enabled
|
||||
permanent: yes
|
||||
permanent: true
|
||||
icmp_block: echo-request
|
||||
|
||||
- ansible.posix.firewalld:
|
||||
zone: internal
|
||||
state: present
|
||||
permanent: yes
|
||||
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: yes
|
||||
immediate: yes
|
||||
permanent: true
|
||||
immediate: true
|
||||
state: enabled
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ Parameters
|
|||
<div>For Solaris systems, <code>true</code> will set <code>yes</code> as the value of mount at boot in <em>/etc/vfstab</em>.</div>
|
||||
<div>For 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>
|
||||
|
|
@ -90,7 +91,7 @@ Parameters
|
|||
<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.</div>
|
||||
<div>Has no effect on Solaris systems or when used with <code>ephemeral</code>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -110,6 +111,7 @@ Parameters
|
|||
<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>
|
||||
|
|
@ -125,7 +127,7 @@ Parameters
|
|||
</td>
|
||||
<td>
|
||||
<div>Filesystem type.</div>
|
||||
<div>Required when <em>state</em> is <code>present</code> or <code>mounted</code>.</div>
|
||||
<div>Required when <em>state</em> is <code>present</code>, <code>mounted</code> or <code>ephemeral</code>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -158,7 +160,7 @@ Parameters
|
|||
<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.</div>
|
||||
<div>Deprecated on Solaris systems. Has no effect when used with <code>ephemeral</code>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -192,7 +194,7 @@ Parameters
|
|||
</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> or <code>mounted</code>.</div>
|
||||
<div>Required when <em>state</em> set to <code>present</code>, <code>mounted</code> or <code>ephemeral</code>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -208,18 +210,22 @@ Parameters
|
|||
<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's entry will be removed from <em>fstab</em> and will also unmount the device and remove the mount point.</div>
|
||||
<div><code>remounted</code> specifies that the device will be remounted for when you want to force a refresh on the mount itself (added in 2.9). This will always return changed=true. If <em>opts</em> is set, the options will be applied to the remount, but will not change <em>fstab</em>. Additionally, if <em>opts</em> is set, and the remount command fails, the module will error to prevent unexpected mount changes. Try using <code>mounted</code> instead to work around this issue.</div>
|
||||
<div><code>remounted</code> specifies that the device will be remounted for when you want to force a refresh on the mount itself (added in 2.9). This will always return changed=true. If <em>opts</em> is set, the options will be applied to the remount, but will not change <em>fstab</em>. Additionally, if <em>opts</em> is set, and the remount command fails, the module will error to prevent unexpected mount changes. Try using <code>mounted</code> instead to work around this issue. <code>remounted</code> expects the mount point to be present in the <em>fstab</em>. To remount a mount point not registered in <em>fstab</em>, use <code>ephemeral</code> instead, especially with BSD nodes.</div>
|
||||
<div><code>absent_from_fstab</code> specifies that the device mount's entry will be removed from <em>fstab</em>. This option does not unmount it or delete the mountpoint.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
@ -304,10 +310,18 @@ Examples
|
|||
src: 192.168.1.100:/nfs/ssd/shared_data
|
||||
path: /mnt/shared_data
|
||||
opts: rw,sync,hard
|
||||
boot: no
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -84,9 +84,9 @@ Parameters
|
|||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<div>Setting to <code>yes</code> will disable patch's heuristic for transforming CRLF line endings into LF.</div>
|
||||
<div>Setting to <code>true</code> will disable patch'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>no</code>, <code>patch</code> will replace CRLF in <code>src</code> files on POSIX.</div>
|
||||
<div>If set to <code>false</code>, <code>patch</code> will replace CRLF in <code>src</code> files on POSIX.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -122,7 +122,7 @@ Parameters
|
|||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<div>Setting to <code>yes</code> will ignore white space changes between patch and input..</div>
|
||||
<div>Setting to <code>true</code> will ignore white space changes between patch and input.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -141,7 +141,7 @@ Parameters
|
|||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<div>If <code>no</code>, it will search for src at originating/controller machine, if <code>yes</code> it will go to the remote/target machine for the <code>src</code>.</div>
|
||||
<div>If <code>false</code>, it will search for src at originating/controller machine, if <code>true</code> it will go to the remote/target machine for the <code>src</code>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -157,7 +157,7 @@ Parameters
|
|||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<div>Path of the patch file as accepted by the GNU patch tool. If <code>remote_src</code> is 'no', the patch source file is looked up from the module's <em>files</em> directory.</div>
|
||||
<div>Path of the patch file as accepted by the GNU patch tool. If <code>remote_src</code> is <code>false</code>, the patch source file is looked up from the module's <em>files</em> directory.</div>
|
||||
<div style="font-size: small; color: darkgreen"><br/>aliases: patchfile</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
103
docs/ansible.posix.rhel_facts_module.rst
Normal file
103
docs/ansible.posix.rhel_facts_module.rst
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
.. _ansible.posix.rhel_facts_module:
|
||||
|
||||
|
||||
************************
|
||||
ansible.posix.rhel_facts
|
||||
************************
|
||||
|
||||
**Facts module to set or override RHEL specific facts.**
|
||||
|
||||
|
||||
Version added: 1.5.0
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
- Compatibility layer for using the "package" module for rpm-ostree based systems via setting the "pkg_mgr" fact correctly.
|
||||
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
The below requirements are needed on the host that executes this module.
|
||||
|
||||
- rpm-ostree
|
||||
|
||||
|
||||
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
.. seealso::
|
||||
|
||||
:ref:`ansible.builtin.package_module`
|
||||
The official documentation on the **ansible.builtin.package** module.
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
- name: Playbook to use the package module on all RHEL footprints
|
||||
vars:
|
||||
ansible_facts_modules:
|
||||
- setup # REQUIRED to be run before all custom fact modules
|
||||
- ansible.posix.rhel_facts
|
||||
tasks:
|
||||
- name: Ensure packages are installed
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- htop
|
||||
- ansible
|
||||
state: present
|
||||
|
||||
|
||||
Returned Facts
|
||||
--------------
|
||||
Facts returned by this module are added/updated in the ``hostvars`` host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<table border=0 cellpadding=0 class="documentation-table">
|
||||
<tr>
|
||||
<th colspan="1">Fact</th>
|
||||
<th>Returned</th>
|
||||
<th width="100%">Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="1" colspan="1">
|
||||
<div class="ansibleOptionAnchor" id="return-"></div>
|
||||
<b>pkg_mgr</b>
|
||||
<a class="ansibleOptionLink" href="#return-" title="Permalink to this fact"></a>
|
||||
<div style="font-size: small">
|
||||
<span style="color: purple">string</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>when needed</td>
|
||||
<td>
|
||||
<div>System-level package manager override
|
||||
</div>
|
||||
<br/>
|
||||
<div style="font-size: smaller"><b>Sample:</b></div>
|
||||
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">{'pkg_mgr': 'ansible.posix.rhel_facts'}</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br/><br/>
|
||||
|
||||
|
||||
|
||||
Status
|
||||
------
|
||||
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
- Adam Miller (@maxamillion)
|
||||
156
docs/ansible.posix.rhel_rpm_ostree_module.rst
Normal file
156
docs/ansible.posix.rhel_rpm_ostree_module.rst
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
.. _ansible.posix.rhel_rpm_ostree_module:
|
||||
|
||||
|
||||
*****************************
|
||||
ansible.posix.rhel_rpm_ostree
|
||||
*****************************
|
||||
|
||||
**Ensure packages exist in a RHEL for Edge rpm-ostree based system**
|
||||
|
||||
|
||||
Version added: 1.5.0
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
- Compatibility layer for using the "package" module for RHEL for Edge systems utilizing the RHEL System Roles.
|
||||
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
The below requirements are needed on the host that executes this module.
|
||||
|
||||
- rpm-ostree
|
||||
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<table border=0 cellpadding=0 class="documentation-table">
|
||||
<tr>
|
||||
<th colspan="1">Parameter</th>
|
||||
<th>Choices/<font color="blue">Defaults</font></th>
|
||||
<th width="100%">Comments</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="1">
|
||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||
<b>name</b>
|
||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||
<div style="font-size: small">
|
||||
<span style="color: purple">list</span>
|
||||
/ <span style="color: purple">elements=string</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<b>Default:</b><br/><div style="color: blue">[]</div>
|
||||
</td>
|
||||
<td>
|
||||
<div>A package name or package specifier with version, like <code>name-1.0</code>.</div>
|
||||
<div>Comparison operators for package version are valid here <code>></code>, <code><</code>, <code>>=</code>, <code><=</code>. Example - <code>name>=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>'*'</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'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)
|
||||
175
docs/ansible.posix.rpm_ostree_upgrade_module.rst
Normal file
175
docs/ansible.posix.rpm_ostree_upgrade_module.rst
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
.. _ansible.posix.rpm_ostree_upgrade_module:
|
||||
|
||||
|
||||
********************************
|
||||
ansible.posix.rpm_ostree_upgrade
|
||||
********************************
|
||||
|
||||
**Manage rpm-ostree upgrade transactions**
|
||||
|
||||
|
||||
Version added: 1.5.0
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
- Manage an rpm-ostree upgrade transactions.
|
||||
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
The below requirements are needed on the host that executes this module.
|
||||
|
||||
- rpm-ostree
|
||||
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<table border=0 cellpadding=0 class="documentation-table">
|
||||
<tr>
|
||||
<th colspan="1">Parameter</th>
|
||||
<th>Choices/<font color="blue">Defaults</font></th>
|
||||
<th width="100%">Comments</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="1">
|
||||
<div class="ansibleOptionAnchor" id="parameter-"></div>
|
||||
<b>allow_downgrade</b>
|
||||
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
|
||||
<div style="font-size: small">
|
||||
<span style="color: purple">boolean</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<ul style="margin: 0; padding: 0"><b>Choices:</b>
|
||||
<li><div style="color: blue"><b>no</b> ←</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> ←</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> ←</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)
|
||||
|
|
@ -92,7 +92,7 @@ Parameters
|
|||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<div>Set to <code>yes</code> if the boolean setting should survive a reboot.</div>
|
||||
<div>Set to <code>true</code> if the boolean setting should survive a reboot.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -135,8 +135,8 @@ Examples
|
|||
- name: Set httpd_can_network_connect flag on and keep it persistent across reboots
|
||||
ansible.posix.seboolean:
|
||||
name: httpd_can_network_connect
|
||||
state: yes
|
||||
persistent: yes
|
||||
state: true
|
||||
persistent: true
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ Parameters
|
|||
</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=yes</em>.</div>
|
||||
<div>This option requires <em>recursive=true</em>.</div>
|
||||
<div>This option ignores excluded files and behaves like the rsync opt <code>--delete-after</code>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -465,7 +465,7 @@ Parameters
|
|||
</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>no</code>.</div>
|
||||
<div>If you have a custom ssh config to define the remote user for a host that does not match the inventory user, you should set this parameter to <code>false</code>.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -502,8 +502,8 @@ Parameters
|
|||
</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>yes</code> to allow multiplexing and reduce SSH connection overhead.</div>
|
||||
<div>Note that simply setting this option to <code>yes</code> is not enough; You must also configure SSH connection multiplexing in your SSH client config by setting values for <code>ControlMaster</code>, <code>ControlPersist</code> and <code>ControlPath</code>.</div>
|
||||
<div>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>
|
||||
|
|
@ -595,8 +595,8 @@ See Also
|
|||
|
||||
.. seealso::
|
||||
|
||||
:ref:`copy_module`
|
||||
The official documentation on the **copy** module.
|
||||
: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.
|
||||
|
||||
|
|
@ -639,27 +639,27 @@ Examples
|
|||
ansible.posix.synchronize:
|
||||
src: some/relative/path
|
||||
dest: /some/absolute/path
|
||||
archive: no
|
||||
archive: false
|
||||
|
||||
- name: Synchronization with --archive options enabled except for --recursive
|
||||
ansible.posix.synchronize:
|
||||
src: some/relative/path
|
||||
dest: /some/absolute/path
|
||||
recursive: no
|
||||
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: yes
|
||||
times: no
|
||||
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: no
|
||||
links: yes
|
||||
archive: false
|
||||
links: true
|
||||
|
||||
- name: Synchronization of two paths both on the control machine
|
||||
ansible.posix.synchronize:
|
||||
|
|
@ -689,8 +689,8 @@ Examples
|
|||
ansible.posix.synchronize:
|
||||
src: some/relative/path
|
||||
dest: /some/absolute/path
|
||||
delete: yes
|
||||
recursive: yes
|
||||
delete: true
|
||||
recursive: true
|
||||
|
||||
# This specific command is granted su privileges on the destination
|
||||
- name: Synchronize using an alternate rsync command
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ Parameters
|
|||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<div>If <code>yes</code>, performs a <em>/sbin/sysctl -p</em> if the <code>sysctl_file</code> is updated. If <code>no</code>, does not reload <em>sysctl</em> even if the <code>sysctl_file</code> is updated.</div>
|
||||
<div>If <code>true</code>, performs a <em>/sbin/sysctl -p</em> if the <code>sysctl_file</code> is updated. If <code>false</code>, does not reload <em>sysctl</em> even if the <code>sysctl_file</code> is updated.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -139,7 +139,7 @@ Parameters
|
|||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<div>Verify token value with the sysctl command and set with -w if necessary</div>
|
||||
<div>Verify token value with the sysctl command and set with -w if necessary.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
@ -186,21 +186,21 @@ Examples
|
|||
name: kernel.panic
|
||||
value: '3'
|
||||
sysctl_file: /tmp/test_sysctl.conf
|
||||
reload: no
|
||||
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: yes
|
||||
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: yes
|
||||
sysctl_set: true
|
||||
state: present
|
||||
reload: yes
|
||||
reload: true
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
namespace: ansible
|
||||
name: posix
|
||||
version: 1.5.0
|
||||
version: 1.5.4
|
||||
readme: README.md
|
||||
authors:
|
||||
- Ansible (github.com/ansible)
|
||||
|
|
|
|||
|
|
@ -284,9 +284,6 @@ class ActionModule(ActionBase):
|
|||
# told (via delegate_to) that a different host is the source of the
|
||||
# rsync
|
||||
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
|
||||
localhost_shell = None
|
||||
for host in C.LOCALHOST:
|
||||
|
|
@ -315,7 +312,11 @@ class ActionModule(ActionBase):
|
|||
localhost_executable = C.DEFAULT_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
|
||||
# Override _remote_is_local as an instance attribute specifically for the synchronize use case
|
||||
# ensuring we set local tmpdir correctly
|
||||
|
|
|
|||
|
|
@ -25,6 +25,16 @@ DOCUMENTATION = '''
|
|||
- key: show_custom_stats
|
||||
section: defaults
|
||||
type: bool
|
||||
json_indent:
|
||||
name: Use indenting for the JSON output
|
||||
description: 'If specified, use this many spaces for indenting in the JSON output. If <= 0, write to a single line.'
|
||||
default: 4
|
||||
env:
|
||||
- name: ANSIBLE_JSON_INDENT
|
||||
ini:
|
||||
- key: json_indent
|
||||
section: defaults
|
||||
type: integer
|
||||
notes:
|
||||
- When using a strategy such as free, host_pinned, or a custom strategy, host results will
|
||||
be added to new task results in ``.plays[].tasks[]``. As such, there will exist duplicate
|
||||
|
|
@ -61,12 +71,19 @@ class CallbackModule(CallbackBase):
|
|||
self._task_map = {}
|
||||
self._is_lockstep = False
|
||||
|
||||
self.set_options()
|
||||
|
||||
self._json_indent = self.get_option('json_indent')
|
||||
if self._json_indent <= 0:
|
||||
self._json_indent = None
|
||||
|
||||
def _new_play(self, play):
|
||||
self._is_lockstep = play.strategy in LOCKSTEP_CALLBACKS
|
||||
return {
|
||||
'play': {
|
||||
'name': play.get_name(),
|
||||
'id': to_text(play._uuid),
|
||||
'path': to_text(play.get_path()),
|
||||
'duration': {
|
||||
'start': current_time()
|
||||
}
|
||||
|
|
@ -79,6 +96,7 @@ class CallbackModule(CallbackBase):
|
|||
'task': {
|
||||
'name': task.get_name(),
|
||||
'id': to_text(task._uuid),
|
||||
'path': to_text(task.get_path()),
|
||||
'duration': {
|
||||
'start': current_time()
|
||||
}
|
||||
|
|
@ -143,7 +161,7 @@ class CallbackModule(CallbackBase):
|
|||
'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):
|
||||
"""This function is used as a partial to add failed/skipped info in a single method"""
|
||||
|
|
|
|||
214
plugins/callback/jsonl.py
Normal file
214
plugins/callback/jsonl.py
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
# (c) 2016, Matt Martz <matt@sivel.net>
|
||||
# (c) 2017 Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
name: jsonl
|
||||
short_description: Ansible screen output as JSONL (lines in json format)
|
||||
description:
|
||||
- This callback converts all events into JSON output to stdout
|
||||
- This callback in contrast with ansible.posix.json uses less memory, because it doesn't store results.
|
||||
type: stdout
|
||||
requirements:
|
||||
- Set as stdout in config
|
||||
options:
|
||||
show_custom_stats:
|
||||
name: Show custom stats
|
||||
description: 'This adds the custom stats set via the set_stats plugin to the play recap'
|
||||
default: False
|
||||
env:
|
||||
- name: ANSIBLE_SHOW_CUSTOM_STATS
|
||||
ini:
|
||||
- key: show_custom_stats
|
||||
section: defaults
|
||||
type: bool
|
||||
json_indent:
|
||||
name: Use indenting for the JSON output
|
||||
description: 'If specified, use this many spaces for indenting in the JSON output. If not specified or <= 0, write to a single line.'
|
||||
default: 0
|
||||
env:
|
||||
- name: ANSIBLE_JSON_INDENT
|
||||
ini:
|
||||
- key: json_indent
|
||||
section: defaults
|
||||
type: integer
|
||||
notes:
|
||||
- When using a strategy such as free, host_pinned, or a custom strategy, host results will
|
||||
be added to new task results in ``.plays[].tasks[]``. As such, there will exist duplicate
|
||||
task objects indicated by duplicate task IDs at ``.plays[].tasks[].task.id``, each with an
|
||||
individual host result for the task.
|
||||
'''
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import copy
|
||||
|
||||
from functools import partial
|
||||
|
||||
from ansible.inventory.host import Host
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.parsing.ajson import AnsibleJSONEncoder
|
||||
from ansible.plugins.callback import CallbackBase
|
||||
|
||||
|
||||
LOCKSTEP_CALLBACKS = frozenset(('linear', 'debug'))
|
||||
|
||||
|
||||
def current_time():
|
||||
return '%sZ' % datetime.datetime.utcnow().isoformat()
|
||||
|
||||
|
||||
class CallbackModule(CallbackBase):
|
||||
CALLBACK_VERSION = 2.0
|
||||
CALLBACK_TYPE = 'stdout'
|
||||
CALLBACK_NAME = 'ansible.posix.jsonl'
|
||||
|
||||
def __init__(self, display=None):
|
||||
super(CallbackModule, self).__init__(display)
|
||||
self.results = []
|
||||
self._task_map = {}
|
||||
self._is_lockstep = False
|
||||
|
||||
self.set_options()
|
||||
|
||||
self._json_indent = self.get_option('json_indent')
|
||||
if self._json_indent <= 0:
|
||||
self._json_indent = None
|
||||
|
||||
def _new_play(self, play):
|
||||
self._is_lockstep = play.strategy in LOCKSTEP_CALLBACKS
|
||||
return {
|
||||
'play': {
|
||||
'name': play.get_name(),
|
||||
'id': to_text(play._uuid),
|
||||
'path': to_text(play.get_path()),
|
||||
'duration': {
|
||||
'start': current_time()
|
||||
}
|
||||
},
|
||||
'tasks': []
|
||||
}
|
||||
|
||||
def _new_task(self, task):
|
||||
return {
|
||||
'task': {
|
||||
'name': task.get_name(),
|
||||
'id': to_text(task._uuid),
|
||||
'path': to_text(task.get_path()),
|
||||
'duration': {
|
||||
'start': current_time()
|
||||
}
|
||||
},
|
||||
'hosts': {}
|
||||
}
|
||||
|
||||
def _find_result_task(self, host, task):
|
||||
key = (host.get_name(), task._uuid)
|
||||
return self._task_map.get(
|
||||
key,
|
||||
self.results[-1]['tasks'][-1]
|
||||
)
|
||||
|
||||
def v2_playbook_on_play_start(self, play):
|
||||
play_result = self._new_play(play)
|
||||
self.results.append(play_result)
|
||||
self._write_event('v2_playbook_on_play_start', play_result)
|
||||
|
||||
def v2_runner_on_start(self, host, task):
|
||||
if self._is_lockstep:
|
||||
return
|
||||
key = (host.get_name(), task._uuid)
|
||||
task_result = self._new_task(task)
|
||||
self._task_map[key] = task_result
|
||||
self.results[-1]['tasks'].append(task_result)
|
||||
self._write_event('v2_runner_on_start', task_result)
|
||||
|
||||
def v2_playbook_on_task_start(self, task, is_conditional):
|
||||
if not self._is_lockstep:
|
||||
return
|
||||
task_result = self._new_task(task)
|
||||
self.results[-1]['tasks'].append(task_result)
|
||||
self._write_event('v2_playbook_on_task_start', task_result)
|
||||
|
||||
def v2_playbook_on_handler_task_start(self, task):
|
||||
if not self._is_lockstep:
|
||||
return
|
||||
task_result = self._new_task(task)
|
||||
self.results[-1]['tasks'].append(task_result)
|
||||
self._write_event('v2_playbook_on_handler_task_start', task_result)
|
||||
|
||||
def _convert_host_to_name(self, key):
|
||||
if isinstance(key, (Host,)):
|
||||
return key.get_name()
|
||||
return key
|
||||
|
||||
def v2_playbook_on_stats(self, stats):
|
||||
"""Display info about playbook statistics"""
|
||||
|
||||
hosts = sorted(stats.processed.keys())
|
||||
|
||||
summary = {}
|
||||
for h in hosts:
|
||||
s = stats.summarize(h)
|
||||
summary[h] = s
|
||||
|
||||
custom_stats = {}
|
||||
global_custom_stats = {}
|
||||
|
||||
if self.get_option('show_custom_stats') and stats.custom:
|
||||
custom_stats.update(dict((self._convert_host_to_name(k), v) for k, v in stats.custom.items()))
|
||||
global_custom_stats.update(custom_stats.pop('_run', {}))
|
||||
|
||||
output = {
|
||||
'stats': summary,
|
||||
'custom_stats': custom_stats,
|
||||
'global_custom_stats': global_custom_stats,
|
||||
}
|
||||
|
||||
self._write_event('v2_playbook_on_stats', output)
|
||||
|
||||
def _write_event(self, event_name, output):
|
||||
output['_event'] = event_name
|
||||
output['_timestamp'] = current_time()
|
||||
self._display.display(json.dumps(output, cls=AnsibleJSONEncoder, indent=self._json_indent, separators=',:', sort_keys=True))
|
||||
|
||||
def _record_task_result(self, event_name, on_info, result, **kwargs):
|
||||
"""This function is used as a partial to add failed/skipped info in a single method"""
|
||||
host = result._host
|
||||
task = result._task
|
||||
|
||||
result_copy = result._result.copy()
|
||||
result_copy.update(on_info)
|
||||
result_copy['action'] = task.action
|
||||
|
||||
task_result = self._find_result_task(host, task)
|
||||
|
||||
end_time = current_time()
|
||||
task_result['task']['duration']['end'] = end_time
|
||||
self.results[-1]['play']['duration']['end'] = end_time
|
||||
|
||||
task_result_copy = copy.deepcopy(task_result)
|
||||
task_result_copy['hosts'][host.name] = result_copy
|
||||
|
||||
if not self._is_lockstep:
|
||||
key = (host.get_name(), task._uuid)
|
||||
del self._task_map[key]
|
||||
|
||||
self._write_event(event_name, task_result_copy)
|
||||
|
||||
def __getattribute__(self, name):
|
||||
"""Return ``_record_task_result`` partial with a dict containing skipped/failed if necessary"""
|
||||
if name not in ('v2_runner_on_ok', 'v2_runner_on_failed', 'v2_runner_on_unreachable', 'v2_runner_on_skipped'):
|
||||
return object.__getattribute__(self, name)
|
||||
|
||||
on = name.rsplit('_', 1)[1]
|
||||
|
||||
on_info = {}
|
||||
if on in ('failed', 'skipped'):
|
||||
on_info[on] = True
|
||||
|
||||
return partial(self._record_task_result, name, on_info)
|
||||
|
|
@ -17,7 +17,7 @@ DOCUMENTATION = '''
|
|||
- Ansible callback plugin for timing individual tasks and overall execution time.
|
||||
- "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"
|
||||
- "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)
|
||||
- Before 2.4 only the environment variables were available for configuration.
|
||||
requirements:
|
||||
|
|
|
|||
|
|
@ -16,3 +16,5 @@ __metaclass__ = type
|
|||
# from ansible.module_utils.compat.version import LooseVersion
|
||||
|
||||
from ._version import LooseVersion, StrictVersion
|
||||
|
||||
__all__ = ['LooseVersion', 'StrictVersion']
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ options:
|
|||
- Name of a service to add/remove to/from firewalld.
|
||||
- The service must be listed in output of firewall-cmd --get-services.
|
||||
type: str
|
||||
protocol:
|
||||
description:
|
||||
- Name of a protocol to add/remove to/from firewalld.
|
||||
type: str
|
||||
port:
|
||||
description:
|
||||
- Name of a port or port range to add/remove to/from firewalld.
|
||||
|
|
@ -144,6 +148,12 @@ EXAMPLES = r'''
|
|||
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
|
||||
|
|
@ -343,6 +353,47 @@ class ServiceTransaction(FirewallTransaction):
|
|||
self.update_fw_settings(fw_zone, fw_settings)
|
||||
|
||||
|
||||
class ProtocolTransaction(FirewallTransaction):
|
||||
"""
|
||||
ProtocolTransaction
|
||||
"""
|
||||
|
||||
def __init__(self, module, action_args=None, zone=None, desired_state=None, permanent=False, immediate=False):
|
||||
super(ProtocolTransaction, self).__init__(
|
||||
module, action_args=action_args, desired_state=desired_state, zone=zone, permanent=permanent, immediate=immediate
|
||||
)
|
||||
|
||||
def get_enabled_immediate(self, protocol, timeout):
|
||||
if protocol in self.fw.getProtocols(self.zone):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_enabled_permanent(self, protocol, timeout):
|
||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
||||
|
||||
if protocol in fw_settings.getProtocols():
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def set_enabled_immediate(self, protocol, timeout):
|
||||
self.fw.addProtocol(self.zone, protocol, timeout)
|
||||
|
||||
def set_enabled_permanent(self, protocol, timeout):
|
||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
||||
fw_settings.addProtocol(protocol)
|
||||
self.update_fw_settings(fw_zone, fw_settings)
|
||||
|
||||
def set_disabled_immediate(self, protocol, timeout):
|
||||
self.fw.removeProtocol(self.zone, protocol)
|
||||
|
||||
def set_disabled_permanent(self, protocol, timeout):
|
||||
fw_zone, fw_settings = self.get_fw_zone_settings()
|
||||
fw_settings.removeProtocol(protocol)
|
||||
self.update_fw_settings(fw_zone, fw_settings)
|
||||
|
||||
|
||||
class MasqueradeTransaction(FirewallTransaction):
|
||||
"""
|
||||
MasqueradeTransaction
|
||||
|
|
@ -469,6 +520,7 @@ class InterfaceTransaction(FirewallTransaction):
|
|||
old_zone_obj = self.fw.config.get_zone(zone)
|
||||
if interface in old_zone_obj.interfaces:
|
||||
iface_zone_objs.append(old_zone_obj)
|
||||
|
||||
if len(iface_zone_objs) > 1:
|
||||
# Even it shouldn't happen, it's actually possible that
|
||||
# the same interface is in several zone XML files
|
||||
|
|
@ -478,18 +530,17 @@ class InterfaceTransaction(FirewallTransaction):
|
|||
len(iface_zone_objs)
|
||||
)
|
||||
)
|
||||
old_zone_obj = iface_zone_objs[0]
|
||||
if old_zone_obj.name != self.zone:
|
||||
old_zone_settings = FirewallClientZoneSettings(
|
||||
self.fw.config.get_zone_config(old_zone_obj)
|
||||
)
|
||||
elif len(iface_zone_objs) == 1 and iface_zone_objs[0].name != self.zone:
|
||||
old_zone_obj = iface_zone_objs[0]
|
||||
old_zone_config = 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
|
||||
self.fw.config.set_zone_config(
|
||||
old_zone_obj,
|
||||
old_zone_settings.settings
|
||||
)
|
||||
fw_settings.addInterface(interface) # add to new
|
||||
self.fw.config.set_zone_config(fw_zone, fw_settings.settings)
|
||||
fw_settings.addInterface(interface) # add to new
|
||||
self.fw.config.set_zone_config(fw_zone, fw_settings.settings)
|
||||
else:
|
||||
old_zone_name = self.fw.config().getZoneOfInterface(interface)
|
||||
if old_zone_name != self.zone:
|
||||
|
|
@ -748,6 +799,7 @@ def main():
|
|||
icmp_block=dict(type='str'),
|
||||
icmp_block_inversion=dict(type='str'),
|
||||
service=dict(type='str'),
|
||||
protocol=dict(type='str'),
|
||||
port=dict(type='str'),
|
||||
port_forward=dict(type='list', elements='dict'),
|
||||
rich_rule=dict(type='str'),
|
||||
|
|
@ -769,7 +821,7 @@ def main():
|
|||
source=('permanent',),
|
||||
),
|
||||
mutually_exclusive=[
|
||||
['icmp_block', 'icmp_block_inversion', 'service', 'port', 'port_forward', 'rich_rule',
|
||||
['icmp_block', 'icmp_block_inversion', 'service', 'protocol', 'port', 'port_forward', 'rich_rule',
|
||||
'interface', 'masquerade', 'source', 'target']
|
||||
],
|
||||
)
|
||||
|
|
@ -798,20 +850,22 @@ def main():
|
|||
icmp_block = module.params['icmp_block']
|
||||
icmp_block_inversion = module.params['icmp_block_inversion']
|
||||
service = module.params['service']
|
||||
protocol = module.params['protocol']
|
||||
rich_rule = module.params['rich_rule']
|
||||
source = module.params['source']
|
||||
zone = module.params['zone']
|
||||
target = module.params['target']
|
||||
|
||||
port = None
|
||||
if module.params['port'] is not None:
|
||||
if '/' in module.params['port']:
|
||||
port, protocol = module.params['port'].strip().split('/')
|
||||
port, port_protocol = module.params['port'].strip().split('/')
|
||||
else:
|
||||
protocol = None
|
||||
if not protocol:
|
||||
port_protocol = None
|
||||
if not port_protocol:
|
||||
module.fail_json(msg='improper port format (missing protocol?)')
|
||||
else:
|
||||
port = None
|
||||
port_protocol = None
|
||||
|
||||
port_forward_toaddr = ''
|
||||
port_forward = None
|
||||
|
|
@ -829,7 +883,7 @@ def main():
|
|||
port_forward_toaddr = port_forward['toaddr']
|
||||
|
||||
modification = False
|
||||
if any([icmp_block, icmp_block_inversion, service, port, port_forward, rich_rule,
|
||||
if any([icmp_block, icmp_block_inversion, service, protocol, port, port_forward, rich_rule,
|
||||
interface, masquerade, source, target]):
|
||||
modification = True
|
||||
if modification and desired_state in ['absent', 'present'] and target is None:
|
||||
|
|
@ -854,12 +908,21 @@ def main():
|
|||
msgs.append("Changed icmp-block %s to %s" % (icmp_block, desired_state))
|
||||
|
||||
if icmp_block_inversion is not None:
|
||||
# Type of icmp_block_inversion will be changed to boolean in a future release.
|
||||
icmp_block_inversion_status = True
|
||||
try:
|
||||
icmp_block_inversion_status = boolean(icmp_block_inversion, True)
|
||||
except TypeError:
|
||||
module.warn('The value of the icmp_block_inversion option is "%s". '
|
||||
'The type of the option will be changed from string to boolean in a future release. '
|
||||
'To avoid unexpected behavior, please change the value to boolean.' % icmp_block_inversion)
|
||||
expected_state = 'enabled' if (desired_state == 'enabled') == icmp_block_inversion_status else 'disabled'
|
||||
|
||||
transaction = IcmpBlockInversionTransaction(
|
||||
module,
|
||||
action_args=(),
|
||||
zone=zone,
|
||||
desired_state=desired_state,
|
||||
desired_state=expected_state,
|
||||
permanent=permanent,
|
||||
immediate=immediate,
|
||||
)
|
||||
|
|
@ -869,14 +932,6 @@ def main():
|
|||
if changed is True:
|
||||
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:
|
||||
|
||||
transaction = ServiceTransaction(
|
||||
|
|
@ -893,6 +948,22 @@ def main():
|
|||
if changed is True:
|
||||
msgs.append("Changed service %s to %s" % (service, desired_state))
|
||||
|
||||
if protocol is not None:
|
||||
|
||||
transaction = ProtocolTransaction(
|
||||
module,
|
||||
action_args=(protocol, timeout),
|
||||
zone=zone,
|
||||
desired_state=desired_state,
|
||||
permanent=permanent,
|
||||
immediate=immediate,
|
||||
)
|
||||
|
||||
changed, transaction_msgs = transaction.run()
|
||||
msgs = msgs + transaction_msgs
|
||||
if changed is True:
|
||||
msgs.append("Changed protocol %s to %s" % (protocol, desired_state))
|
||||
|
||||
if source is not None:
|
||||
|
||||
transaction = SourceTransaction(
|
||||
|
|
@ -911,7 +982,7 @@ def main():
|
|||
|
||||
transaction = PortTransaction(
|
||||
module,
|
||||
action_args=(port, protocol, timeout),
|
||||
action_args=(port, port_protocol, timeout),
|
||||
zone=zone,
|
||||
desired_state=desired_state,
|
||||
permanent=permanent,
|
||||
|
|
@ -923,7 +994,7 @@ def main():
|
|||
if changed is True:
|
||||
msgs.append(
|
||||
"Changed port %s to %s" % (
|
||||
"%s/%s" % (port, protocol), desired_state
|
||||
"%s/%s" % (port, port_protocol), desired_state
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -981,12 +1052,21 @@ def main():
|
|||
msgs = msgs + transaction_msgs
|
||||
|
||||
if masquerade is not None:
|
||||
# Type of masquerade will be changed to boolean in a future release.
|
||||
masquerade_status = True
|
||||
try:
|
||||
masquerade_status = boolean(masquerade, True)
|
||||
except TypeError:
|
||||
module.warn('The value of the masquerade option is "%s". '
|
||||
'The type of the option will be changed from string to boolean in a future release. '
|
||||
'To avoid unexpected behavior, please change the value to boolean.' % masquerade)
|
||||
|
||||
expected_state = 'enabled' if (desired_state == 'enabled') == masquerade_status else 'disabled'
|
||||
transaction = MasqueradeTransaction(
|
||||
module,
|
||||
action_args=(),
|
||||
zone=zone,
|
||||
desired_state=desired_state,
|
||||
desired_state=expected_state,
|
||||
permanent=permanent,
|
||||
immediate=immediate,
|
||||
)
|
||||
|
|
@ -994,14 +1074,6 @@ def main():
|
|||
changed, transaction_msgs = transaction.run()
|
||||
msgs = msgs + transaction_msgs
|
||||
|
||||
# Type of masquerade will be changed to boolean in a future release.
|
||||
try:
|
||||
boolean(masquerade, True)
|
||||
except TypeError:
|
||||
module.warn('The value of the masquerade option is "%s". '
|
||||
'The type of the option will be changed from string to boolean in a future release. '
|
||||
'To avoid unexpected behavior, please change the value to boolean.' % masquerade)
|
||||
|
||||
if target is not None:
|
||||
|
||||
transaction = ZoneTargetTransaction(
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ EXAMPLES = r'''
|
|||
- 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:
|
||||
|
|
@ -44,6 +49,7 @@ EXAMPLES = r'''
|
|||
- public
|
||||
- external
|
||||
- internal
|
||||
register: result
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
|
|
@ -78,7 +84,7 @@ firewalld_info:
|
|||
returned: success
|
||||
type: str
|
||||
sample: 0.8.2
|
||||
default_zones:
|
||||
default_zone:
|
||||
description:
|
||||
- The zone name of default zone.
|
||||
returned: success
|
||||
|
|
@ -204,7 +210,6 @@ firewalld_info:
|
|||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.six import raise_from
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible_collections.ansible.posix.plugins.module_utils.version import StrictVersion
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ def main():
|
|||
if os.path.exists("/run/ostree-booted"):
|
||||
ansible_facts['pkg_mgr'] = 'ansible.posix.rhel_rpm_ostree'
|
||||
|
||||
module.exit_json(ansible_facts, changed=False)
|
||||
module.exit_json(ansible_facts=ansible_facts, changed=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
3
tests/integration/requirements.yml
Normal file
3
tests/integration/requirements.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
collections:
|
||||
- community.general
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
- block:
|
||||
|
||||
- include: acl.yml
|
||||
- include_tasks: acl.yml
|
||||
when: ansible_system == 'Linux' # TODO enable acls mount option on FreeBSD to test it there too
|
||||
|
||||
always:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,172 @@
|
|||
# Test playbook for the firewalld module - icmp block inversion operations
|
||||
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Icmp block inversion enabled when icmp block inversion is truthy and state is enabled
|
||||
block:
|
||||
- name: Testing enable icmp block inversion
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: yes
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is enabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing enable icmp block inversion (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: yes
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is enabled (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Icmp block inversion disabled when icmp block inversion is falsy and state is enabled
|
||||
block:
|
||||
- name: Testing disable icmp block inversion
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: no
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is disabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing disable icmp block inversion (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: no
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is disabled (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Icmp block inversion enabled when icmp block inversion is falsy and state is disabled
|
||||
block:
|
||||
- name: Testing enable icmp block inversion
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: no
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is enabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing enable icmp block inversion (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: no
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is enabled (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Icmp block inversion disabled when icmp block inversion is truthy and state is disabled
|
||||
block:
|
||||
- name: Testing disable icmp block inversion
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: yes
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is disabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing disable icmp block inversion (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: yes
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is disabled (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
# Validate backwards compatible behavior until icmp block inversion is switched from string to boolean type
|
||||
- name: Icmp block inversion enabled when icmp block inversion is non-boolean string and state is enabled
|
||||
block:
|
||||
- name: Testing enable icmp block inversion
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: 'some string'
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is enabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing enable icmp block inversion (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: 'some string'
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is enabled (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Icmp block inversion disabled when icmp block inversion is non-boolean string and state is disabled
|
||||
block:
|
||||
- name: Testing disable icmp block inversion
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: 'some string'
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is disabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing disable icmp block inversion (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
icmp_block_inversion: 'some string'
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert icmp block inversion is disabled (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
# Test playbook for the firewalld module - interface operations
|
||||
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Validate adding interface
|
||||
block:
|
||||
- name: Add lo interface to trusted zone
|
||||
ansible.posix.firewalld:
|
||||
interface: lo
|
||||
zone: trusted
|
||||
permanent: Yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert lo was added to trusted zone
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Add lo interface to trusted zone (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
interface: lo
|
||||
zone: trusted
|
||||
permanent: Yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert lo was added to trusted zone (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Validate moving interfaces
|
||||
block:
|
||||
- name: Move lo interface from trusted zone to internal zone
|
||||
ansible.posix.firewalld:
|
||||
interface: lo
|
||||
zone: internal
|
||||
permanent: Yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: Assert lo was moved from trusted zone to internal zone
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Move lo interface from trusted zone to internal zone (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
interface: lo
|
||||
zone: internal
|
||||
permanent: Yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert lo was moved from trusted zone to internal zone (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Validate removing interface
|
||||
block:
|
||||
- name: Remove lo interface from internal zone
|
||||
ansible.posix.firewalld:
|
||||
interface: lo
|
||||
zone: internal
|
||||
permanent: Yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: Assert lo interface was removed from internal zone
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Remove lo interface from internal zone (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
interface: lo
|
||||
zone: internal
|
||||
permanent: Yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: Assert lo interface was removed from internal zone (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
# Test playbook for the firewalld module - masquerade operations
|
||||
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- name: Masquerade enabled when masquerade is truthy and state is enabled
|
||||
block:
|
||||
- name: Testing enable masquerade
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
masquerade: yes
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is enabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing enable masquerade (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
masquerade: yes
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is enabled (verify not changed)
|
||||
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: no
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is disabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing disable masquerade (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
masquerade: no
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is disabled (verify not changed)
|
||||
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: no
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is enabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing enable masquerade (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
masquerade: no
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is enabled (verify not changed)
|
||||
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: yes
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is disabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing disable masquerade (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
masquerade: yes
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is disabled (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
# Validate backwards compatible behavior until masquerade is switched from string to boolean type
|
||||
- name: Masquerade enabled when masquerade is non-boolean string and state is enabled
|
||||
block:
|
||||
- name: Testing enable masquerade
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
masquerade: 'some string'
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is enabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing enable masquerade (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
masquerade: 'some string'
|
||||
permanent: yes
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is enabled (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Masquerade disabled when masquerade is non-boolean string and state is disabled
|
||||
block:
|
||||
- name: Testing disable masquerade
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
masquerade: 'some string'
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is disabled
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Testing disable masquerade (verify not changed)
|
||||
ansible.posix.firewalld:
|
||||
zone: trusted
|
||||
masquerade: 'some string'
|
||||
permanent: yes
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert masquerade is disabled (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
# Test playbook for the firewalld module - protocol operations
|
||||
# (c) 2022, Robért S. Guhr <rguhr@cronon.net>
|
||||
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- name: firewalld protocol test permanent enabled
|
||||
firewalld:
|
||||
protocol: ospf
|
||||
permanent: true
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert firewalld protocol test permanent enabled worked
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: firewalld protocol test permanent enabled rerun (verify not changed)
|
||||
firewalld:
|
||||
protocol: ospf
|
||||
permanent: true
|
||||
state: enabled
|
||||
register: result
|
||||
|
||||
- name: assert firewalld protocol test permanent enabled rerun worked (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: firewalld protocol test permanent disabled
|
||||
firewalld:
|
||||
protocol: ospf
|
||||
permanent: true
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert firewalld protocol test permanent disabled worked
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: firewalld protocol test permanent disabled rerun (verify not changed)
|
||||
firewalld:
|
||||
protocol: ospf
|
||||
permanent: true
|
||||
state: disabled
|
||||
register: result
|
||||
|
||||
- name: assert firewalld protocol test permanent disabled rerun worked (verify not changed)
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
|
@ -10,6 +10,9 @@
|
|||
# firewalld service operation test cases
|
||||
- include_tasks: service_test_cases.yml
|
||||
|
||||
# firewalld protocol operation test cases
|
||||
- include_tasks: protocol_test_cases.yml
|
||||
|
||||
# firewalld port operation test cases
|
||||
- include_tasks: port_test_cases.yml
|
||||
|
||||
|
|
@ -24,3 +27,12 @@
|
|||
|
||||
# firewalld port forwarding operation test cases
|
||||
- include_tasks: port_forward_test_cases.yml
|
||||
|
||||
# firewalld masquerade operation test cases
|
||||
- include_tasks: masquerade_test_cases.yml
|
||||
|
||||
# firewalld icmp block inversion operation test cases
|
||||
- include_tasks: icmp_block_inversion_test_cases.yml
|
||||
|
||||
# firewalld interface operation test cases
|
||||
- include_tasks: interface_test_cases.yml
|
||||
|
|
|
|||
|
|
@ -82,4 +82,4 @@
|
|||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
- "result.msg == 'parameters are mutually exclusive: icmp_block|icmp_block_inversion|service|port|port_forward|rich_rule|interface|masquerade|source|target'"
|
||||
- "result.msg == 'parameters are mutually exclusive: icmp_block|icmp_block_inversion|service|protocol|port|port_forward|rich_rule|interface|masquerade|source|target'"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
- include: seboolean.yml
|
||||
- include_tasks: seboolean.yml
|
||||
when:
|
||||
- ansible_selinux is defined
|
||||
- ansible_selinux != False
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@
|
|||
msg: SELinux is {{ ansible_selinux.status }}
|
||||
when: ansible_selinux is defined and ansible_selinux != False
|
||||
|
||||
- include: selinux.yml
|
||||
- include_tasks: selinux.yml
|
||||
when:
|
||||
- ansible_selinux is defined
|
||||
- ansible_selinux != False
|
||||
- ansible_selinux.status == 'enabled'
|
||||
|
||||
- include: selogin.yml
|
||||
- include_tasks: selogin.yml
|
||||
when:
|
||||
- ansible_selinux is defined
|
||||
- ansible_selinux != False
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@
|
|||
|
||||
- name: Try sysctl with no name
|
||||
sysctl:
|
||||
name:
|
||||
name: ""
|
||||
value: 1
|
||||
sysctl_set: yes
|
||||
ignore_errors: True
|
||||
|
|
@ -180,7 +180,7 @@
|
|||
assert:
|
||||
that:
|
||||
- sysctl_no_name is failed
|
||||
- "sysctl_no_name.msg == 'name cannot be None'"
|
||||
- "sysctl_no_name.msg == 'name cannot be blank'"
|
||||
|
||||
- name: Try sysctl with no value
|
||||
sysctl:
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
integration_tests_dependencies:
|
||||
- community.general
|
||||
unit_tests_dependencies:
|
||||
- community.general
|
||||
5
tests/sanity/ignore-2.16.txt
Normal file
5
tests/sanity/ignore-2.16.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
plugins/modules/synchronize.py use-argspec-type-path
|
||||
plugins/modules/synchronize.py validate-modules:doc-default-does-not-match-spec
|
||||
plugins/modules/synchronize.py validate-modules:nonexistent-parameter-documented
|
||||
plugins/modules/synchronize.py validate-modules:parameter-type-not-in-doc
|
||||
plugins/modules/synchronize.py validate-modules:undocumented-parameter
|
||||
|
|
@ -31,3 +31,4 @@ except ImportError:
|
|||
BUILTINS = 'builtins'
|
||||
else:
|
||||
BUILTINS = '__builtin__'
|
||||
__all__ = ['__builtin__']
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import os
|
|||
import unittest
|
||||
import yaml
|
||||
|
||||
import ansible.plugins
|
||||
from ansible_collections.ansible.posix.tests.unit.compat.mock import patch, MagicMock
|
||||
from ansible_collections.ansible.posix.plugins.action.synchronize import ActionModule
|
||||
|
||||
|
|
|
|||
3
tests/unit/requirements.yml
Normal file
3
tests/unit/requirements.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
collections:
|
||||
- community.general
|
||||
|
|
@ -145,9 +145,7 @@ function cleanup
|
|||
fi
|
||||
|
||||
if [ "${process_coverage}" ]; then
|
||||
# use python 3.7 for coverage to avoid running out of memory during coverage xml processing
|
||||
# only use it for coverage to avoid the additional overhead of setting up a virtual environment for a potential no-op job
|
||||
virtualenv --python /usr/bin/python3.7 ~/ansible-venv
|
||||
python3 -m venv ~/ansible-venv
|
||||
set +ux
|
||||
. ~/ansible-venv/bin/activate
|
||||
set -ux
|
||||
|
|
|
|||
Loading…
Reference in a new issue