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.

72 lines
1.7KB

  1. {%- from "salt/map.jinja" import minion with context %}
  2. {%- if minion.enabled %}
  3. include:
  4. - salt.minion.service
  5. /etc/salt/minion.d/_pki.conf:
  6. file.managed:
  7. - source: salt://salt/files/_pki.conf
  8. - template: jinja
  9. - require:
  10. - {{ minion.install_state }}
  11. {%- if not grains.get('noservices', False) %}
  12. - watch_in:
  13. - service: salt_minion_service
  14. {%- endif %}
  15. {%- for ca_name,ca in minion.ca.iteritems() %}
  16. /etc/pki/ca/{{ ca_name }}/certs:
  17. file.directory:
  18. - makedirs: true
  19. /etc/pki/ca/{{ ca_name }}/ca.key:
  20. x509.private_key_managed:
  21. - bits: 4096
  22. - backup: True
  23. - require:
  24. - file: /etc/pki/ca/{{ ca_name }}/certs
  25. /etc/pki/ca/{{ ca_name }}/ca.crt:
  26. x509.certificate_managed:
  27. - signing_private_key: /etc/pki/ca/{{ ca_name }}/ca.key
  28. - CN: "{{ ca.common_name }}"
  29. {%- if ca.country is defined %}
  30. - C: {{ ca.country }}
  31. {%- endif %}
  32. {%- if ca.state is defined %}
  33. - ST: {{ ca.state }}
  34. {%- endif %}
  35. {%- if ca.locality is defined %}
  36. - L: {{ ca.locality }}
  37. {%- endif %}
  38. {%- if ca.organization is defined %}
  39. - O: {{ ca.organization }}
  40. {%- endif %}
  41. {%- if ca.organization_unit is defined %}
  42. - OU: {{ ca.organization_unit }}
  43. {%- endif %}
  44. - basicConstraints: "critical,CA:TRUE"
  45. - keyUsage: "critical,cRLSign,keyCertSign"
  46. - subjectKeyIdentifier: hash
  47. - authorityKeyIdentifier: keyid,issuer:always
  48. - days_valid: {{ ca.days_valid.authority }}
  49. - days_remaining: 0
  50. - backup: True
  51. - require:
  52. - x509: /etc/pki/ca/{{ ca_name }}/ca.key
  53. salt_system_ca_mine_send_ca_{{ ca_name }}:
  54. module.run:
  55. - name: mine.send
  56. - func: x509.get_pem_entries
  57. - kwargs:
  58. glob_path: /etc/pki/ca/{{ ca_name }}/ca.crt
  59. - require:
  60. - x509: /etc/pki/ca/{{ ca_name }}/ca.crt
  61. {%- endfor %}
  62. {%- endif %}