Saltstack Official Apache Formula
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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