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.

69 lines
1.6KB

  1. {% from 'icinga2/map.jinja' import icinga2 with context %}
  2. include:
  3. - icinga2.pki
  4. icinga2_ca_dir:
  5. file.directory:
  6. - name: {{icinga2.ca_dir}}
  7. - user: {{icinga2.user}}
  8. - group: {{icinga2.group}}
  9. icinga2_ca_key:
  10. x509.private_key_managed:
  11. - name: {{icinga2.ca_dir}}/ca.key
  12. - bits: 4096
  13. - backup: True
  14. - require:
  15. - file: icinga2_ca_dir
  16. icinga2_ca_key_perms:
  17. file.managed:
  18. - name: {{icinga2.ca_dir}}/ca.key
  19. - user: {{icinga2.user}}
  20. - group: {{icinga2.group}}
  21. - mode: 600
  22. - watch:
  23. - x509: icinga2_ca_key
  24. icinga2_ca_cert:
  25. x509.certificate_managed:
  26. - name: {{icinga2.ca_dir}}/ca.crt
  27. - signing_private_key: {{icinga2.ca_dir}}/ca.key
  28. - CN: 'Icinga2 CA'
  29. - basicConstraints: "critical CA:true"
  30. - days_valid: 3650
  31. - backup: True
  32. - require:
  33. - x509: icinga2_ca_key
  34. icinga2_ca_cert_perms:
  35. file.managed:
  36. - name: {{icinga2.ca_dir}}/ca.crt
  37. - user: {{icinga2.user}}
  38. - group: {{icinga2.group}}
  39. - watch:
  40. - x509: icinga2_ca_cert
  41. /etc/salt/minion.d/signing_policies.conf:
  42. file.managed:
  43. - source: salt://icinga2/pki/signing_policies.conf
  44. - template: jinja
  45. - require:
  46. - x509: icinga2_ca_cert
  47. # Restart the salt minion if the signing_policies changes
  48. icinga2_restart_ca_minion:
  49. module.wait:
  50. - name: service.restart
  51. - m_name: salt-minion
  52. - watch:
  53. - file: /etc/salt/minion.d/signing_policies.conf
  54. # Save the ca certificate in mine so the minions can collect it
  55. icinga2_mine_ca_cert:
  56. module.run:
  57. - name: mine.update
  58. - onchanges:
  59. - x509: icinga2_ca_cert