Saltstack Official Apache Formula
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

81 行
2.7KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=sls
  3. {%- set tplroot = tpldir.split('/')[0] %}
  4. {%- set sls_package_install = tplroot ~ '.package.install' %}
  5. {%- set sls_service_running = tplroot ~ '.service.running' %}
  6. {%- from tplroot ~ "/map.jinja" import apache with context %}
  7. include:
  8. - {{ sls_package_install }}
  9. - {{ sls_service_running }}
  10. {%- for id, site in salt['pillar.get']('apache:sites', {}).items() %}
  11. {%- set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, site.get('ServerName', id))) %}
  12. apache-config-vhosts-standard-{{ id }}:
  13. file.managed:
  14. - name: {{ apache.vhostdir }}/{{ id }}{{ apache.confext }}
  15. - source: {{ site.get('template_file', 'salt://apache/config/vhosts/standard.tmpl') }}
  16. - template: {{ apache.get('template_engine', 'jinja') }}
  17. - makedirs: True
  18. - context:
  19. apache: {{ apache|json }}
  20. id: {{ id|json }}
  21. site: {{ site|json }}
  22. map: {{ apache|json }}
  23. - require:
  24. - pkg: apache-package-install-pkg-installed
  25. - watch_in:
  26. - module: apache-service-running-reload
  27. - require_in:
  28. - module: apache-service-running-restart
  29. - module: apache-service-running-reload
  30. - service: apache-service-running
  31. {%- if site.get('DocumentRoot') != False %}
  32. apache-config-vhosts-standard-{{ id }}-docroot:
  33. file.directory:
  34. - name: {{ documentroot }}
  35. - makedirs: True
  36. - user: {{ site.get('DocumentRootUser', apache.get('document_root_user'))|json or apache.user }}
  37. - group: {{ site.get('DocumentRootGroup', apache.get('document_root_group'))|json or apache.group }}
  38. - allow_symlink: True
  39. {%- endif %}
  40. {%- if grains.os_family == 'Debian' %}
  41. {%- if site.get('enabled', True) %}
  42. apache-config-vhosts-standard-{{ id }}-cmd-run-a2en:
  43. cmd.run:
  44. - name: a2ensite {{ id }}{{ apache.confext }}
  45. - unless: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
  46. - require:
  47. - file: apache-config-vhosts-standard-{{ id }}
  48. - watch_in:
  49. - module: apache-service-running-reload
  50. - require_in:
  51. - module: apache-service-running-restart
  52. - module: apache-service-running-reload
  53. - service: apache-service-running
  54. {%- else %}
  55. apache-config-vhosts-standard-{{ id }}-cmd-run-a2dis:
  56. cmd.run:
  57. - name: a2dissite {{ id }}{{ apache.confext }}:
  58. - onlyif: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
  59. - require:
  60. - file: apache-config-vhosts-standard-{{ id }}
  61. - watch_in:
  62. - module: apache-service-running-reload
  63. - require_in:
  64. - module: apache-service-running-restart
  65. - module: apache-service-running-reload
  66. - service: apache-service-running
  67. {%- endif %}
  68. {%- endif %} {# Debian #}
  69. {%- endfor %}