Saltstack Official IPTables Formula
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

63 lines
1.7KB

  1. {% from "iptables/map.jinja" import service with context %}
  2. {%- for chain_name, chain in service.get('chain', {}).iteritems() %}
  3. iptables_{{ chain_name }}:
  4. iptables.chain_present:
  5. - family: ipv4
  6. - name: {{ chain_name }}
  7. - table: filter
  8. {%- if grains.ipv6|default(False) and service.ipv6|default(True) %}
  9. iptables_{{ chain_name }}_ipv6:
  10. iptables.chain_present:
  11. - family: ipv6
  12. - name: {{ chain_name }}
  13. - table: filter
  14. - require_in:
  15. - iptables: iptables_{{ chain_name }}_ipv6_policy
  16. {%- if chain.policy is defined %}
  17. iptables_{{ chain_name }}_policy:
  18. iptables.set_policy:
  19. - family: ipv4
  20. - chain: {{ chain_name }}
  21. - policy: {{ chain.policy }}
  22. - table: filter
  23. - require:
  24. - iptables: iptables_{{ chain_name }}
  25. {%- if grains.ipv6|default(False) and service.ipv6|default(True) %}
  26. iptables_{{ chain_name }}_ipv6_policy:
  27. iptables.set_policy:
  28. - family: ipv6
  29. - chain: {{ chain_name }}
  30. - policy: {{ chain.policy }}
  31. - table: filter
  32. - require:
  33. - iptables: iptables_{{ chain_name }}_ipv6
  34. {%- endif %}
  35. {%- endif %}
  36. {%- for service_name, service in pillar.items() %}
  37. {%- if service.get('_support', {}).get('iptables', {}).get('enabled', False) %}
  38. {%- set grains_fragment_file = service_name+'/meta/iptables.yml' %}
  39. {%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
  40. {%- set grains_yaml = load_grains_file()|load_yaml %}
  41. {%- for rule in grains_yaml.iptables.rules %}
  42. {%- set rule_name = service_name+'_'+loop.index|string %}
  43. {% include "iptables/_rule.sls" %}
  44. {%- endfor %}
  45. {%- endif %}
  46. {%- endfor %}
  47. {%- for rule in chain.get('rules', []) %}
  48. {%- set rule_name = loop.index %}
  49. {% include "iptables/_rule.sls" %}
  50. {%- endfor %}
  51. {%- endfor %}