ansible.posix/plugins/modules
softwarefactory-project-zuul[bot] 8a07431bf8
Merge pull request #399 from gnfzdz/main
Updat ZoneTransaction to support operations when firewalld is offline

SUMMARY

Fixes #398 by checking the flag self.fw_offline and calling the offline specific APIs when the flag is true.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ansible.posix.firewalld
ADDITIONAL INFORMATION
When attempting to add or remove zones, the ansible.posix.firewalld module would always call APIs as if it was online.
Specifically, the ZoneTransaction class assumed that self.fw  was a FirewallClient, but when the daemon is offline, it is instead either a Firewall or Firewall_test based on the version of firewalld installed.
See #398  for additional background.

Sample task
- name: 'Zone example - Create new zone'
  ansible.posix.firewalld:
    zone: "example"
    state: "present"
    permanent: Yes
Before
The full traceback is:
  File "/tmp/ansible_ansible.posix.firewalld_payload_04lptorx/ansible_ansible.posix.firewalld_payload.zip/ansible_collections/ansible/posix/plugins/module_utils/firewalld.py", line 111, in action_handler
    return action_func(*action_func_args)
  File "/tmp/ansible_ansible.posix.firewalld_payload_04lptorx/ansible_ansible.posix.firewalld_payload.zip/ansible_collections/ansible/posix/plugins/modules/firewalld.py", line 678, in get_enabled_permanent
fatal: [boot]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "icmp_block": null,
            "icmp_block_inversion": null,
            "immediate": false,
            "interface": null,
            "masquerade": null,
            "offline": null,
            "permanent": true,
            "port": null,
            "port_forward": null,
            "rich_rule": null,
            "service": null,
            "source": null,
            "state": "present",
            "target": null,
            "timeout": 0,
            "zone": "example"
        }
    },
    "msg": "ERROR: Exception caught: 'FirewallConfig' object is not callable"
}

After
changed: [boot] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "icmp_block": null,
            "icmp_block_inversion": null,
            "immediate": false,
            "interface": null,
            "masquerade": null,
            "offline": null,
            "permanent": true,
            "port": null,
            "port_forward": null,
            "rich_rule": null,
            "service": null,
            "source": null,
            "state": "present",
            "target": null,
            "timeout": 0,
            "zone": "example"
        }
    },
    "msg": "Permanent operation, Added zone example, Changed zone example to present, (offline operation: only on-disk configs were altered)"

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
2023-02-03 14:12:50 +00:00
..
__init__.py Initial commit 2020-03-09 13:15:28 +00:00
acl.py Merge pull request #400 from vladislav-sharapov/fix-doc-boolean-values 2022-12-22 08:00:13 +00:00
at.py Fix boolean values in docs 2022-12-09 00:36:29 +04:00
authorized_key.py Fix boolean values in docs 2022-12-09 00:36:29 +04:00
firewalld.py Update ZoneTransaction to support adding/removing zones when firewalld is offline. 2023-01-17 13:29:18 -05:00
firewalld_info.py Fix boolean values in docs 2022-12-09 00:36:29 +04:00
mount.py Merge pull request #400 from vladislav-sharapov/fix-doc-boolean-values 2022-12-22 08:00:13 +00:00
patch.py Fix boolean values in docs 2022-12-09 00:36:29 +04:00
rhel_facts.py fixes based on feedback 2022-11-22 09:03:04 -06:00
rhel_rpm_ostree.py Update documented default value for rhel_rpm_ostree's name parameter to match implementation. 2022-12-13 11:48:39 -05:00
rpm_ostree_upgrade.py fixes based on feedback 2022-11-22 09:03:04 -06:00
seboolean.py Fix boolean values in docs 2022-12-09 00:36:29 +04:00
selinux.py Fix boolean values in docs 2022-12-09 00:36:29 +04:00
synchronize.py Fix broken seealso in synchronize module 2023-01-30 22:07:10 +01:00
sysctl.py Fix boolean values in docs 2022-12-09 00:36:29 +04:00