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.

98 lines
3.7KB

  1. <?xml version="1.0" encoding="utf-8"?>
  2. {{pillar['headers']['salt']['xml']}}
  3. <zone{% if 'target' in zone %} target="{{ zone.target }}"{% endif %}>
  4. {% if 'short' in zone %}<short>{{ zone.short }}</short>{% else %}<short>{{ name }}</short>{% endif %}
  5. {% if 'description' in zone %}<description>{{ zone.description }}</description>{% endif %}
  6. {% if 'interfaces' in zone %}
  7. {% for v in zone.interfaces %}<interface name="{{ v }}" />{% endfor %}
  8. {% endif %}
  9. {% if 'sources' in zone %}
  10. {% for v in zone.sources %}<source name="{{ v }}" />{% endfor %}
  11. {% endif %}
  12. {% if 'services' in zone %}
  13. {% for v in zone.services %}<service name="{{ v }}" />{% endfor %}
  14. {% endif %}
  15. {% if 'ports' in zone %}
  16. {% for v in zone.ports %}
  17. {% if 'comment' in v %}
  18. <!-- {{ v.comment }} -->
  19. {% endif %}
  20. <port port="{{ v.port }}" protocol="{{ v.protocol }}"/>
  21. {% endfor %}
  22. {% endif %}
  23. {% if 'icmp_blocks' in zone %}
  24. {% for v in zone.icmp_blocks %}<icmp-block name="{{ v }}" />{% endfor %}
  25. {% endif %}
  26. {% if 'masquerade' in zone %}{% if zone.masquerade %}<masquerade/>{% endif %}{% endif %}
  27. {% if 'forward_ports' in zone %}
  28. {% for v in zone.forward_ports %}
  29. {% if 'comment' in v %}
  30. <!-- {{ v.comment }} -->
  31. {% endif %}
  32. <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 %} />
  33. {% endfor %}
  34. {% endif %}
  35. {% if 'rich_rules' in zone %}
  36. {% for rule in zone.rich_rules %}
  37. {% if 'family' in rule %}
  38. <rule family="{{ rule.family }}">
  39. {% else %}
  40. <rule>
  41. {% endif %}
  42. {% if 'source' in rule %}
  43. <source address="{{ rule.source.address }}" {% if 'invert' in rule.source %}invert="{{ rule.source.invert }}"{% endif %}/>
  44. {% endif %}
  45. {% if 'destination' in rule %}
  46. <destination address="{{ rule.destination.address }}" {% if 'invert' in rule.destination %}invert="{{ rule.destination.invert }}"{% endif %}/>
  47. {% endif %}
  48. {% if 'service' in rule %}
  49. <destination name="{{ rule.service }}"/>
  50. {% endif %}
  51. {% if 'port' in rule %}
  52. <port port="{{ rule.port.portid }}" protocol="{{ rule.port.protocol }}"/>
  53. {% endif %}
  54. {% if 'protocol' in rule %}
  55. <protocol value="{{ rule.protocol }}"/>
  56. {% endif %}
  57. {% if 'icmp_block' in rule %}
  58. <icmp_block name="{{ rule.icmp_block }}"/>
  59. {% endif %}
  60. {% if 'masquerade' in rule %}
  61. {% if rule.masquerade %}<masquerade/>{% endif %}
  62. {% endif %}
  63. {% if 'forward_port' in rule %}
  64. {% if 'comment' in rule.forward_port %}
  65. <!-- {{ rule.forward_port.comment }} -->
  66. {% endif %}
  67. <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 %} />
  68. {% endif %}
  69. {% if 'log' in rule %}
  70. <log{% if 'prefix' in rule.log %} prefix="{{ rule.log.prefix }}"{% endif %}{% if 'level' in rule.log %} level="{{ rule.log.level }}"{% endif %}>
  71. {% if 'limit' in rule.log %}
  72. <limit value="{{ rule.log.limit }}"/>
  73. {% endif %}
  74. </log>
  75. {% endif %}
  76. {% if 'audit' in rule %}
  77. <audit>{% if 'limit' in rule.audit %} <limit value="{{ rule.audit.limit }}"/>{% endif %}</audit>
  78. {% endif %}
  79. {% if 'accept' in rule %}
  80. <accept/>
  81. {% endif %}
  82. {% if 'reject' in rule %}
  83. <reject{% if 'type' in rule.reject %} type="{{ rule.reject.type }}"{% endif %}/>
  84. {% endif %}
  85. {% if 'drop' in rule %}
  86. <drop/>
  87. {% endif %}
  88. </rule>
  89. {% endfor %}
  90. {% endif %}
  91. </zone>