From 847417f03e145ae173639ee961e054ddffbbac4d Mon Sep 17 00:00:00 2001 From: David Bezuidenhout Date: Wed, 11 Mar 2015 16:04:00 +0200 Subject: [PATCH] [update] jinja brackets so that resulting output on xml files are better human readable --- firewalld/files/service.xml | 52 ++++++----- firewalld/files/zone.xml | 180 +++++++++++++++++++----------------- 2 files changed, 125 insertions(+), 107 deletions(-) diff --git a/firewalld/files/service.xml b/firewalld/files/service.xml index 38b4fe3..abca276 100644 --- a/firewalld/files/service.xml +++ b/firewalld/files/service.xml @@ -1,24 +1,34 @@ -{% if 'short' in service %}{{ service.short }}{% else %}{{ name }}{% endif %} -{% if 'description' in service %}{{ service.description }}{% endif %} -{% if 'ports' in service %} - {% if 'tcp' in service.ports %} - {% for v in service.ports.tcp %}{% endfor %} - {% endif %} - {% if 'udp' in service.ports %} - {% for v in service.ports.udp %}{% endfor %} - {% endif %} - {% if 'modules' in service %} - {% for v in service.modules %}{% endfor %} - {% endif %} -{% endif %} -{% if 'destinations' in service %} - {% if 'ipv4' in service.destinations %} - {% for v in service.destinations.ipv4 %}{% endfor %} - {% endif %} - {% if 'ipv6' in service.destinations %} - {% for v in service.destinations.ipv6 %}{% endfor %} - {% endif %} -{% endif %} + {%- if 'short' in service %}{{ service.short }}{%- else %}{{ name }}{%- endif %} + {%- if 'description' in service %}{{ service.description }}{%- endif %} +{%- if 'ports' in service %} +{%- if 'tcp' in service.ports %} + {%- for v in service.ports.tcp %} + + {%- endfor %} +{%- endif %} +{%- if 'udp' in service.ports %} + {%- for v in service.ports.udp %} + + {%- endfor %} +{%- endif %} +{%- if 'modules' in service %} + {%- for v in service.modules %} + + {%- endfor %} +{%- endif %} +{%- endif %} +{%- if 'destinations' in service %} + {%- if 'ipv4' in service.destinations %} + {%- for v in service.destinations.ipv4 %} + + {%- endfor %} + {%- endif %} + {%- if 'ipv6' in service.destinations %} + {%- for v in service.destinations.ipv6 %} + + %- endfor %} + {%- endif %} +{%- endif %} diff --git a/firewalld/files/zone.xml b/firewalld/files/zone.xml index 11043e7..3dadf2a 100644 --- a/firewalld/files/zone.xml +++ b/firewalld/files/zone.xml @@ -1,96 +1,104 @@ - -{% if 'short' in zone %}{{ zone.short }}{% else %}{{ name }}{% endif %} -{% if 'description' in zone %}{{ zone.description }}{% endif %} + + {% if 'short' in zone %}{{ zone.short }}{% else %}{{ name }}{% endif %} + {% if 'description' in zone %}{{ zone.description }}{% endif %} -{% if 'interfaces' in zone %} - {% for v in zone.interfaces %}{% endfor %} -{% endif %} -{% if 'sources' in zone %} - {% for v in zone.sources %}{% endfor %} -{% endif %} -{% if 'services' in zone %} - {% for v in zone.services %}{% endfor %} -{% endif %} -{% if 'ports' in zone %} - {% for v in zone.ports %} - {% if 'comment' in v %} - - {% endif %} - - {% endfor %} -{% endif %} -{% if 'icmp_blocks' in zone %} - {% for v in zone.icmp_blocks %}{% endfor %} -{% endif %} -{% if 'masquerade' in zone %}{% if zone.masquerade %}{% endif %}{% endif %} -{% if 'forward_ports' in zone %} - {% for v in zone.forward_ports %} - {% if 'comment' in v %} - - {% endif %} - - {% endfor %} -{% endif %} +{%- if 'interfaces' in zone %} + {%- for v in zone.interfaces %} + + {%- endfor %} +{%- endif %} +{%- if 'sources' in zone %} + {%- for v in zone.sources %} + + {%- endfor %} +{%- endif %} +{%- if 'services' in zone %} + {%- for v in zone.services %} + + {%- endfor %} +{%- endif %} +{%- if 'ports' in zone %} + {%- for v in zone.ports %} + {%- if 'comment' in v %} + + {%- endif %} + + {%- endfor %} +{%- endif %} +{%- if 'icmp_blocks' in zone %} + {%- for v in zone.icmp_blocks %} + + {%- endfor %} +{%- endif %} +{%- if 'masquerade' in zone %} + {%- if zone.masquerade %} + + {%- endif %} +{%- endif %} +{%- if 'forward_ports' in zone %} + {%- for v in zone.forward_ports %} + {%- if 'comment' in v %} + + {%- endif %} + + {%- endfor %} +{%- endif %} -{% if 'rich_rules' in zone %} - {% for rule in zone.rich_rules %} - {% if 'family' in rule %} - - {% else %} - - {% endif %} - {% if 'source' in rule %} - - {% endif %} - {% if 'destination' in rule %} - - {% endif %} - {% if 'service' in rule %} +{%- if 'rich_rules' in zone %} + {%- for rule in zone.rich_rules %} + {%- if 'family' in rule %} + + {%- else %} + + {%- endif %} + {%- if 'source' in rule %} + + {%- endif %} + {%- if 'destination' in rule %} + + {%- endif %} + {%- if 'service' in rule %} - {% endif %} - {% if 'port' in rule %} + {%- endif %} + {%- if 'port' in rule %} - {% endif %} - {% if 'protocol' in rule %} + {%- endif %} + {%- if 'protocol' in rule %} - {% endif %} - {% if 'icmp_block' in rule %} + {%- endif %} + {%- if 'icmp_block' in rule %} - {% endif %} - {% if 'masquerade' in rule %} - {% if rule.masquerade %}{% endif %} - {% endif %} - {% if 'forward_port' in rule %} - {% if 'comment' in rule.forward_port %} - - {% endif %} - - {% endif %} - {% if 'log' in rule %} - - {% if 'limit' in rule.log %} + {%- endif %} + {%- if 'masquerade' in rule %} + {%- if rule.masquerade %}{%- endif %} + {%- endif %} + {%- if 'forward_port' in rule %} + {%- if 'comment' in rule.forward_port %} + + {%- endif %} + + {%- endif %} + {%- if 'log' in rule %} + + {%- if 'limit' in rule.log %} - {% endif %} + {%- endif %} - {% endif %} - {% if 'audit' in rule %} - {% if 'limit' in rule.audit %} {% endif %} - {% endif %} - {% if 'accept' in rule %} - - {% endif %} - {% if 'reject' in rule %} - - {% endif %} - {% if 'drop' in rule %} - - {% endif %} - - {% endfor %} -{% endif %} - + {%- endif %} + {%- if 'audit' in rule %} + {%- if 'limit' in rule.audit %} {%- endif %} + {%- endif %} + {%- if 'accept' in rule %} + + {%- endif %} + {%- if 'reject' in rule %} + + {%- endif %} + {%- if 'drop' in rule %} + + {%- endif %} + + {%- endfor %} +{%- endif %} - - -