Saltstack Official Nginx Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

56 行
1.7KB

  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. {%- for dh_param, value in salt['pillar.get']('nginx:ng:dh_param', {}).items() %}
  6. {%- if value is string %}
  7. create_nginx_dhparam_{{ dh_param }}_key:
  8. file.managed:
  9. - name: {{ certificates_path }}/{{ dh_param }}
  10. - contents_pillar: nginx:ng:dh_param:{{ dh_param }}
  11. - makedirs: True
  12. - watch_in:
  13. - service: nginx_service
  14. {%- else %}
  15. generate_nginx_dhparam_{{ dh_param }}_key:
  16. pkg.installed:
  17. - name: {{ nginx.lookup.openssl_package }}
  18. file.directory:
  19. - name: {{ certificates_path }}
  20. - makedirs: True
  21. cmd.run:
  22. - name: openssl dhparam -out {{ dh_param }} {{ value.get('keysize', 2048) }}
  23. - cwd: {{ certificates_path }}
  24. - creates: {{ certificates_path }}/{{ dh_param }}
  25. - watch_in:
  26. - service: nginx_service
  27. {%- endif %}
  28. {%- endfor %}
  29. {% if salt['pillar.get']('nginx:ng:certificates') is defined and salt['pillar.get']('nginx:ng:certificates') %}
  30. {%- for domain in salt['pillar.get']('nginx:ng:certificates', {}).keys() %}
  31. nginx_{{ domain }}_ssl_certificate:
  32. file.managed:
  33. - name: {{ certificates_path }}/{{ domain }}.crt
  34. - makedirs: True
  35. - contents_pillar: nginx:ng:certificates:{{ domain }}:public_cert
  36. - watch_in:
  37. - service: nginx_service
  38. {% if salt['pillar.get']("nginx:ng:certificates:{}:private_key".format(domain)) %}
  39. nginx_{{ domain }}_ssl_key:
  40. file.managed:
  41. - name: {{ certificates_path }}/{{ domain }}.key
  42. - mode: 600
  43. - makedirs: True
  44. - contents_pillar: nginx:ng:certificates:{{ domain }}:private_key
  45. - watch_in:
  46. - service: nginx_service
  47. {% endif %}
  48. {%- endfor %}
  49. {% endif %}