Saltstack Official IPTables 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.

42 lines
1.1KB

  1. {% from "iptables/map.jinja" import service with context %}
  2. {%- for chain_name, chain in service.get('chain', {}).iteritems() %}
  3. {%- if chain.policy is defined %}
  4. iptables_{{ chain_name }}_policy:
  5. iptables.set_policy:
  6. - family: ipv4
  7. - chain: {{ chain_name }}
  8. - policy: {{ chain.policy }}
  9. - table: filter
  10. iptables_{{ chain_name }}_ipv6_policy:
  11. iptables.set_policy:
  12. - family: ipv6
  13. - chain: {{ chain_name }}
  14. - policy: {{ chain.policy }}
  15. - table: filter
  16. {%- endif %}
  17. {%- for service_name, service in pillar.items() %}
  18. {%- if service.get('_support', {}).get('iptables', {}).get('enabled', False) %}
  19. {%- set grains_fragment_file = service_name+'/meta/iptables.yml' %}
  20. {%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
  21. {%- set grains_yaml = load_grains_file()|load_yaml %}
  22. {%- for rule in grains_yaml.iptables.rules %}
  23. {%- set rule_name = service_name+'_'+loop.index|string %}
  24. {% include "iptables/_rule.sls" %}
  25. {%- endfor %}
  26. {%- endif %}
  27. {%- endfor %}
  28. {%- for rule in chain.get('rules', []) %}
  29. {%- set rule_name = loop.index %}
  30. {% include "iptables/_rule.sls" %}
  31. {%- endfor %}
  32. {%- endfor %}