Saltstack Official UFW Formula
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

52 rindas
1.7KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=sls
  3. {#- Get the `tplroot` from `tpldir` #}
  4. {%- set tplroot = tpldir.split('/')[0] %}
  5. {%- set sls_package_install = tplroot ~ '.package.install' %}
  6. {%- set sls_enable_service = tplroot ~ '.service.enable' %}
  7. {%- set sls_reload_service = tplroot ~ '.service.reload' %}
  8. {%- from tplroot ~ "/map.jinja" import ufw with context %}
  9. include:
  10. - {{ sls_package_install }}
  11. - {{ sls_enable_service }}
  12. - {{ sls_reload_service }}
  13. # Applications
  14. {%- for app_name, app_details in ufw.get('applications', {}).items() %}
  15. {%- set from_addr_raw = app_details.get('from_addr', [None]) %}
  16. {%- set from_addrs = [from_addr_raw] if from_addr_raw is string else from_addr_raw %}
  17. {%- for from_addr in from_addrs %}
  18. {%- set deny = app_details.get('deny', None) %}
  19. {%- set limit = app_details.get('limit', None) %}
  20. {%- set method = 'deny' if deny else ('limit' if limit else 'allow') %}
  21. {%- set to_addr = app_details.get('to_addr', None) %}
  22. {%- set comment = app_details.get('comment', None) %}
  23. {%- if from_addr is not none %}
  24. ufw-app-{{ method }}-{{ app_name }}-{{ from_addr }}:
  25. {%- else %}
  26. ufw-app-{{ method }}-{{ app_name }}:
  27. {%- endif %}
  28. ufw.{{ method }}:
  29. - app: '"{{ app_name }}"'
  30. {%- if from_addr is not none %}
  31. - from_addr: {{ from_addr }}
  32. {%- endif %}
  33. {%- if to_addr is not none %}
  34. - to_addr: {{ to_addr }}
  35. {%- endif %}
  36. # Debian Jessie doesn't implement the **comment** directive
  37. # CentOS-6 throws an UTF-8 error
  38. {%- if comment is not none and salt['grains.get']('osfinger') != 'Debian-8' and salt['grains.get']('osfinger') != 'CentOS-6' %}
  39. - comment: '"{{ comment }}"'
  40. {%- endif %}
  41. - listen_in:
  42. - cmd: reload-ufw
  43. {%- endfor %}
  44. {%- endfor %}