From c230e05aa85d276e4be5a2b7498f58110ec88f45 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Tue, 27 Sep 2022 21:59:37 -0700 Subject: [PATCH] Better first run bootstrap --- nomad/bootstrap-values.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/nomad/bootstrap-values.yml b/nomad/bootstrap-values.yml index f1c40f0..1143c85 100644 --- a/nomad/bootstrap-values.yml +++ b/nomad/bootstrap-values.yml @@ -40,9 +40,23 @@ name: hvac extra_args: --index-url https://pypi.org/simple - # This fails on first run because `root_token` isn't found - # Fails after taht too because the kv/ space has not been created yet either! Oh noes! - # Maybe move data bootstrapping to after the cluster is bootstrapped + - name: Check mount + community.hashi_vault.vault_read: + url: "http://{{ inventory_hostname }}:8200" + token: "{{ root_token }}" + path: "/sys/mounts/kv" + ignore_errors: true + register: check_mount + + - name: Create kv mount + community.hashi_vault.vault_write: + url: "http://{{ inventory_hostname }}:8200" + token: "{{ root_token }}" + path: "/sys/mounts/kv" + data: + type: kv-v2 + when: check_mount is not succeeded + - name: Write values no_log: true community.hashi_vault.vault_write: @@ -53,6 +67,8 @@ data: "{{ item.value }}" loop: "{{ hashi_vault_values | default({}) | dict2items }}" + retries: 2 + delay: 5 - name: Write userpass no_log: true