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.

rules.sls 2.0KB

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