Update cockpit task to use the posix collection firewalld module, which
greatly simplifies this task. I also opted to reload the firewall as a handler. Since there is a new requirement for the posix collection, the galaxy.yml, requirements.yml, and README.md are also all updated. I have to credit Qwen3.8-27B for this, I only worked on the task and handler, but asked it for review and it noted the missing requirements. Assisted-by: Qwen3.8-27B-GGUF-UD-Q4_K_XL
This commit is contained in:
parent
fac3bb33f3
commit
d694be0a07
5 changed files with 21 additions and 19 deletions
|
|
@ -12,6 +12,7 @@ tags:
|
|||
- infrastructure
|
||||
dependencies:
|
||||
community.general: ">=1.0.0"
|
||||
ansible.posix: ">=1.0.0"
|
||||
repository: https://forge.fedoraproject.org/server/ansible-support
|
||||
build_ignore:
|
||||
- .git
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
---
|
||||
collections:
|
||||
- name: community.general
|
||||
- name: ansible.posix
|
||||
|
|
|
|||
|
|
@ -10,8 +10,9 @@ fully qualified collection name (FQCN): `fedoraserver.general.postinstall`.
|
|||
Requirements
|
||||
------------
|
||||
|
||||
This role requires Ansible 2.15 or later and the `community.general` collection. Installing this
|
||||
collection pulls in that dependency automatically. It is designed for Fedora Server systems.
|
||||
This role requires Ansible 2.15 or later and the `community.general` and `ansible.posix`
|
||||
collections. Installing this collection pulls in those dependencies automatically. It is designed
|
||||
for Fedora Server systems.
|
||||
|
||||
Role tasks and Boolean values
|
||||
-----------------------------
|
||||
|
|
@ -76,6 +77,7 @@ This role relies on standard Ansible modules such as:
|
|||
- `community.general.timezone` for timezone configuration
|
||||
- `ansible.builtin.package` for package management
|
||||
- `ansible.builtin.service` for service management
|
||||
- `ansible.posix.firewalld` for firewall configuration
|
||||
|
||||
Example playbook
|
||||
----------------
|
||||
|
|
|
|||
|
|
@ -12,3 +12,7 @@
|
|||
- ansible_facts['os_family'] != 'AIX'
|
||||
- ansible_facts['os_family'] != 'OpenWrt'
|
||||
listen: sshd_reload
|
||||
|
||||
- name: Reload firewalld
|
||||
ansible.posix.firewalld:
|
||||
state: reloaded
|
||||
|
|
|
|||
|
|
@ -1,19 +1,13 @@
|
|||
---
|
||||
# Remove the cockpit service from the permanent firewalld configuration
|
||||
# Remove the cockpit service from the permanent firewalld configuration.
|
||||
# Access Cockpit afterwards via an SSH tunnel, a Cockpit proxy, or by
|
||||
# re-adding the service on an ad hoc basis.
|
||||
# The firewalld module is a no-op (and no reload) if the cockpit service
|
||||
# is not present in the permanent configuration.
|
||||
|
||||
- name: Check if the cockpit service is defined in firewalld
|
||||
ansible.builtin.command:
|
||||
cmd: firewall-cmd --permanent --query-service=cockpit
|
||||
register: cockpit_firewalld_check
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- name: Remove the cockpit service from firewalld
|
||||
ansible.builtin.command:
|
||||
cmd: firewall-cmd --permanent --remove-service=cockpit
|
||||
when: cockpit_firewalld_check.rc == 0
|
||||
|
||||
- name: Reload firewalld to apply changes
|
||||
ansible.builtin.command:
|
||||
cmd: firewall-cmd --reload
|
||||
when: cockpit_firewalld_check.rc == 0
|
||||
- name: Remove the cockpit service from the firewalld permanent configuration
|
||||
ansible.posix.firewalld:
|
||||
service: cockpit
|
||||
permanent: true
|
||||
state: disabled
|
||||
notify: Reload firewalld
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue