New version of salt-formula from Saltstack
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.

45 lines
1.2KB

  1. {%- from "salt/map.jinja" import minion with context %}
  2. {%- if minion.enabled %}
  3. {%- for cert_name,cert in minion.get('cert', {}).iteritems() %}
  4. {%- set rowloop = loop %}
  5. /etc/ssl/private/{{ cert.common_name }}.key:
  6. x509.private_key_managed:
  7. - bits: 4096
  8. {{ cert.common_name }}_rights:
  9. file.managed:
  10. - name: /etc/ssl/private/{{ cert.common_name }}.key
  11. - mode: 600
  12. - require:
  13. - x509: /etc/ssl/private/{{ cert.common_name }}.key
  14. /etc/ssl/certs/{{ cert.common_name }}.crt:
  15. x509.certificate_managed:
  16. - ca_server: {{ cert.host }}
  17. - signing_policy: {{ cert.authority }}_{{ cert.signing_policy }}
  18. - public_key: /etc/ssl/private/{{ cert.common_name }}.key
  19. - CN: {{ cert.common_name }}
  20. {%- if cert.alternative_names is defined %}
  21. - subjectAltName: {{ cert.alternative_names }}
  22. {%- endif %}
  23. - days_remaining: 30
  24. - backup: True
  25. {%- for ca_path,ca_cert in salt['mine.get'](cert.host, 'x509.get_pem_entries')[cert.host].iteritems() %}
  26. {%- if '/etc/pki/ca/'+cert.authority in ca_path %}
  27. ca_cert_{{ cert.authority }}_{{ rowloop.index }}:
  28. x509.pem_managed:
  29. - name: /etc/ssl/certs/ca-{{ cert.authority }}.crt
  30. - text: {{ ca_cert|replace('\n', '') }}
  31. {%- endif %}
  32. {%- endfor %}
  33. {%- endfor %}
  34. {%- endif %}