Saltstack Official Apache Formula
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

55 rindas
1.6KB

  1. {% from "apache/map.jinja" import apache with context %}
  2. include:
  3. - apache
  4. {% for id, site in salt['pillar.get']('apache:sites', {}).items() %}
  5. {% set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, id)) %}
  6. {{ id }}:
  7. file:
  8. - managed
  9. - name: {{ apache.vhostdir }}/{{ id }}{{ apache.confext }}
  10. - source: {{ site.get('template_file', 'salt://apache/vhosts/standard.tmpl') }}
  11. - template: {{ site.get('template_engine', 'jinja') }}
  12. - context:
  13. id: {{ id|json }}
  14. site: {{ site|json }}
  15. map: {{ apache|json }}
  16. - require:
  17. - pkg: apache
  18. - watch_in:
  19. - module: apache-reload
  20. {% if site.get('DocumentRoot') != False %}
  21. {{ id }}-documentroot:
  22. file.directory:
  23. - name: {{ documentroot }}
  24. - makedirs: True
  25. - user: {{ site.get('DocumentRootUser', apache.get('document_root_user'))|json }}
  26. - group: {{ site.get('DocumentRootGroup', apache.get('document_root_group'))|json }}
  27. - allow_symlink: True
  28. {% endif %}
  29. {% if grains.os_family == 'Debian' %}
  30. {% if site.get('enabled', True) %}
  31. a2ensite {{ id }}{{ apache.confext }}:
  32. cmd.run:
  33. - unless: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
  34. - require:
  35. - file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
  36. - watch_in:
  37. - module: apache-reload
  38. {% else %}
  39. a2dissite {{ id }}{{ apache.confext }}:
  40. cmd.run:
  41. - onlyif: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
  42. - require:
  43. - file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
  44. - watch_in:
  45. - module: apache-reload
  46. {% endif %}
  47. {% endif %}
  48. {% endfor %}