Saltstack Official IPTables Formula
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

44 lines
1.2KB

  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. {%- if service.ipv6 %}
  11. iptables_{{ chain_name }}_ipv6_policy:
  12. iptables.set_policy:
  13. - family: ipv6
  14. - chain: {{ chain_name }}
  15. - policy: {{ chain.policy }}
  16. - table: filter
  17. {%- endif %}
  18. {%- endif %}
  19. {%- for service_name, service in pillar.items() %}
  20. {%- if service.get('_support', {}).get('iptables', {}).get('enabled', False) %}
  21. {%- set grains_fragment_file = service_name+'/meta/iptables.yml' %}
  22. {%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
  23. {%- set grains_yaml = load_grains_file()|load_yaml %}
  24. {%- for rule in grains_yaml.iptables.rules %}
  25. {%- set rule_name = service_name+'_'+loop.index|string %}
  26. {% include "iptables/_rule.sls" %}
  27. {%- endfor %}
  28. {%- endif %}
  29. {%- endfor %}
  30. {%- for rule in chain.get('rules', []) %}
  31. {%- set rule_name = loop.index %}
  32. {% include "iptables/_rule.sls" %}
  33. {%- endfor %}
  34. {%- endfor %}