Saltstack Official Apache Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.8KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=sls
  3. {%- set tplroot = tpldir.split('/')[0] %}
  4. {%- set sls_service_running = tplroot ~ '.service.running' %}
  5. {%- set sls_package_install = tplroot ~ '.package.install' %}
  6. {%- from tplroot ~ "/map.jinja" import apache with context %}
  7. include:
  8. - {{ sls_service_running }}
  9. - {{ sls_package_install }}
  10. {%- if grains.os_family not in ('Arch',) %}
  11. apache-config-modules-security-pkg:
  12. pkg.installed:
  13. - name: {{ apache.mod_security.package }}
  14. - order: 180
  15. - require:
  16. - pkg: apache-package-install-pkg-installed
  17. - watch_in:
  18. - module: apache-service-running-restart
  19. - require_in:
  20. - module: apache-service-running-restart
  21. - module: apache-service-running-reload
  22. - service: apache-service-running
  23. {%- if apache.mod_security.crs_install and 'crs_package' in apache.mod_security %}
  24. apache-config-modules-security-crs-pkg:
  25. pkg.installed:
  26. - name: {{ apache.mod_security.crs_package }}
  27. - order: 180
  28. - require:
  29. - pkg: apache-config-modules-security-pkg
  30. - watch_in:
  31. - module: apache-service-running-restart
  32. - require_in:
  33. - module: apache-service-running-restart
  34. - module: apache-service-running-reload
  35. - service: apache-service-running
  36. {%- endif %}
  37. {%- if apache.mod_security.manage_config and 'config_file' in apache.mod_security %}
  38. apache-config-modules-security-main-config-file-managed:
  39. file.managed:
  40. - name: {{ apache.mod_security.config_file }}
  41. - order: 220
  42. - makedirs: True
  43. - template: {{ apache.get('template_engine', 'jinja') }}
  44. - context:
  45. apache: {{ apache|json }}
  46. - source:
  47. - {{ 'salt://apache/files/' ~ salt['grains.get']('os_family') ~ '/modsecurity.conf.jinja' }}
  48. - context: {{ apache.mod_security|json }}
  49. - require:
  50. - pkg: apache-config-modules-security-pkg
  51. - watch_in:
  52. - module: apache-service-running-reload
  53. - require_in:
  54. - module: apache-service-running-restart
  55. - module: apache-service-running-reload
  56. - service: apache-service-running
  57. {%- endif %}
  58. {%- if grains['os_family'] in ('Suse', 'Debian',) %}
  59. apache-config-modules-security-cmd-run-a2en-security2:
  60. cmd.run:
  61. - name: a2enmod security2
  62. - unless: ls {{ apache.moddir }}/security2.load && ls {{ apache.moddir }}/security2.conf
  63. - order: 225
  64. {%- elif grains.os_family in ('Redhat',) %}
  65. apache-config-modules-security-file-directory-modsecurity:
  66. file.directory:
  67. - name: /etc/httpd/modsecurity.d
  68. {%- endif %}
  69. - require:
  70. - pkg: apache-config-modules-security-pkg
  71. - watch_in:
  72. - module: apache-service-running-restart
  73. - require_in:
  74. - module: apache-service-running-restart
  75. - module: apache-service-running-reload
  76. - service: apache-service-running
  77. {%- endif %}