Saltstack Official IPTables Formula
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. {% from "iptables/map.jinja" import service with context %}
  2. {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
  3. {%- for chain_name, chain in service.get('chain', {}).iteritems() %}
  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. {%- if chain.policy is defined %}
  25. iptables_{{ chain_name }}_policy:
  26. iptables.set_policy:
  27. - family: ipv4
  28. - chain: {{ chain_name }}
  29. - policy: {{ chain.policy }}
  30. - table: filter
  31. - require:
  32. - iptables: iptables_{{ chain_name }}
  33. {%- if grains.ipv6|default(False) and service.ipv6|default(True) %}
  34. iptables_{{ chain_name }}_ipv6_policy:
  35. iptables.set_policy:
  36. - family: ipv6
  37. - chain: {{ chain_name }}
  38. - policy: {{ chain.policy }}
  39. - table: filter
  40. - require:
  41. - iptables: iptables_{{ chain_name }}_ipv6
  42. {%- endif %}
  43. {%- endif %}
  44. {%- for service_name, service in pillar.items() %}
  45. {%- if service is mapping %}
  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. {%- endif %}
  56. {%- endfor %}
  57. {%- for rule in chain.get('rules', []) %}
  58. {%- set rule_name = loop.index %}
  59. {% include "iptables/_rule.sls" %}
  60. {%- endfor %}
  61. {%- endfor %}
  62. {%- endif %}