Saltstack Official UFW 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ů.

104 lines
2.1KB

  1. # UFW management module
  2. {%- set ufw = pillar.get('ufw', {}) %}
  3. {%- if ufw.get('enabled', False) %}
  4. ufw:
  5. pkg:
  6. - installed
  7. service.running:
  8. - enable: True
  9. {%- if ufw.get('defaults', {}).get('incoming', False) %}
  10. ufw-default-incoming:
  11. ufw.default_incoming:
  12. - default: {{ufw.get('defaults', {}).get('incoming', 'allow')}}
  13. - require:
  14. - pkg: ufw
  15. {% endif %}
  16. {%- if ufw.get('defaults', {}).get('outgoing', False) %}
  17. ufw-default-outgoing:
  18. ufw.default_outgoing:
  19. - default: {{ufw.get('defaults', {}).get('outgoing', 'deny')}}
  20. - require:
  21. - pkg: ufw
  22. {% endif %}
  23. {%- for service_name, service_details in ufw.get('services', {}).items() %}
  24. {%- for from_addr in service_details.get('from_addr', [None]) %}
  25. {%- set protocol = service_details.get('protocol', None) %}
  26. {%- set from_port = service_details.get('from_port', None) %}
  27. {%- set to_addr = service_details.get('to_addr', None) %}
  28. ufw-svc-{{service_name}}-{{from_addr}}:
  29. ufw.allowed:
  30. {%- if protocol != None %}
  31. - protocol: {{protocol}}
  32. {%- endif %}
  33. {%- if from_addr != None %}
  34. - from_addr: {{from_addr}}
  35. {%- endif %}
  36. {%- if from_port != None %}
  37. - from_port: "{{from_port}}"
  38. {%- endif %}
  39. {%- if to_addr != None %}
  40. - to_addr: {{to_addr}}
  41. {%- endif %}
  42. - to_port: "{{service_name}}"
  43. - require:
  44. - pkg: ufw
  45. {%- endfor %}
  46. {%- endfor %}
  47. # Applications
  48. {%- for app_name in ufw.get('applications', []) %}
  49. ufw-app-{{app_name}}:
  50. ufw.allowed:
  51. - app: {{app_name}}
  52. - require:
  53. - pkg: ufw
  54. {%- endfor %}
  55. # Interfaces
  56. {%- for interface in ufw.get('interfaces', []) %}
  57. ufw-interface-{{interface}}:
  58. ufw.allowed:
  59. - interface: {{interface}}
  60. - require:
  61. - pkg: ufw
  62. {%- endfor %}
  63. # Open
  64. {%- for from_addr in ufw.get('open', {}).get('from_addr', []) %}
  65. ufw-open-{{from_addr}}:
  66. ufw.allowed:
  67. - from_addr: {{from_addr}}
  68. - require:
  69. - pkg: ufw
  70. {%- endfor %}
  71. enable-ufw:
  72. ufw.enabled:
  73. - require:
  74. - pkg: ufw
  75. {% else %}
  76. #ufw:
  77. #ufw:
  78. #- disabled
  79. {% endif %}