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.

32 lines
1.1 KiB

  1. ---
  2. - name: "bootstrap/gen_ca | Ensure cert_dir {{ gen_ca_cert_dir }} exists"
  3. file:
  4. mode: 0755
  5. path: "{{ gen_ca_cert_dir }}"
  6. state: directory
  7. - name: "bootstrap/gen_ca | Generate {{ gen_ca_mount_path }} root CA"
  8. uri:
  9. url: "{{ vault_leader_url }}/v1/{{ gen_ca_mount_path }}/root/generate/exported"
  10. headers: "{{ gen_ca_vault_headers }}"
  11. method: POST
  12. body_format: json
  13. body: "{{ gen_ca_vault_options }}"
  14. status_code: 200,204
  15. register: vault_ca_gen
  16. delegate_to: "{{ groups.vault|first }}"
  17. run_once: true
  18. - name: "bootstrap/gen_ca | Copy {{ gen_ca_mount_path }} root CA cert locally"
  19. copy:
  20. content: "{{ hostvars[groups.vault|first]['vault_ca_gen']['json']['data']['certificate'] }}"
  21. dest: "{{ gen_ca_cert_dir }}/ca.pem"
  22. mode: 0644
  23. when: vault_ca_gen.status == 200
  24. - name: "bootstrap/gen_ca | Copy {{ gen_ca_mount_path }} root CA key locally"
  25. copy:
  26. content: "{{ hostvars[groups.vault|first]['vault_ca_gen']['json']['data']['private_key'] }}"
  27. dest: "{{ gen_ca_cert_dir }}/ca-key.pem"
  28. mode: 0640
  29. when: vault_ca_gen.status == 200