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.

83 line
2.1KB

  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 -f {{ 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. {% elif salt['grains.get']('os_family') == 'Suse' or salt['grains.get']('os') == 'SUSE' %}
  48. include:
  49. - apache
  50. {% for module in salt['pillar.get']('apache:modules:enabled', []) %}
  51. a2enmod {{ module }}:
  52. cmd.run:
  53. - unless: egrep "^APACHE_MODULES=" /etc/sysconfig/apache2 | grep {{ module }}
  54. - order: 225
  55. - require:
  56. - pkg: apache
  57. - watch_in:
  58. - module: apache-restart
  59. {% endfor %}
  60. {% for module in salt['pillar.get']('apache:modules:disabled', []) %}
  61. a2dismod -f {{ module }}:
  62. cmd.run:
  63. - onlyif: egrep "^APACHE_MODULES=" /etc/sysconfig/apache2 | grep {{ module }}
  64. - order: 225
  65. - require:
  66. - pkg: apache
  67. - watch_in:
  68. - module: apache-restart
  69. {% endfor %}
  70. {% endif %}