Saltstack Official Apache Formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

117 lines
3.1KB

  1. {% if grains['os_family']=="Debian" %}
  2. include:
  3. - apache
  4. {%- set existing_states = salt['cp.list_states']() %}
  5. {%- for module in salt['pillar.get']('apache:modules:enabled', []) %}
  6. {%- set mod_state = 'apache.mod_{}'.format(module) %}
  7. {%- if mod_state in existing_states %}
  8. - {{ mod_state }}
  9. {%- endif %}
  10. {%- endfor %}
  11. {% for module in salt['pillar.get']('apache:modules:enabled', []) %}
  12. {%- set mod_state = 'apache.mod_{}'.format(module) %}
  13. {% if mod_state not in existing_states %}
  14. a2enmod {{ module }}:
  15. cmd.run:
  16. - unless: ls /etc/apache2/mods-enabled/{{ module }}.load
  17. - order: 225
  18. - require:
  19. - pkg: apache
  20. - watch_in:
  21. - module: apache-restart
  22. - require_in:
  23. - module: apache-restart
  24. - module: apache-reload
  25. - service: apache
  26. {% endif %}
  27. {% endfor %}
  28. {% for module in salt['pillar.get']('apache:modules:disabled', []) %}
  29. a2dismod -f {{ module }}:
  30. cmd.run:
  31. - onlyif: ls /etc/apache2/mods-enabled/{{ module }}.load
  32. - order: 225
  33. - require:
  34. - pkg: apache
  35. - watch_in:
  36. - module: apache-restart
  37. - require_in:
  38. - module: apache-restart
  39. - module: apache-reload
  40. - service: apache
  41. {% endfor %}
  42. {% elif grains['os_family']=="RedHat" %}
  43. include:
  44. - apache
  45. {% for module in salt['pillar.get']('apache:modules:enabled', []) %}
  46. find /etc/httpd/ -name '*.conf' -type f -exec sed -i -e 's/\(^#\)\(\s*LoadModule.{{ module }}_module\)/\2/g' {} \;:
  47. cmd.run:
  48. - unless: httpd -M 2> /dev/null | grep "[[:space:]]{{ module }}_module"
  49. - order: 225
  50. - require:
  51. - pkg: apache
  52. - watch_in:
  53. - module: apache-restart
  54. - require_in:
  55. - module: apache-restart
  56. - module: apache-reload
  57. - service: apache
  58. {% endfor %}
  59. {% for module in salt['pillar.get']('apache:modules:disabled', []) %}
  60. find /etc/httpd/ -name '*.conf' -type f -exec sed -i -e 's/\(^\s*LoadModule.{{ module }}_module\)/#\1/g' {} \;:
  61. cmd.run:
  62. - onlyif: httpd -M 2> /dev/null | grep "[[:space:]]{{ module }}_module"
  63. - order: 225
  64. - require:
  65. - pkg: apache
  66. - watch_in:
  67. - module: apache-restart
  68. - require_in:
  69. - module: apache-restart
  70. - module: apache-reload
  71. - service: apache
  72. {% endfor %}
  73. {% elif salt['grains.get']('os_family') == 'Suse' or salt['grains.get']('os') == 'SUSE' %}
  74. include:
  75. - apache
  76. {% for module in salt['pillar.get']('apache:modules:enabled', []) %}
  77. a2enmod {{ module }}:
  78. cmd.run:
  79. - unless: egrep "^APACHE_MODULES=" /etc/sysconfig/apache2 | grep {{ module }}
  80. - order: 225
  81. - require:
  82. - pkg: apache
  83. - watch_in:
  84. - module: apache-restart
  85. - require_in:
  86. - module: apache-restart
  87. - module: apache-reload
  88. - service: apache
  89. {% endfor %}
  90. {% for module in salt['pillar.get']('apache:modules:disabled', []) %}
  91. a2dismod -f {{ module }}:
  92. cmd.run:
  93. - onlyif: egrep "^APACHE_MODULES=" /etc/sysconfig/apache2 | grep {{ module }}
  94. - order: 225
  95. - require:
  96. - pkg: apache
  97. - watch_in:
  98. - module: apache-restart
  99. - require_in:
  100. - module: apache-restart
  101. - module: apache-reload
  102. - service: apache
  103. {% endfor %}
  104. {% endif %}