Saltstack Official Nginx 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.

48 lines
1.5KB

  1. {% from 'nginx/ng/map.jinja' import nginx with context %}
  2. include:
  3. - nginx.ng.service
  4. {% set certificates_path = salt['pillar.get']('nginx:ng:certificates_path', '/etc/nginx/ssl') %}
  5. {% if salt.pillar.get('nginx:ng:dh_contents') %}
  6. create_nginx_dhparam_key:
  7. file.managed:
  8. - name: {{ certificates_path }}/dhparam.pem
  9. - contents_pillar: nginx:ng:dh_contents
  10. - makedirs: True
  11. {% elif salt.pillar.get('nginx:ng:dh_keygen', False) %}
  12. generate_nginx_dhparam_key:
  13. pkg.installed:
  14. - name: {{ nginx.lookup.openssl_package }}
  15. file.directory:
  16. - name: {{ certificates_path }}
  17. - makedirs: True
  18. cmd.run:
  19. - name: openssl dhparam -out dhparam.pem {{ salt.pillar.get('nginx:ng:dh_keysize', 2048) }}
  20. - cwd: {{ certificates_path }}
  21. - creates: {{ certificates_path }}/dhparam.pem
  22. {% endif %}
  23. {%- for domain in salt['pillar.get']('nginx:ng:certificates', {}).keys() %}
  24. nginx_{{ domain }}_ssl_certificate:
  25. file.managed:
  26. - name: {{ certificates_path }}/{{ domain }}.crt
  27. - makedirs: True
  28. - contents_pillar: nginx:ng:certificates:{{ domain }}:public_cert
  29. - watch_in:
  30. - service: nginx_service
  31. {% if salt['pillar.get']("nginx:ng:certificates:{}:private_key".format(domain)) %}
  32. nginx_{{ domain }}_ssl_key:
  33. file.managed:
  34. - name: {{ certificates_path }}/{{ domain }}.key
  35. - mode: 600
  36. - makedirs: True
  37. - contents_pillar: nginx:ng:certificates:{{ domain }}:private_key
  38. - watch_in:
  39. - service: nginx_service
  40. {% endif %}
  41. {%- endfor %}