Saltstack Official Apache Formula
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

49 lines
1.4KB

  1. {%- set tplroot = tpldir.split('/')[0] %}
  2. {%- from tplroot ~ "/map.jinja" import apache with context %}
  3. {#- set apache = pillar.get('apache', {}) #}
  4. {%- set mod_security = apache.get('mod_security', {}) %}
  5. {%- if mod_security.get('manage_config', False) %}
  6. include:
  7. - apache.config.modules.mod_security
  8. {%- for rule_name, rule_details in mod_security.get('rules', {}).items() %}
  9. {%- set rule_set = rule_details.get('rule_set', '') %}
  10. {%- set enabled = rule_details.get('enabled', False ) %}
  11. {%- if enabled %}
  12. /etc/modsecurity/{{ rule_name }}:
  13. file.symlink:
  14. - target: /usr/share/modsecurity-crs/{{ rule_set }}/{{ rule_name }}
  15. - user: {{ apache.rootuser }}
  16. - group: {{ apache.rootgroup }}
  17. - mode: 755
  18. {%- else %}
  19. /etc/modsecurity/{{ rule_name }}:
  20. file.absent:
  21. - name: /etc/modsecurity/{{ rule_name }}
  22. {%- endif %}
  23. {%- endfor %}
  24. {%- for custom_rule, custom_rule_details in mod_security.get('custom_rule_files', {}).items() %}
  25. {%- set file = custom_rule_details.get('file', None) %}
  26. {%- set path = custom_rule_details.get('path', None) %}
  27. {%- set enabled = custom_rule_details.get('enabled', False ) %}
  28. {%- if enabled %}
  29. /etc/modsecurity/{{ file }}:
  30. file.managed:
  31. - source: {{ path }}
  32. - user: {{ apache.rootuser }}
  33. - group: {{ apache.rootgroup }}
  34. - mode: 755
  35. - makedirs: True
  36. {%- else %}
  37. /etc/modsecurity/{{ file }}:
  38. file.absent:
  39. - name: /etc/modsecurity/{{ file }}
  40. {%- endif %}
  41. {%- endfor %}
  42. {%- endif %}