2017-01-13 20:31:10 +00:00
|
|
|
---
|
|
|
|
|
2018-05-11 16:11:38 +00:00
|
|
|
- name: cluster/init | wait for vault
|
|
|
|
command: /bin/true
|
|
|
|
notify: wait for vault up
|
|
|
|
|
|
|
|
- meta: flush_handlers
|
|
|
|
|
2017-01-13 20:31:10 +00:00
|
|
|
- name: cluster/init | Initialize Vault
|
2018-05-11 16:11:38 +00:00
|
|
|
hashivault_init:
|
|
|
|
url: "https://localhost:{{ vault_port }}/"
|
|
|
|
ca_cert: "{{ vault_cert_dir }}/ca.pem"
|
|
|
|
secret_shares: "{{ vault_secret_shares }}"
|
|
|
|
secret_threshold: "{{ vault_secret_threshold }}"
|
|
|
|
run_once: true
|
2017-01-13 20:31:10 +00:00
|
|
|
register: vault_init_result
|
2018-05-11 16:11:38 +00:00
|
|
|
when: not vault_cluster_is_initialized
|
2017-01-13 20:31:10 +00:00
|
|
|
|
|
|
|
- name: cluster/init | Set facts on the results of the initialization
|
|
|
|
set_fact:
|
2018-05-11 16:11:38 +00:00
|
|
|
vault_unseal_keys: "{{ vault_init_result.keys_base64 }}"
|
|
|
|
vault_root_token: "{{ vault_init_result.root_token }}"
|
|
|
|
vault_headers: "{{ vault_client_headers|combine({'X-Vault-Token': vault_init_result.root_token}) }}"
|
|
|
|
run_once: true
|
|
|
|
when: not vault_cluster_is_initialized
|
2017-01-13 20:31:10 +00:00
|
|
|
|
|
|
|
- name: cluster/init | Ensure all in groups.vault have the unseal_keys locally
|
|
|
|
copy:
|
|
|
|
content: "{{ vault_unseal_keys|join('\n') }}"
|
|
|
|
dest: "{{ vault_secrets_dir }}/unseal_keys"
|
2017-02-08 21:41:36 +00:00
|
|
|
mode: 0640
|
2017-01-13 20:31:10 +00:00
|
|
|
when: not vault_cluster_is_initialized
|
|
|
|
|
|
|
|
- name: cluster/init | Ensure all in groups.vault have the root_token locally
|
|
|
|
copy:
|
|
|
|
content: "{{ vault_root_token }}"
|
|
|
|
dest: "{{ vault_secrets_dir }}/root_token"
|
2017-02-08 21:41:36 +00:00
|
|
|
mode: 0640
|
2017-01-13 20:31:10 +00:00
|
|
|
when: not vault_cluster_is_initialized
|
|
|
|
|
|
|
|
- name: cluster/init | Ensure vault_headers and vault statuses are updated
|
|
|
|
set_fact:
|
|
|
|
vault_cluster_is_initialized: true
|
2018-05-11 16:11:38 +00:00
|
|
|
run_once: true
|