2024-04-01 21:59:48 +00:00
|
|
|
---
|
2024-03-13 22:27:12 +00:00
|
|
|
- name: "Vault"
|
|
|
|
block:
|
|
|
|
- name: "Include ednz_cloud.hashistack.hashicorp_consul"
|
|
|
|
ansible.builtin.include_role:
|
|
|
|
name: ednz_cloud.hashistack.hashicorp_vault
|
|
|
|
|
|
|
|
- name: "Initialize vault cluster" # noqa: run-once[task]
|
|
|
|
ednz_cloud.hashistack.vault_init:
|
|
|
|
api_url: "{{ hashi_vault_configuration['api_addr'] }}"
|
2024-04-06 21:47:35 +00:00
|
|
|
tls_verify: "{{ vault_tls_verify }}"
|
2024-03-13 22:27:12 +00:00
|
|
|
key_shares: "{{ vault_seal_configuration['key_shares'] }}"
|
|
|
|
key_threshold: "{{ vault_seal_configuration['key_threshold'] }}"
|
|
|
|
run_once: true
|
|
|
|
retries: 5
|
|
|
|
delay: 5
|
|
|
|
delegate_to: "{{ groups['vault_servers'] | first }}"
|
|
|
|
register: _vault_init_secret
|
|
|
|
until: not _vault_init_secret.failed
|
|
|
|
|
|
|
|
- name: "Write vault configuration to file" # noqa: run-once[task] no-handler
|
|
|
|
ansible.builtin.copy:
|
2024-05-03 20:23:47 +00:00
|
|
|
content: "{{ _vault_init_secret.state | to_nice_yaml(indent=2) }}"
|
|
|
|
dest: "{{ sub_configuration_directories.secrets }}/vault.yml"
|
2024-03-13 22:27:12 +00:00
|
|
|
owner: "{{ lookup('env', 'USER') }}"
|
|
|
|
group: "{{ lookup('env', 'USER') }}"
|
|
|
|
mode: "0644"
|
|
|
|
when: _vault_init_secret.changed
|
|
|
|
run_once: true
|
|
|
|
delegate_to: localhost
|
|
|
|
|
2024-05-03 20:23:47 +00:00
|
|
|
# - name: "Load vault cluster variables necessary for unseal operation"
|
|
|
|
# ansible.builtin.include_vars:
|
|
|
|
# file: "{{ sub_configuration_directories.vault_servers }}/vault_config.yml"
|
|
|
|
# name: _vault_cluster_config
|
|
|
|
|
2024-03-13 22:27:12 +00:00
|
|
|
- name: "Load vault cluster variables necessary for unseal operation"
|
2024-05-03 20:23:47 +00:00
|
|
|
ansible.builtin.import_tasks:
|
|
|
|
file: ../misc/load_credentials_vars.yml
|
2024-03-13 22:27:12 +00:00
|
|
|
|
|
|
|
- name: "Unseal the bootstrap node" # noqa: run-once[task] no-handler
|
|
|
|
ednz_cloud.hashistack.vault_unseal:
|
|
|
|
api_url: "{{ hashi_vault_configuration['api_addr'] }}"
|
2024-04-06 21:47:35 +00:00
|
|
|
tls_verify: "{{ vault_tls_verify }}"
|
2024-05-03 20:23:47 +00:00
|
|
|
key_shares: "{{ _credentials.vault['keys'] }}"
|
2024-03-13 22:27:12 +00:00
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups['vault_servers'] | first }}"
|
|
|
|
when: _vault_init_secret.changed
|
|
|
|
register: _vault_unseal_secret
|
|
|
|
|
|
|
|
- name: "Unseal all vault nodes"
|
|
|
|
ednz_cloud.hashistack.vault_unseal:
|
|
|
|
api_url: "{{ hashi_vault_configuration['api_addr'] }}"
|
2024-04-06 21:47:35 +00:00
|
|
|
tls_verify: "{{ vault_tls_verify }}"
|
2024-05-03 20:23:47 +00:00
|
|
|
key_shares: "{{ _credentials.vault['keys'] }}"
|
2024-03-13 22:27:12 +00:00
|
|
|
retries: 5
|
|
|
|
delay: 5
|
2024-04-01 21:59:48 +00:00
|
|
|
until: _unseal_status.changed or not _unseal_status.failed
|
2024-03-13 22:27:12 +00:00
|
|
|
register: _unseal_status
|