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

65 lines
2.0KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=sls
  3. {%- set tplroot = tpldir.split('/')[0] %}
  4. {%- set sls_config_file = tplroot ~ '.config.file' %}
  5. {%- set sls_config_registersite = tplroot ~ '.config.register_site' %}
  6. {%- from tplroot ~ "/map.jinja" import apache with context %}
  7. include:
  8. - {{ sls_config_file }}
  9. - {{ sls_config_registersite }}
  10. apache-service-running:
  11. {%- if salt['pillar.get']('apache:manage_service_states', True) %}
  12. {# By default run apache service states (unless pillar is false) #}
  13. service.running:
  14. - name: {{ apache.service.name }}
  15. - enable: True
  16. - watch:
  17. - sls: {{ sls_config_file }}
  18. - retry: {{ apache.retry_option|json }}
  19. cmd.run:
  20. - names:
  21. - journalctl -xe -u {{ apache.service.name }} || tail -20 /var/log/messages || true
  22. - (service {{ apache.service.name }} restart && service {{ apache.service.name }} status) || true
  23. - cat {{ apache.config }}
  24. - onfail:
  25. - service: apache-service-running
  26. {%- endif %}
  27. {# The following states are by default inert and can be used #}
  28. {# by other states to trigger a restart or reload as needed. #}
  29. apache-service-running-restart:
  30. module.wait:
  31. {%- if apache.service_state in ['running'] %}
  32. - name: service.restart
  33. - m_name: {{ apache.service.name }}
  34. {%- else %}
  35. - name: cmd.run
  36. - cmd: {{ apache.custom_reload_command|default('apachectl graceful') }}
  37. - python_shell: True
  38. {%- endif %}
  39. - watch:
  40. - sls: {{ sls_config_file }}
  41. - require:
  42. - sls: {{ sls_config_file }}
  43. - service: apache-service-running
  44. apache-service-running-reload:
  45. module.wait:
  46. {%- if apache.service_state in ['running'] %}
  47. - name: service.reload
  48. - m_name: {{ apache.service.name }}
  49. {%- else %}
  50. - name: cmd.run
  51. - cmd: {{ apache.custom_reload_command|default('apachectl graceful') }}
  52. - python_shell: True
  53. {%- endif %}
  54. - watch:
  55. - sls: {{ sls_config_file }}
  56. - require:
  57. - sls: {{ sls_config_file }}
  58. - service: apache-service-running