Saltstack Official IPTables Formula
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

service.sls 2.3KB

hace 9 años
hace 9 años
hace 9 años
hace 9 años
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {% from "iptables/map.jinja" import service with context %}
  2. {%- if pillar.iptables.service.enabled %}
  3. iptables_packages:
  4. pkg.installed:
  5. - names: {{ service.pkgs }}
  6. iptables_services:
  7. service.dead:
  8. - enable: true
  9. - name: {{ service.service }}
  10. - sig: test -e /etc/iptables/rules.v4
  11. - require:
  12. - pkg: iptables_packages
  13. {%- for chain_name, chain in service.get('chain', {}).iteritems() %}
  14. {%- if chain.policy is defined %}
  15. iptables_{{ chain_name }}_policy:
  16. iptables.set_policy:
  17. - chain: {{ chain_name }}
  18. - policy: {{ chain.policy }}
  19. - table: filter
  20. {%- endif %}
  21. {%- for rule_name, rule in chain.get('rule', {}).iteritems() %}
  22. iptables_{{ chain_name }}_{{ rule_name }}:
  23. iptables.insert:
  24. {%- if rule.position is defined %}
  25. - position: {{ rule.position }}
  26. {%- endif %}
  27. {%- if rule.table is defined %}
  28. - table: {{ rule.table }}
  29. {%- endif %}
  30. - chain: {{ chain_name }}
  31. {%- if rule.jump is defined %}
  32. - jump: {{ rule.jump }}
  33. {%- endif %}
  34. {%- if rule.match is defined %}
  35. - match: {{ rule.match }}
  36. {%- endif %}
  37. {%- if rule.connection_state is defined %}
  38. - connstate: {{ rule.connection_state }}
  39. {%- endif %}
  40. {%- if rule.protocol is defined %}
  41. - proto: {{ rule.protocol }}
  42. {%- endif %}
  43. {%- if rule.destination_port is defined %}
  44. - dport: {{ rule.destination_port }}
  45. {%- endif %}
  46. {%- if rule.source_port is defined %}
  47. - sport: {{ rule.source_port }}
  48. {%- endif %}
  49. {%- if rule.in_interface is defined %}
  50. - in-interface: {{ rule.in_interface }}
  51. {%- endif %}
  52. {%- if rule.out_interface is defined %}
  53. - out-interface: {{ rule.out_interface }}
  54. {%- endif %}
  55. {%- if rule.to_destination is defined %}
  56. - to-destination: {{ rule.to_destination }}
  57. {%- endif %}
  58. {%- if rule.to_source is defined %}
  59. - to-source: {{ rule.to_source }}
  60. {%- endif %}
  61. {%- if rule.source_network is defined %}
  62. - source: {{ rule.source_network }}
  63. {%- endif %}
  64. {%- if rule.destination_network is defined %}
  65. - destination: {{ rule.destination_network }}
  66. {%- endif %}
  67. {%- if chain.policy is defined %}
  68. - require_in:
  69. - iptables: iptables_{{ chain_name }}_policy:
  70. {%- endif %}
  71. - save: True
  72. {%- endfor %}
  73. {%- endfor %}
  74. {%- else %}
  75. iptables_services:
  76. service.dead:
  77. - enable: false
  78. - name: {{ service.service }}
  79. {%- endif %}