fix: case where vault root file not exist

This commit is contained in:
vincent 2024-01-30 18:32:25 +01:00
parent 63cd352fff
commit 13bda4cd34

View File

@ -5,10 +5,15 @@
- role: ansible-hashicorp-vault - role: ansible-hashicorp-vault
become: true become: true
post_tasks: post_tasks:
- name: Stat root file
ansible.builtin.stat:
path: "{{ vault_unseal_keys_dir_output }}/rootkey"
register: rootkey_exist
- name: Reading root contents - name: Reading root contents
ansible.builtin.command: cat "{{ vault_unseal_keys_dir_output }}/rootkey" ansible.builtin.command: cat "{{ vault_unseal_keys_dir_output }}/rootkey"
register: root_token register: root_token
delegate_to: localhost delegate_to: localhost
when: rootkey_exist.stat.exists
changed_when: false changed_when: false
- name: debug - name: debug
ansible.builtin.debug: ansible.builtin.debug:
@ -20,7 +25,7 @@
period: 72h period: 72h
no_parent: true no_parent: true
token: "{{ root_token.stdout }}" token: "{{ root_token.stdout }}"
url: http://{{ ansible_default_ipv4.address }}:8200 url: "{{ vault_api_addr }}"
retries: 4 retries: 4
run_once: true run_once: true
delegate_to: localhost delegate_to: localhost