2023-12-15 17:45:58 +00:00
|
|
|
---
|
|
|
|
# hashistack deployment playbook
|
|
|
|
- name: "Deploy"
|
|
|
|
hosts: all
|
|
|
|
gather_facts: true
|
2023-12-24 17:09:08 +00:00
|
|
|
become: true
|
2023-12-15 17:45:58 +00:00
|
|
|
tasks:
|
2024-01-01 20:16:44 +00:00
|
|
|
- name: "debug"
|
2023-12-31 17:28:23 +00:00
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "{{ hashi_vault_configuration.listener }}"
|
2024-01-02 20:11:32 +00:00
|
|
|
|
2023-12-30 14:54:37 +00:00
|
|
|
- name: "Vault"
|
|
|
|
when: enable_vault | bool
|
2024-01-01 20:16:44 +00:00
|
|
|
when: "'vault_servers' in group_names"
|
2023-12-30 14:54:37 +00:00
|
|
|
tags:
|
|
|
|
- vault
|
|
|
|
block:
|
|
|
|
- name: "Include ednxzu.hashicorp_vault"
|
|
|
|
ansible.builtin.include_role:
|
|
|
|
name: ednxzu.hashistack.hashicorp_vault
|
2023-12-24 17:09:08 +00:00
|
|
|
|
2023-12-30 14:54:37 +00:00
|
|
|
- name: "Initialize vault cluster"
|
|
|
|
ednxzu.hashistack.vault_init:
|
2023-12-31 09:26:25 +00:00
|
|
|
api_url: "{{ hashi_vault_configuration['api_addr'] }}"
|
2023-12-30 14:54:37 +00:00
|
|
|
key_shares: 3
|
|
|
|
key_threshold: 2
|
|
|
|
run_once: true
|
|
|
|
retries: 5
|
|
|
|
delay: 5
|
|
|
|
delegate_to: "{{ groups['vault_servers'] | first }}"
|
|
|
|
register: _vault_init_secret
|
|
|
|
until: not _vault_init_secret.failed
|
2023-12-28 21:38:26 +00:00
|
|
|
|
2023-12-30 14:54:37 +00:00
|
|
|
- name: "Write vault configuration to file"
|
|
|
|
ansible.builtin.copy:
|
|
|
|
content: "{{ _vault_init_secret.state | to_nice_yaml}}"
|
|
|
|
dest: "{{ configuration_directory }}/vault/vault_config"
|
|
|
|
mode: '0644'
|
|
|
|
when: _vault_init_secret.changed
|
|
|
|
run_once: true
|
|
|
|
delegate_to: localhost
|
2023-12-28 22:10:17 +00:00
|
|
|
|
2023-12-30 14:54:37 +00:00
|
|
|
- name: "Load vault cluster variables necessary for unseal operation"
|
|
|
|
ansible.builtin.include_vars:
|
|
|
|
file: "{{ configuration_directory }}/vault/vault_config"
|
|
|
|
name: _vault_cluster_config
|
2023-12-29 11:51:00 +00:00
|
|
|
|
2023-12-30 14:54:37 +00:00
|
|
|
- name: "Unseal the bootstrap node"
|
|
|
|
ednxzu.hashistack.vault_unseal:
|
2023-12-31 09:26:25 +00:00
|
|
|
api_url: "{{ hashi_vault_configuration['api_addr'] }}"
|
2023-12-30 14:54:37 +00:00
|
|
|
key_shares: "{{ _vault_cluster_config['keys'] }}"
|
|
|
|
max_retries: "{{ (_vault_cluster_config['keys'] | length) - 1 }}"
|
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups['vault_servers'] | first }}"
|
|
|
|
when: _vault_init_secret.changed
|
2023-12-29 11:51:00 +00:00
|
|
|
|
2023-12-30 14:54:37 +00:00
|
|
|
- name: "Unseal all vault nodes"
|
|
|
|
ednxzu.hashistack.vault_unseal:
|
2023-12-31 09:26:25 +00:00
|
|
|
api_url: "{{ hashi_vault_configuration['api_addr'] }}"
|
2023-12-30 14:54:37 +00:00
|
|
|
key_shares: "{{ _vault_cluster_config['keys'] }}"
|
|
|
|
max_retries: "{{ (_vault_cluster_config['keys'] | length) - 1 }}"
|
|
|
|
retries: 5
|
|
|
|
delay: 5
|
|
|
|
register: _unseal_status
|
|
|
|
until: not _unseal_status.failed
|