init.sls 872 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #
  2. # Nginx
  3. #
  4. {% set nginx_pkg = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':nginx:pkg', 'nginx') %}
  5. nginx:
  6. pkg.installed:
  7. - name: {{nginx_pkg}}
  8. {% if grains['oscodename'] == 'jessie' %}
  9. - fromrepo: jessie-backports
  10. {% endif %}
  11. service.running:
  12. - enable: TRUE
  13. - reload: TRUE
  14. - watch:
  15. - file: /etc/nginx/sites-*
  16. file.absent:
  17. - name: /etc/nginx/sites-enabled/default
  18. {% if grains['saltversion'] >= '2014.7.0' %}
  19. nginx-dhparam:
  20. cmd.run:
  21. - name: openssl dhparam -out /etc/ssl/dhparam.pem 4096
  22. - creates: /etc/ssl/dhparam
  23. - require_in:
  24. - serivce: nginx
  25. {% endif %}
  26. {% for website in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':nginx:websites', []) %}
  27. /etc/nginx/sites-enabled/{{website}}:
  28. file.managed:
  29. - source: salt://nginx/{{website}}
  30. - template: jinja
  31. - require:
  32. - pkg: nginx
  33. {% endfor %}