2017-01-13 20:31:10 +00:00
|
|
|
---
|
2017-02-08 21:41:36 +00:00
|
|
|
- name: bootstrap/start_vault_temp | Ensure vault-temp isn't already running
|
|
|
|
shell: if docker rm -f {{ vault_temp_container_name }} 2>&1 1>/dev/null;then echo true;else echo false;fi
|
2017-01-13 20:31:10 +00:00
|
|
|
register: vault_temp_stop_check
|
2017-04-26 12:11:13 +00:00
|
|
|
changed_when: "'true' in vault_temp_stop_check.stdout"
|
2017-01-13 20:31:10 +00:00
|
|
|
|
|
|
|
- name: bootstrap/start_vault_temp | Start single node Vault with file backend
|
|
|
|
command: >
|
2017-02-08 21:41:36 +00:00
|
|
|
docker run -d --cap-add=IPC_LOCK --name {{ vault_temp_container_name }}
|
|
|
|
-p {{ vault_port }}:{{ vault_port }}
|
2017-01-13 20:31:10 +00:00
|
|
|
-e 'VAULT_LOCAL_CONFIG={{ vault_temp_config|to_json }}'
|
|
|
|
-v /etc/vault:/etc/vault
|
|
|
|
{{ vault_image_repo }}:{{ vault_version }} server
|
|
|
|
|
2017-04-12 10:37:50 +00:00
|
|
|
- name: bootstrap/start_vault_temp | Start again single node Vault with file backend
|
|
|
|
command: docker start {{ vault_temp_container_name }}
|
|
|
|
|
2017-01-13 20:31:10 +00:00
|
|
|
- name: bootstrap/start_vault_temp | Initialize vault-temp
|
2018-05-11 16:11:38 +00:00
|
|
|
hashivault_init:
|
|
|
|
url: "http://localhost:{{ vault_port }}/"
|
|
|
|
secret_shares: 1
|
|
|
|
secret_threshold: 1
|
2018-10-16 22:33:30 +00:00
|
|
|
until: "vault_temp_init is succeeded"
|
2017-12-09 23:39:43 +00:00
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
2017-01-13 20:31:10 +00:00
|
|
|
register: vault_temp_init
|
|
|
|
|
2017-02-08 21:41:36 +00:00
|
|
|
# NOTE: vault_headers and vault_url are used by subsequent issue calls
|
2017-01-13 20:31:10 +00:00
|
|
|
- name: bootstrap/start_vault_temp | Set needed vault facts
|
|
|
|
set_fact:
|
2017-02-08 21:41:36 +00:00
|
|
|
vault_leader_url: "http://{{ inventory_hostname }}:{{ vault_port }}"
|
2018-05-11 16:11:38 +00:00
|
|
|
vault_temp_unseal_keys: "{{ vault_temp_init.keys_base64 }}"
|
|
|
|
vault_root_token: "{{ vault_temp_init.root_token }}"
|
|
|
|
vault_headers: "{{ vault_client_headers|combine({'X-Vault-Token': vault_temp_init.root_token}) }}"
|
2017-01-13 20:31:10 +00:00
|
|
|
|
|
|
|
- name: bootstrap/start_vault_temp | Unseal vault-temp
|
2018-05-11 16:11:38 +00:00
|
|
|
hashivault_unseal:
|
|
|
|
url: "http://localhost:{{ vault_port }}/"
|
|
|
|
token: "{{ vault_root_token }}"
|
|
|
|
keys: "{{ item }}"
|
2017-01-13 20:31:10 +00:00
|
|
|
with_items: "{{ vault_temp_unseal_keys|default([]) }}"
|
2018-05-11 16:11:38 +00:00
|
|
|
no_log: true
|