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.

57 lines
1.5KB

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