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.

85 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. {%- set mpm_module = salt['pillar.get']('apache:mpm:module', 'mpm_prefork') %}
  8. include:
  9. - {{ sls_service_running }}
  10. - {{ sls_package_install }}
  11. {%- if grains['os_family'] in ('Suse', 'Debian',) %}
  12. apache-config-modules-mpm-pkg:
  13. cmd.run:
  14. - name: a2enmod {{ mpm_module }}
  15. - unless: ls {{ apache.moddir }}/{{ mpm_module }}.load
  16. - require:
  17. - pkg: apache-package-install-pkg-installed
  18. - watch_in:
  19. - module: apache-service-running-restart
  20. - require_in:
  21. - module: apache-service-running-restart
  22. - module: apache-service-running-reload
  23. - service: apache-service-running
  24. file.managed:
  25. - name: /etc/apache2/mods-available/{{ mpm_module }}.conf
  26. - template: {{ apache.get('template_engine', 'jinja') }}
  27. - makedirs: True
  28. - context:
  29. apache: {{ apache|json }}
  30. - source:
  31. - salt://apache/files/Debian/mpm/{{ mpm_module }}.conf.jinja
  32. - require:
  33. - pkg: apache-package-install-pkg-installed
  34. - watch_in:
  35. - module: apache-service-running-restart
  36. - require_in:
  37. - module: apache-service-running-restart
  38. - module: apache-service-running-reload
  39. - service: apache-service-running
  40. # Deactivate the other mpm modules as a previous step
  41. {%- for mod in ['mpm_prefork', 'mpm_worker', 'mpm_event'] if not mod == mpm_module %}
  42. apache-config-modules-mpm-{{ mod }}-cmd-run:
  43. cmd.run:
  44. - name: a2dismod {{ mod }}
  45. - onlyif: ls {{ apache.moddir }}/{{ mod }}.load || egrep "^APACHE_MODULES=" /etc/sysconfig/apache2 | grep ' {{ mod }}'
  46. - require:
  47. - pkg: apache-package-install-pkg-installed
  48. - require_in:
  49. - cmd: a2enmod {{ mpm_module }}
  50. - watch_in:
  51. - module: apache-service-running-restart
  52. - require_in:
  53. - module: apache-service-running-restart
  54. - module: apache-service-running-reload
  55. - service: apache-service-running
  56. {%- endfor %}
  57. {%- elif grains['os_family']=="RedHat" %}
  58. apache-config-modules-mpm-{{ grains.os_family }}-conf-file-managed:
  59. file.managed:
  60. - name: {{ apache.moddir }}/00-mpm.conf
  61. - template: {{ apache.get('template_engine', 'jinja') }}
  62. - makedirs: True
  63. - context:
  64. apache: {{ apache|json }}
  65. - source:
  66. - salt://apache/files/RedHat/conf.modules.d/00-{{ mpm_module }}.conf.jinja
  67. - require:
  68. - pkg: apache-package-install-pkg-installed
  69. - watch_in:
  70. - module: apache-service-running-restart
  71. - require_in:
  72. - module: apache-service-running-restart
  73. - module: apache-service-running-reload
  74. - service: apache-service-running
  75. {%- endif %}