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.

52 lines
1.3KB

  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. {{ id }}-documentroot:
  21. file.directory:
  22. - unless: test -d {{ documentroot }}
  23. - name: {{ documentroot }}
  24. - makedirs: True
  25. {% if grains.os_family == 'Debian' %}
  26. {% if site.get('enabled') %}
  27. a2ensite {{ id }}{{ apache.confext }}:
  28. cmd:
  29. - run
  30. - unless: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
  31. - require:
  32. - file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
  33. - watch_in:
  34. - module: apache-reload
  35. {% else %}
  36. a2dissite {{ id }}{{ apache.confext }}:
  37. cmd:
  38. - run
  39. - require:
  40. - file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
  41. - watch_in:
  42. - module: apache-reload
  43. {% endif %}
  44. {% endif %}
  45. {% endfor %}