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.

54 line
1.5KB

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