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.

52 lines
1.9 KiB

  1. ---
  2. - include_tasks: ../shared/sync_file.yml
  3. vars:
  4. sync_file: "{{ item }}"
  5. sync_file_dir: "{{ vault_secrets_dir }}"
  6. sync_file_hosts: "{{ groups.vault }}"
  7. with_items:
  8. - root_token
  9. - unseal_keys
  10. - name: bootstrap/sync_secrets | Set fact based on sync_file_results
  11. set_fact:
  12. vault_secrets_available: "{{ vault_secrets_available|default(true) and not item.no_srcs }}"
  13. with_items: "{{ sync_file_results|d([]) }}"
  14. - name: bootstrap/sync_secrets | Reset sync_file_results to avoid variable bleed
  15. set_fact:
  16. sync_file_results: []
  17. - name: bootstrap/sync_secrets | Print out warning message if secrets are not available and vault is initialized
  18. pause:
  19. prompt: >
  20. Vault orchestration may not be able to proceed. The Vault cluster is initialzed, but
  21. 'root_token' or 'unseal_keys' were not found in {{ vault_secrets_dir }}. These are
  22. needed for many vault orchestration steps.
  23. when: vault_cluster_is_initialized and not vault_secrets_available
  24. - name: bootstrap/sync_secrets | Cat root_token from a vault host
  25. command: "cat {{ vault_secrets_dir }}/root_token"
  26. register: vault_root_token_cat
  27. run_once: yes
  28. when: vault_secrets_available
  29. - name: bootstrap/sync_secrets | Cat unseal_keys from a vault host
  30. command: "cat {{ vault_secrets_dir }}/unseal_keys"
  31. register: vault_unseal_keys_cat
  32. run_once: yes
  33. when: vault_secrets_available
  34. - name: bootstrap/sync_secrets | Set needed facts for Vault API interaction when Vault is already running
  35. set_fact:
  36. vault_root_token: "{{ vault_root_token_cat.stdout }}"
  37. vault_unseal_keys: "{{ vault_unseal_keys_cat.stdout_lines }}"
  38. run_once: yes
  39. when: vault_secrets_available
  40. # FIXME: Remove all uri calls
  41. - name: bootstrap/sync_secrets | Update vault_headers if we have the root_token
  42. set_fact:
  43. vault_headers: "{{ vault_client_headers | combine({'X-Vault-Token': vault_root_token}) }}"
  44. when: vault_secrets_available