Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make firewalld operations idempotent #173

Merged
merged 5 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions lemmy-almalinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
ansible.builtin.systemd:
name: nginx
state: reloaded

- name: Reload firewalld
codyro marked this conversation as resolved.
Show resolved Hide resolved
ansible.builtin.systemd:
name: firewalld
state: reloaded
vars:
lemmy_port: "{{ 32767 | random(start=1024) }}"
tasks:
Expand Down Expand Up @@ -98,21 +103,17 @@
tags:
- firewalld

# TODO: Use ansible.posix.firewalld
- name: Allow http/httpd traffic to public zone in firewalld
ansible.builtin.command: "firewall-cmd --zone=public --add-service={{ item }} --perm"
ansible.posix.firewalld:
service: "{{ item }}"
state: enabled
zone: public
permanent: true
immediate: true
loop:
- http
- https
when: "'firewalld.service' in ansible_facts.services and ansible_facts.services['firewalld.service'].state == 'running'"
changed_when: true
tags:
- firewalld

- name: Reload firewalld
ansible.builtin.command: firewall-cmd --reload
when: "'firewalld.service' in ansible_facts.services and ansible_facts.services['firewalld.service'].state == 'running'"
changed_when: true
tags:
- firewalld

Expand Down
3 changes: 3 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
collections:
- name: ansible.posix