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.

63 lines
1.6KB

  1. {% from 'icinga2/map.jinja' import icinga2 with context %}
  2. include:
  3. - icinga2.pki
  4. {% set fqdn = salt.grains.get('fqdn') %}
  5. # Get ca certificate from mine
  6. icinga2_node_ca_cert:
  7. x509.pem_managed:
  8. - name: {{icinga2.pki_dir}}/ca.crt
  9. - text: {{ salt['mine.get'](icinga2.master_minion_id, 'icinga2_ca_cert')[icinga2.master_minion_id]|replace('\n', '') }}
  10. - require:
  11. - file: icinga2_pki_dir
  12. icinga2_node_ca_cert_perms:
  13. file.managed:
  14. - name: {{icinga2.pki_dir}}/ca.crt
  15. - user: {{icinga2.user}}
  16. - group: {{icinga2.group}}
  17. - watch:
  18. - x509: icinga2_node_ca_cert
  19. # Create the key
  20. icinga2_node_key:
  21. x509.private_key_managed:
  22. - name: {{icinga2.pki_dir}}/{{fqdn}}.key
  23. - bits: 4096
  24. - backup: True
  25. - require:
  26. - file: icinga2_pki_dir
  27. icinga2_node_key_perms:
  28. file.managed:
  29. - name: {{icinga2.pki_dir}}/{{fqdn}}.key
  30. - user: {{icinga2.user}}
  31. - group: {{icinga2.group}}
  32. - mode: 600
  33. - watch:
  34. - x509: icinga2_node_key
  35. # Create the certificate, send it to ca_server to be signed and store it as crt
  36. icinga2_node_cert:
  37. x509.certificate_managed:
  38. - name: {{icinga2.pki_dir}}/{{fqdn}}.crt
  39. - ca_server: {{icinga2.master_minion_id}}
  40. - signing_policy: icinga2
  41. - public_key: {{icinga2.pki_dir}}/{{fqdn}}.key
  42. - CN: {{fqdn}}
  43. - backup: True
  44. - require:
  45. - x509: icinga2_node_key
  46. - onchanges:
  47. - x509: icinga2_node_ca_cert
  48. icinga2_node_cert_perms:
  49. file.managed:
  50. - name: {{icinga2.pki_dir}}/{{fqdn}}.crt
  51. - user: {{icinga2.user}}
  52. - group: {{icinga2.group}}
  53. - watch:
  54. - x509: icinga2_node_cert