Saltstack Official IPTables Formula
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

80 lines
1.9KB

  1. {% from "iptables/map.jinja" import defaults,schema,service with context %}
  2. {%- if service.v4.enabled %}
  3. iptables_packages_v4:
  4. pkg.installed:
  5. - names: {{ service.v4.pkgs }}
  6. iptables_modules_v4_load:
  7. kmod.present:
  8. - persist: true
  9. - mods: {{ service.v4.modules }}
  10. - require:
  11. - pkg: iptables_packages_v4
  12. {{ service.v4.persistent_config }}:
  13. file.managed:
  14. - user: root
  15. - group: root
  16. - mode: 640
  17. - source: salt://iptables/v{{ schema.epoch }}/files/v4_rules
  18. - template: jinja
  19. - require:
  20. - pkg: iptables_packages_v4
  21. {% if grains['os'] == 'Ubuntu' %}
  22. iptables_services_v4_start:
  23. cmd.run:
  24. - name: find /usr/share/netfilter-persistent/plugins.d/[0-9]*-ip4tables -exec {} start \;
  25. - onlyif: test $(iptables-save | wc -l) -eq 0
  26. - require:
  27. - file: {{ service.v4.persistent_config }}
  28. - kmod: iptables_modules_v4_load
  29. {%- endif %}
  30. {{ service.v4.service }}:
  31. service.running:
  32. - enable: true
  33. - require:
  34. - file: {{ service.v4.persistent_config }}
  35. - kmod: iptables_modules_v4_load
  36. - watch:
  37. - file: {{ service.v4.persistent_config }}
  38. iptables_tables_cleanup_v4:
  39. module.wait:
  40. - name: iptables_extra.remove_stale_tables
  41. - config_file: {{ service.v4.persistent_config }}
  42. - family: ipv4
  43. - require:
  44. - file: {{ service.v4.persistent_config }}
  45. - watch:
  46. - file: {{ service.v4.persistent_config }}
  47. {%- else %}
  48. {% if grains['os'] == 'Ubuntu' %}
  49. iptables_services_v4_stop:
  50. cmd.run:
  51. - name: find /usr/share/netfilter-persistent/plugins.d/[0-9]*-ip4tables -exec {} flush \;
  52. - onlyif: test $(which iptables-save) -eq 0 && test $(iptables-save | wc -l) -ne 0
  53. {{ service.v4.persistent_config }}:
  54. file.absent:
  55. - require:
  56. - cmd: iptables_services_v4_stop
  57. iptables_tables_flush_v4:
  58. module.wait:
  59. - name: iptables_extra.flush_all
  60. - family: ipv4
  61. - watch:
  62. - file: {{ service.v4.persistent_config }}
  63. {%- endif %}
  64. {%- endif %}