Saltstack Official FirewallD Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
5.3KB

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. This file is managed/generated by salt.
  4. Do not edit this file manually, it will be overwritten!
  5. Modify the salt pillar for firewalld instead
  6. -->
  7. <zone{%- if 'target' in zone %} target="{{ zone.target }}"{%- endif %}>
  8. {% if 'short' in zone %}<short>{{ zone.short }}</short>{% else %}<short>{{ name }}</short>{% endif %}
  9. {% if 'description' in zone %}<description>{{ zone.description }}</description>{% endif %}
  10. {%- if 'interfaces' in zone %}
  11. {%- for v in zone.interfaces %}
  12. <interface name="{{ v }}" />
  13. {%- endfor %}
  14. {%- endif %}
  15. {%- if 'sources' in zone %}
  16. {%- for v in zone.sources %}
  17. {%- if 'comment' in v %}
  18. <!-- {{ v.comment }} -->
  19. <source address="{{ v.source }}" />
  20. {%- else %}
  21. <source address="{{ v }}" />
  22. {%- endif %}
  23. {%- endfor %}
  24. {%- endif %}
  25. {%- if 'ipsets' in zone %}
  26. {%- for v in zone.ipsets %}
  27. {%- if 'comment' in v %}
  28. <!-- {{ v.comment }} -->
  29. <source ipset="{{ v.ipset }}" />
  30. {%- else %}
  31. <source ipset="{{ v }}" />
  32. {%- endif %}
  33. {%- endfor %}
  34. {%- endif %}
  35. {%- for k,val in zone.items() %}
  36. {%- if k.endswith("services") %}
  37. {%- for v in val %}
  38. <service name="{{ v }}" />
  39. {%- endfor %}
  40. {%- endif %}
  41. {%- endfor %}
  42. {%- if 'ports' in zone %}
  43. {%- for v in zone.ports %}
  44. {%- if 'comment' in v %}
  45. <!-- {{ v.comment }} -->
  46. {%- endif %}
  47. <port port="{{ v.port }}" protocol="{{ v.protocol }}" />
  48. {%- endfor %}
  49. {%- endif %}
  50. {%- if 'protocols' in zone %}
  51. {%- for v in zone.protocols %}
  52. <protocol value="{{ v }}" />
  53. {%- endfor %}
  54. {%- endif %}
  55. {%- if 'icmp_blocks' in zone %}
  56. {%- for v in zone.icmp_blocks %}
  57. <icmp-block name="{{ v }}" />
  58. {%- endfor %}
  59. {%- endif %}
  60. {%- if 'icmp_block_inversion' in zone and zone.icmp_block_inversion %}
  61. <icmp-block-inversion />
  62. {%- endif %}
  63. {%- if 'masquerade' in zone %}
  64. {%- if zone.masquerade %}
  65. <masquerade/>
  66. {%- endif %}
  67. {%- endif %}
  68. {%- if 'forward_ports' in zone %}
  69. {%- for v in zone.forward_ports %}
  70. {%- if 'comment' in v %}
  71. <!-- {{ v.comment }} -->
  72. {%- endif %}
  73. <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 %} />
  74. {%- endfor %}
  75. {%- endif %}
  76. {%- if 'source_ports' in zone %}
  77. {%- for v in zone.source_ports %}
  78. {%- if 'comment' in v %}
  79. <!-- {{ v.comment }} -->
  80. {%- endif %}
  81. <source-port port="{{ v.port }}" protocol="{{ v.protocol }}" />
  82. {%- endfor %}
  83. {%- endif %}
  84. {%- if 'rich_rules' in zone %}
  85. {%- for rule in zone.rich_rules %}
  86. {%- if 'family' in rule %}
  87. <rule family="{{ rule.family }}">
  88. {%- else %}
  89. <rule>
  90. {%- endif %}
  91. {%- if 'ipset' in rule %}
  92. <source ipset="{{ rule.ipset.name }}" />
  93. {%- endif %}
  94. {%- if 'source' in rule %}
  95. <source address="{{ rule.source.address }}" {%- if 'invert' in rule.source %}invert="{{ rule.source.invert }}"{%- endif %} />
  96. {%- endif %}
  97. {%- if 'destination' in rule %}
  98. <destination address="{{ rule.destination.address }}" {%- if 'invert' in rule.destination %}invert="{{ rule.destination.invert }}"{%- endif %} />
  99. {%- endif %}
  100. {%- if 'service' in rule %}
  101. <service name="{{ rule.service }}" />
  102. {%- endif %}
  103. {%- if 'port' in rule %}
  104. <port port="{{ rule.port.portid }}" protocol="{{ rule.port.protocol }}" />
  105. {%- endif %}
  106. {%- if 'protocol' in rule %}
  107. <protocol value="{{ rule.protocol }}" />
  108. {%- endif %}
  109. {%- if 'icmp_block' in rule %}
  110. <icmp-block name="{{ rule.icmp_block }}" />
  111. {%- endif %}
  112. {%- if 'icmp_type' in rule %}
  113. <icmp-type name="{{ rule.icmp_type }}" />
  114. {%- endif %}
  115. {%- if 'masquerade' in rule %}
  116. {%- if rule.masquerade %}<masquerade/>{%- endif %}
  117. {%- endif %}
  118. {%- if 'forward_port' in rule %}
  119. {%- if 'comment' in rule.forward_port %}
  120. <!-- {{ rule.forward_port.comment }} -->
  121. {%- endif %}
  122. <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 %} />
  123. {%- endif %}
  124. {%- if 'source_port' in rule %}
  125. {%- if 'comment' in rule.source_port %}
  126. <!-- {{ rule.source_port.comment }} -->
  127. {%- endif %}
  128. <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 %} />
  129. {%- endif %}
  130. {%- if 'log' in rule %}
  131. <log{%- if 'prefix' in rule.log %} prefix="{{ rule.log.prefix }}"{%- endif %}{%- if 'level' in rule.log %} level="{{ rule.log.level }}"{%- endif %}>
  132. {%- if 'limit' in rule.log %}
  133. <limit value="{{ rule.log.limit }}"/>
  134. {%- endif %}
  135. </log>
  136. {%- endif %}
  137. {%- if 'audit' in rule %}
  138. <audit>{%- if 'limit' in rule.audit %} <limit value="{{ rule.audit.limit }}"/>{%- endif %}</audit>
  139. {%- endif %}
  140. {%- if 'accept' in rule %}
  141. <accept/>
  142. {%- endif %}
  143. {%- if 'reject' in rule %}
  144. <reject{%- if 'type' in rule.reject %} type="{{ rule.reject.type }}"{%- endif %} />
  145. {%- endif %}
  146. {%- if 'drop' in rule %}
  147. <drop/>
  148. {%- endif %}
  149. </rule>
  150. {%- endfor %}
  151. {%- endif %}
  152. </zone>