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.

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