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.

56 lines
1.4KB

  1. {% if grains['os_family']=="Debian" %}
  2. include:
  3. - apache
  4. {% for module in salt['pillar.get']('apache:modules:enabled', []) %}
  5. a2enmod {{ module }}:
  6. cmd.run:
  7. - unless: ls /etc/apache2/mods-enabled/{{ module }}.load
  8. - order: 225
  9. - require:
  10. - pkg: apache
  11. - watch_in:
  12. - module: apache-restart
  13. {% endfor %}
  14. {% for module in salt['pillar.get']('apache:modules:disabled', []) %}
  15. a2dismod {{ module }}:
  16. cmd.run:
  17. - onlyif: ls /etc/apache2/mods-enabled/{{ module }}.load
  18. - order: 225
  19. - require:
  20. - pkg: apache
  21. - watch_in:
  22. - module: apache-restart
  23. {% endfor %}
  24. {% elif grains['os_family']=="RedHat" %}
  25. include:
  26. - apache
  27. {% for module in salt['pillar.get']('apache:modules:enabled', []) %}
  28. find /etc/httpd/ -name '*.conf' -type f -exec sed -i -e 's/\(^#\)\(\s*LoadModule.{{ module }}_module\)/\2/g' {} \;:
  29. cmd.run:
  30. - unless: httpd -M 2> /dev/null | grep "[[:space:]]{{ module }}_module"
  31. - order: 225
  32. - require:
  33. - pkg: apache
  34. - watch_in:
  35. - module: apache-restart
  36. {% endfor %}
  37. {% for module in salt['pillar.get']('apache:modules:disabled', []) %}
  38. find /etc/httpd/ -name '*.conf' -type f -exec sed -i -e 's/\(^\s*LoadModule.{{ module }}_module\)/#\1/g' {} \;:
  39. cmd.run:
  40. - onlyif: httpd -M 2> /dev/null | grep "[[:space:]]{{ module }}_module"
  41. - order: 225
  42. - require:
  43. - pkg: apache
  44. - watch_in:
  45. - module: apache-restart
  46. {% endfor %}
  47. {% endif %}