Skip to content

Commit

Permalink
feat(zone.xml): allow more services definition inside zone
Browse files Browse the repository at this point in the history
Now multiple sections ending with `services` can be defined for each in pillar
and all of them will get merged into one service block in the zone. The goal is
to keep backward compatibility while allowing different services to be defined
in different pillars. So basically have various parts of the pillar affecting
the firewall without need to define everything centrally. Helpful for the
exceptions to the rules.
  • Loading branch information
miska committed Feb 11, 2020
1 parent 0b82e43 commit 8d0172f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions firewalld/files/zone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if 'services' in zone %}
{%- for v in zone.services %}
{%- for k,val in zone.items() %}
{%- if k.endswith("services") %}
{%- for v in val %}
<service name="{{ v }}" />
{%- endfor %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endfor %}
{%- if 'ports' in zone %}
{%- for v in zone.ports %}
{%- if 'comment' in v %}
Expand Down
4 changes: 3 additions & 1 deletion pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ firewalld:
are accepted.
services:
- http
- zabbixcustom
- https
- ssh
- salt-minion
# Anything in zone definition ending with services will get merged into services
other_services:
- zabbixcustom
protocols:
- igmp
rich_rules:
Expand Down

0 comments on commit 8d0172f

Please sign in to comment.