Skip to content

Commit

Permalink
feat(zones): add purging option
Browse files Browse the repository at this point in the history
This introduces a "purge_zones" toggle which, if enabled, ensures
zones not managed using the firewalld pillar get deleted.
Useful to enforce that only Salt managed zones exist and to clean
up pre-Salt data.

Signed-off-by: Georg Pfuetzenreuter <[email protected]>
  • Loading branch information
tacerus committed Feb 7, 2024
1 parent cc7d05a commit 9373db5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions firewalld/zones.sls
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,16 @@ directory_firewalld_zones:
zone: {{ v|json }}
{% endfor %}
{%- if firewalld.get('purge_zones', False) %}
{%- for file in salt['file.find']('/etc/firewalld/zones', name='*.xml', print='name', type='f') %}
{%- if file.replace('.xml', '') not in firewalld.get('zones', {}).keys() %}
/etc/firewalld/zones/{{ file }}:
file.absent:
- watch_in:
- cmd: reload_firewalld
{%- endif %}
{%- endfor %}
{%- endif %}
3 changes: 3 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ firewalld:
entries:
- 2a01::1

# Delete zones not defined under "zones"
purge_zones: False

zones:
public:
short: Public
Expand Down

0 comments on commit 9373db5

Please sign in to comment.