2014-08-23 16:44:48 +02:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2017-05-25 23:51:04 +02:00
|
|
|
<!--
|
|
|
|
This file is managed/generated by salt.
|
|
|
|
Do not edit this file manually, it will be overwritten!
|
|
|
|
Modify the salt pillar for firewalld instead
|
|
|
|
-->
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- macro rich_rule(rule) -%}
|
|
|
|
{%- if 'family' in rule %}
|
|
|
|
<rule family="{{ rule.family }}">
|
|
|
|
{%- else %}
|
|
|
|
<rule>
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'ipset' in rule %}
|
|
|
|
<source ipset="{{ rule.ipset.name }}" />
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'source' in rule %}
|
2021-04-25 02:04:24 +02:00
|
|
|
<source address="{{ rule.source.address }}" {%- if 'invert' in rule.source %} invert="{{ rule.source.invert }}"{%- endif %} />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'destination' in rule %}
|
2021-04-25 02:04:24 +02:00
|
|
|
<destination address="{{ rule.destination.address }}" {%- if 'invert' in rule.destination %} invert="{{ rule.destination.invert }}"{%- endif %} />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'service' in rule %}
|
|
|
|
<service name="{{ rule.service }}" />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'port' in rule %}
|
|
|
|
<port port="{{ rule.port.portid }}" protocol="{{ rule.port.protocol }}" />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'protocol' in rule %}
|
|
|
|
<protocol value="{{ rule.protocol }}" />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'icmp_block' in rule %}
|
|
|
|
<icmp-block name="{{ rule.icmp_block }}" />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'icmp_type' in rule %}
|
|
|
|
<icmp-type name="{{ rule.icmp_type }}" />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'masquerade' in rule %}
|
|
|
|
{%- if rule.masquerade %}<masquerade/>{%- endif %}
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'forward_port' in rule %}
|
|
|
|
{%- if 'comment' in rule.forward_port %}
|
|
|
|
<!-- {{ rule.forward_port.comment }} -->
|
|
|
|
{%- endif %}
|
|
|
|
<forward-port port="{{ rule.forward_port.portid }}" protocol="{{ rule.forward_port.protocol }}"{%- if 'to_port' in rule.forward_port %} to-port="{{ rule.forward_port.to_port }}"{%- endif %}{%- if 'to_addr' in rule.forward_port %} to-addr="{{ rule.forward_port.to_addr }}"{%- endif %} />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'source_port' in rule %}
|
|
|
|
{%- if 'comment' in rule.source_port %}
|
|
|
|
<!-- {{ rule.source_port.comment }} -->
|
|
|
|
{%- endif %}
|
|
|
|
<source-port port="{{ rule.source_port.portid }}" protocol="{{ rule.source_port.protocol }}"{%- if 'to_port' in rule.source_port %} to-port="{{ rule.source_port.to_port }}"{%- endif %}{%- if 'to_addr' in rule.source_port %} to-addr="{{ rule.source_port.to_addr }}"{%- endif %} />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'log' in rule %}
|
|
|
|
<log{%- if 'prefix' in rule.log %} prefix="{{ rule.log.prefix }}"{%- endif %}{%- if 'level' in rule.log %} level="{{ rule.log.level }}"{%- endif %}>
|
|
|
|
{%- if 'limit' in rule.log %}
|
|
|
|
<limit value="{{ rule.log.limit }}"/>
|
|
|
|
{%- endif %}
|
|
|
|
</log>
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'audit' in rule %}
|
|
|
|
<audit>{%- if 'limit' in rule.audit %} <limit value="{{ rule.audit.limit }}"/>{%- endif %}</audit>
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'accept' in rule %}
|
2021-01-13 14:59:29 +01:00
|
|
|
<accept>{%- if rule.accept is mapping and 'limit' in rule.accept %} <limit value="{{ rule.accept.limit }}"/>{%- endif %}</accept>
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'reject' in rule %}
|
2021-04-25 02:06:15 +02:00
|
|
|
<reject{%- if rule.reject is mapping and 'type' in rule.reject %} type="{{ rule.reject.type }}"{%- endif %} />
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{%- if 'drop' in rule %}
|
|
|
|
<drop/>
|
2020-04-01 19:41:42 +02:00
|
|
|
{%- endif %}
|
2020-04-01 19:00:58 +02:00
|
|
|
</rule>
|
|
|
|
{%- endmacro %}
|
2015-03-11 15:04:00 +01:00
|
|
|
<zone{%- if 'target' in zone %} target="{{ zone.target }}"{%- endif %}>
|
|
|
|
{% if 'short' in zone %}<short>{{ zone.short }}</short>{% else %}<short>{{ name }}</short>{% endif %}
|
|
|
|
{% if 'description' in zone %}<description>{{ zone.description }}</description>{% endif %}
|
2014-08-23 16:44:48 +02:00
|
|
|
|
2015-03-11 15:04:00 +01:00
|
|
|
{%- if 'interfaces' in zone %}
|
|
|
|
{%- for v in zone.interfaces %}
|
|
|
|
<interface name="{{ v }}" />
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'sources' in zone %}
|
|
|
|
{%- for v in zone.sources %}
|
2016-09-30 04:50:55 +02:00
|
|
|
{%- if 'comment' in v %}
|
|
|
|
<!-- {{ v.comment }} -->
|
|
|
|
<source address="{{ v.source }}" />
|
|
|
|
{%- else %}
|
2015-03-11 15:04:00 +01:00
|
|
|
<source address="{{ v }}" />
|
2016-09-30 04:50:55 +02:00
|
|
|
{%- endif %}
|
2015-03-11 15:04:00 +01:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2017-11-25 00:31:17 +01:00
|
|
|
{%- if 'ipsets' in zone %}
|
|
|
|
{%- for v in zone.ipsets %}
|
|
|
|
{%- if 'comment' in v %}
|
|
|
|
<!-- {{ v.comment }} -->
|
|
|
|
<source ipset="{{ v.ipset }}" />
|
|
|
|
{%- else %}
|
|
|
|
<source ipset="{{ v }}" />
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2020-02-11 15:10:45 +01:00
|
|
|
{%- for k,val in zone.items() %}
|
|
|
|
{%- if k.endswith("services") %}
|
|
|
|
{%- for v in val %}
|
2015-03-11 15:04:00 +01:00
|
|
|
<service name="{{ v }}" />
|
2020-02-11 15:10:45 +01:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
2015-03-11 15:04:00 +01:00
|
|
|
{%- if 'ports' in zone %}
|
|
|
|
{%- for v in zone.ports %}
|
|
|
|
{%- if 'comment' in v %}
|
|
|
|
<!-- {{ v.comment }} -->
|
|
|
|
{%- endif %}
|
2019-04-06 23:26:48 +02:00
|
|
|
<port port="{{ v.port }}" protocol="{{ v.protocol }}" />
|
2015-03-11 15:04:00 +01:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2019-04-05 21:04:30 +02:00
|
|
|
{%- if 'protocols' in zone %}
|
|
|
|
{%- for v in zone.protocols %}
|
|
|
|
<protocol value="{{ v }}" />
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-03-11 15:04:00 +01:00
|
|
|
{%- if 'icmp_blocks' in zone %}
|
|
|
|
{%- for v in zone.icmp_blocks %}
|
|
|
|
<icmp-block name="{{ v }}" />
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2019-11-08 16:37:31 +01:00
|
|
|
{%- if 'icmp_block_inversion' in zone and zone.icmp_block_inversion %}
|
|
|
|
<icmp-block-inversion />
|
2019-04-05 21:04:30 +02:00
|
|
|
{%- endif %}
|
2015-03-11 15:04:00 +01:00
|
|
|
{%- if 'masquerade' in zone %}
|
|
|
|
{%- if zone.masquerade %}
|
|
|
|
<masquerade/>
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'forward_ports' in zone %}
|
|
|
|
{%- for v in zone.forward_ports %}
|
|
|
|
{%- if 'comment' in v %}
|
|
|
|
<!-- {{ v.comment }} -->
|
|
|
|
{%- endif %}
|
|
|
|
<forward-port port="{{ v.portid }}" protocol="{{ v.protocol }}"{%- if 'to_port' in v %} to-port="{{ v.to_port }}"{%- endif %}{%- if 'to_addr' in v %} to-addr="{{ v.to_addr }}"{%- endif %} />
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2019-04-05 21:04:30 +02:00
|
|
|
{%- if 'source_ports' in zone %}
|
|
|
|
{%- for v in zone.source_ports %}
|
|
|
|
{%- if 'comment' in v %}
|
|
|
|
<!-- {{ v.comment }} -->
|
|
|
|
{%- endif %}
|
2019-04-06 23:26:48 +02:00
|
|
|
<source-port port="{{ v.port }}" protocol="{{ v.protocol }}" />
|
2019-04-05 21:04:30 +02:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2020-03-26 13:36:02 +01:00
|
|
|
{%- if 'rich_rules' in zone %}
|
|
|
|
{%- if zone.rich_rules is list %}
|
|
|
|
{%- set rich_rules = zone.rich_rules %}
|
|
|
|
{%- else %}
|
|
|
|
{%- set expanded_ipset_rules = [] %}
|
|
|
|
{%- for name,rule in zone.rich_rules|dictsort %}
|
|
|
|
{%- if 'ipsets' in rule %}
|
|
|
|
{%- for ipset in rule.ipsets %}
|
|
|
|
{%- set tmp_rule = {} %}
|
|
|
|
{%- set _dummy = tmp_rule.update(rule) %}
|
|
|
|
{%- set _dummy = tmp_rule.update({'ipset':{'name':ipset}}) %}
|
|
|
|
{%- set _dummy = expanded_ipset_rules.append(tmp_rule) %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- else %}
|
|
|
|
{%- set _dummy = expanded_ipset_rules.append(rule) %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- set rich_rules = [] %}
|
|
|
|
{%- for rule in expanded_ipset_rules %}
|
|
|
|
{%- if 'services' in rule %}
|
|
|
|
{%- for service in rule.services %}
|
|
|
|
{%- set tmp_rule = {} %}
|
|
|
|
{%- set _dummy = tmp_rule.update(rule) %}
|
|
|
|
{%- set _dummy = tmp_rule.update({'service':service}) %}
|
|
|
|
{%- set _dummy = rich_rules.append(tmp_rule) %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- else %}
|
|
|
|
{%- set _dummy = rich_rules.append(rule) %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- for rule in rich_rules %}
|
2020-04-01 19:00:58 +02:00
|
|
|
{{- rich_rule(rule) }}
|
2015-03-11 15:04:00 +01:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2014-08-23 16:44:48 +02:00
|
|
|
</zone>
|