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.

44 lines
1.4 KiB

  1. ---
  2. - name: cluster/init | wait for vault
  3. command: /bin/true
  4. notify: wait for vault up
  5. - meta: flush_handlers
  6. - name: cluster/init | Initialize Vault
  7. hashivault_init:
  8. url: "https://localhost:{{ vault_port }}/"
  9. ca_cert: "{{ vault_cert_dir }}/ca.pem"
  10. secret_shares: "{{ vault_secret_shares }}"
  11. secret_threshold: "{{ vault_secret_threshold }}"
  12. run_once: true
  13. register: vault_init_result
  14. when: not vault_cluster_is_initialized
  15. - name: cluster/init | Set facts on the results of the initialization
  16. set_fact:
  17. vault_unseal_keys: "{{ vault_init_result.keys_base64 }}"
  18. vault_root_token: "{{ vault_init_result.root_token }}"
  19. vault_headers: "{{ vault_client_headers|combine({'X-Vault-Token': vault_init_result.root_token}) }}"
  20. run_once: true
  21. when: not vault_cluster_is_initialized
  22. - name: cluster/init | Ensure all in groups.vault have the unseal_keys locally
  23. copy:
  24. content: "{{ vault_unseal_keys|join('\n') }}"
  25. dest: "{{ vault_secrets_dir }}/unseal_keys"
  26. mode: 0640
  27. when: not vault_cluster_is_initialized
  28. - name: cluster/init | Ensure all in groups.vault have the root_token locally
  29. copy:
  30. content: "{{ vault_root_token }}"
  31. dest: "{{ vault_secrets_dir }}/root_token"
  32. mode: 0640
  33. when: not vault_cluster_is_initialized
  34. - name: cluster/init | Ensure vault_headers and vault statuses are updated
  35. set_fact:
  36. vault_cluster_is_initialized: true
  37. run_once: true