Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Fixed ansible-lint problems
Browse files Browse the repository at this point in the history
  • Loading branch information
dmotte committed Jul 20, 2023
1 parent 67a950c commit 2810e35
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
---
strict: true
exclude_paths:
- .github/
8 changes: 4 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
# Content for the /etc/iptables/rules.v4 file. If set to empty string, that file
# won't be created
rules_v4: ""
iptables_rules_v4: ""

# Content for the /etc/iptables/rules.v6 file. If set to empty string, that file
# won't be created
rules_v6: ""
iptables_rules_v6: ""

# Whether or not to reload the iptables rules if changed
reload_rules_if_changed: true
iptables_rules_reload_if_changed: true

# List of services that must be restarted if the iptables rules change
restart_services: []
iptables_rules_restart_services: []
8 changes: 4 additions & 4 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Iptables IPv4 reset
when: reload_rules_if_changed
when: iptables_rules_reload_if_changed
block:
- name: Set the iptables policy for the filter:INPUT chain to ACCEPT
ansible.builtin.iptables:
Expand Down Expand Up @@ -36,7 +36,7 @@
listen: Reload iptables rules and restart services

- name: Iptables IPv6 reset
when: reload_rules_if_changed
when: iptables_rules_reload_if_changed
block:
- name: Set the iptables IPv6 policy for the filter:INPUT chain to ACCEPT
ansible.builtin.iptables:
Expand Down Expand Up @@ -81,11 +81,11 @@
name: netfilter-persistent
state: restarted
listen: Reload iptables rules and restart services
when: reload_rules_if_changed
when: iptables_rules_reload_if_changed

- name: Restart other services
ansible.builtin.service:
name: "{{ item }}"
state: restarted
loop: "{{ restart_services }}"
loop: "{{ iptables_rules_restart_services }}"
listen: Reload iptables rules and restart services
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
src: rules_v4.j2
dest: /etc/iptables/rules.v4
mode: "0644"
when: rules_v4 != ""
when: iptables_rules_v4 != ""
notify: Reload iptables rules and restart services

- name: Create the rules.v6 file
ansible.builtin.template:
src: rules_v6.j2
dest: /etc/iptables/rules.v6
mode: "0644"
when: rules_v6 != ""
when: iptables_rules_v6 != ""
notify: Reload iptables rules and restart services

- name: Force all notified handlers to run at this point
Expand Down
2 changes: 1 addition & 1 deletion templates/rules_v4.j2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ rules_v4 | regex_replace('\r\n', '\n') }}
{{ iptables_rules_v4 | regex_replace('\r\n', '\n') }}
2 changes: 1 addition & 1 deletion templates/rules_v6.j2
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ rules_v6 | regex_replace('\r\n', '\n') }}
{{ iptables_rules_v6 | regex_replace('\r\n', '\n') }}
8 changes: 4 additions & 4 deletions test/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
tasks:
- name: Include the role from the parent directory
ansible.builtin.include_role: { name: "{{ playbook_dir | dirname }}" }
vars:
vars: # noqa: var-naming[no-role-prefix]
ansible_become: true
rules_v4: "{{ lookup('ansible.builtin.file', 'rules.v4') }}"
reload_rules_if_changed: false
restart_services: [docker]
iptables_rules_v4: "{{ lookup('ansible.builtin.file', 'rules.v4') }}"
iptables_rules_reload_if_changed: false
iptables_rules_restart_services: [docker]

0 comments on commit 2810e35

Please sign in to comment.