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.

164 lines
4.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_package_install = tplroot ~ '.package.install' %}
  6. {%- from tplroot ~ "/map.jinja" import apache with context %}
  7. {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
  8. include:
  9. - {{ sls_service_running }}
  10. - {{ sls_package_install }}
  11. apache-config-file-directory-logdir:
  12. file.directory:
  13. - name: {{ apache.logdir }}
  14. - user: {{ apache.user }}
  15. - group: {{ apache.group }}
  16. - makedirs: True
  17. - require:
  18. - sls: {{ sls_package_install }}
  19. - require_in:
  20. - service: apache-service-running
  21. apache-config-file-directory-vhostdir:
  22. file.directory:
  23. - name: {{ apache.vhostdir }}
  24. - makedirs: True
  25. - require:
  26. - sls: {{ sls_package_install }}
  27. - require_in:
  28. - service: apache-service-running
  29. apache-config-file-directory-moddir:
  30. file.directory:
  31. - name: {{ apache.moddir }}
  32. - makedirs: True
  33. - require:
  34. - sls: {{ sls_package_install }}
  35. - require_in:
  36. - service: apache-service-running
  37. {%- if apache.davlockdbdir %}
  38. apache-config-file-directory-davlockdbdir:
  39. file.directory:
  40. - name: {{ apache.davlockdbdir }}
  41. - makedirs: True
  42. - user: {{ apache.user }}
  43. - group: {{ apache.group }}
  44. - recurse:
  45. - user
  46. - group
  47. - require:
  48. - sls: {{ sls_package_install }}
  49. - require_in:
  50. - service: apache-service-running
  51. {%- endif %}
  52. {%- if 'sitesdir' in apache and apache.sitesdir %}
  53. apache-config-file-directory-sites-enabled:
  54. file.directory:
  55. - name: {{ apache.sitesdir }}
  56. - makedirs: True
  57. - require:
  58. - sls: {{ sls_package_install }}
  59. - require_in:
  60. - service: apache-service-running
  61. {%- endif %}
  62. {%- if grains.os_family in ('Debian',) and 'confdir' in apache and apache.confdir %}
  63. apache-config-file-directory-conf-enabled:
  64. file.directory:
  65. - name: {{ apache.confdir }}
  66. - makedirs: True
  67. - require:
  68. - sls: {{ sls_package_install }}
  69. - require_in:
  70. - service: apache-service-running
  71. {%- endif %}
  72. apache-config-file-managed:
  73. file.managed:
  74. - name: {{ apache.config }}
  75. - source: 'salt://apache/files/{{ grains.os_family }}/apache-{{ apache.version }}.config.jinja'
  76. - mode: 644
  77. - user: {{ apache.rootuser }}
  78. {%- if grains.kernel != 'Windows' %}
  79. - group: {{ apache.rootgroup }}
  80. {%- endif %}
  81. - makedirs: True
  82. - template: {{ apache.get('template_engine', 'jinja') }}
  83. - require:
  84. - sls: {{ sls_package_install }}
  85. - context:
  86. apache: {{ apache | json }}
  87. {%- if grains.os_family in ('Debian', 'FreeBSD') %}
  88. apache-config-file-managed-{{ grains.os }}-env:
  89. file.managed:
  90. - name: /etc/apache2/envvars
  91. - source: 'salt://apache/files/{{ grains.os_family }}/envvars-{{ apache.version }}.jinja'
  92. - mode: 644
  93. - user: {{ apache.rootuser }}
  94. - group: {{ apache.rootgroup }}
  95. - makedirs: True
  96. - template: {{ apache.get('template_engine', 'jinja') }}
  97. - context:
  98. apache: {{ apache | json }}
  99. - require_in:
  100. - file: apache-config-file-managed-{{ grains.os }}-ports
  101. apache-config-file-managed-{{ grains.os }}-ports:
  102. file.managed:
  103. - name: {{ apache.portsfile }}
  104. - source: salt://apache/files/{{ grains.os_family }}/ports-{{ apache.version }}.conf.jinja
  105. - mode: 644
  106. - user: {{ apache.rootuser }}
  107. - group: {{ apache.rootgroup }}
  108. - makedirs: True
  109. - template: {{ apache.get('template_engine', 'jinja') }}
  110. - context:
  111. apache: {{ apache | json }}
  112. {%- elif grains.os_family == "RedHat" %}
  113. apache-config-file-absent-{{ grains.os }}:
  114. file.absent:
  115. - name: {{ apache.confdir }}/welcome.conf
  116. {%- elif grains.os_family == "Suse" %}
  117. apache-config-file-managed-{{ grains.os }}:
  118. file.managed:
  119. - name: /etc/apache2/global.conf
  120. - source: 'salt://apache/files/Suse/global.config.jinja'
  121. - mode: 644
  122. - user: {{ apache.rootuser }}
  123. - group: {{ apache.rootgroup }}
  124. - makedirs: True
  125. - template: {{ apache.get('template_engine', 'jinja') }}
  126. - context:
  127. apache: {{ apache | json }}
  128. {%- else %}
  129. apache-config-file-managed-skip:
  130. test.show_notification:
  131. - text: |
  132. No configuration file to manage
  133. {%- endif %}
  134. - require:
  135. - sls: {{ sls_package_install }}
  136. - watch_in:
  137. - module: apache-service-running-restart
  138. - require_in:
  139. - module: apache-service-running-restart
  140. - service: apache-service-running