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