feat(vars): add check to load global vars file before running deployment

This commit is contained in:
Bertrand Lanson 2024-01-02 21:11:32 +01:00
parent 27df88ae09
commit 34bb4bd7ad
2 changed files with 16 additions and 3 deletions

View File

@ -8,6 +8,7 @@
- name: "debug" - name: "debug"
ansible.builtin.debug: ansible.builtin.debug:
msg: "{{ hashi_vault_configuration.listener }}" msg: "{{ hashi_vault_configuration.listener }}"
- name: "Vault" - name: "Vault"
when: enable_vault | bool when: enable_vault | bool
when: "'vault_servers' in group_names" when: "'vault_servers' in group_names"

View File

@ -6,9 +6,21 @@
become: true become: true
tasks: tasks:
- name: "Load global variables" - name: "Load global variables"
ansible.builtin.include_vars: block:
dir: "{{ configuration_directory }}" - name: "Stat global configuration file"
files_matching: "{{ configuration_global_vars_file }}" ansible.builtin.stat:
path: "{{ configuration_directory }}/{{ configuration_global_vars_file }}"
register: _global_config_file
- name: "Make sure global configuration file exists"
ansible.builtin.assert:
that:
- _global_config_file.stat.exists
- name: "Load global variables"
ansible.builtin.include_vars:
dir: "{{ configuration_directory }}"
files_matching: "{{ configuration_global_vars_file }}"
- name: "Load group specific variables" - name: "Load group specific variables"
ansible.builtin.include_vars: ansible.builtin.include_vars: