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.

52 lines
1.5KB

  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_config_file = tplroot ~ '.config.file' %}
  6. {%- from tplroot ~ "/map.jinja" import apache with context %}
  7. include:
  8. - {{ sls_service_running }}
  9. - {{ sls_config_file }}
  10. {% set existing_states = salt['cp.list_states']() %}
  11. {% for module in salt['pillar.get']('apache:modules:enabled', []) %}
  12. apache-config-modules-{{ module }}-enable:
  13. {% if grains['os_family']=="Debian" %}
  14. cmd.run:
  15. - name: a2enmod -f {{ module }}
  16. - unless: ls {{ apache.moddir }}/{{ module }}.load
  17. {% elif grains.os_family in ('RedHat', 'Arch') %}
  18. cmd.run:
  19. - name: find /etc/httpd/ -name '*.conf' -type f -exec sed -i -e 's/\(^#\)\(\s*LoadModule.{{ module }}_module\)/\2/g' {} \;
  20. - onlyif: {{ grains.os_family in ('Arch',) and 'true' }} || (httpd -M 2> /dev/null |grep "[[:space:]]{{ module }}_module")
  21. {% elif salt['grains.get']('os_family') == 'Suse' %}
  22. cmd.run:
  23. - name: a2enmod {{ module }}
  24. - onlyif: egrep "^APACHE_MODULES=" /etc/sysconfig/apache2 |grep {{ module }}
  25. {% else %}
  26. test.show_notification:
  27. - text: |
  28. No {{ module }} module change
  29. {%- endif %}
  30. - order: 225
  31. - require:
  32. - sls: {{ sls_config_file }}
  33. - watch_in:
  34. - module: apache-service-running-restart
  35. - require_in:
  36. - module: apache-service-running-restart
  37. - module: apache-service-running-reload
  38. {%- endfor %}