From 141b53b809b4d81eafcac09a62ae5755ff43a72c Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Wed, 7 Sep 2022 11:05:27 -0700 Subject: [PATCH] Add playbook to unseal Vault --- Makefile | 5 +++++ unseal-vault.yml | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 unseal-vault.yml diff --git a/Makefile b/Makefile index 01b48c6..e4d1f47 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,11 @@ bootstrap-values: venv/bin/ansible galaxy $(shell test -f vault-keys.json && echo '-e "@vault-keys.json"') \ -i ansible_hosts.yml -M ./roles ./bootstrap-values.yml +.PHONY: unseal-vault +unseal-vault: venv/bin/ansible galaxy + env VIRTUAL_ENV=/Users/ifij/workspace/iamthefij/orchestration-tests/nomad/venv ./venv/bin/ansible-playbook -K -vv \ + -e "@vault-keys.json" -i ansible_hosts.yml -M ./roles ./unseal-vault.yml + .PHONY: init init: @terraform init diff --git a/unseal-vault.yml b/unseal-vault.yml new file mode 100644 index 0000000..db24e89 --- /dev/null +++ b/unseal-vault.yml @@ -0,0 +1,27 @@ +--- +- name: Unseal Vault + hosts: vault_instances + + tasks: + - name: Get Vault status + uri: + url: http://127.0.0.1:8200/v1/sys/health + method: GET + status_code: 200, 429, 472, 473, 501, 503 + body_format: json + return_content: true + register: vault_status + + - name: Unseal Vault + no_log: true + command: + argv: + - "vault" + - "operator" + - "unseal" + - "-address=http://127.0.0.1:8200/" + - "{{ item }}" + loop: "{{ unseal_keys_hex }}" + when: + - unseal_keys_hex is defined + - vault_status.json["sealed"]