From a4a3703a2a56ac639467b6d746bd55b6014b274b Mon Sep 17 00:00:00 2001 From: Bertrand Lanson Date: Wed, 3 Jan 2024 17:38:09 +0100 Subject: [PATCH] feat(vars): add host specific vars inclusion --- playbooks/load_vars.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/playbooks/load_vars.yml b/playbooks/load_vars.yml index 56caadf..59d4307 100644 --- a/playbooks/load_vars.yml +++ b/playbooks/load_vars.yml @@ -41,6 +41,26 @@ when: item.stat.exists delegate_to: localhost +- name: "Load host specific variables" + block: + - name: "Stat host specific config file" + ansible.builtin.stat: + path: "{{ configuration_directory }}/{{ item }}/{{ inventory_hostname }}/{{ configuration_global_vars_file }}" + register: _host_config_file + loop: "{{ group_names }}" + delegate_to: localhost + + - name: "debug" + ansible.builtin.debug: + msg: "{{ _host_config_file }}" + + - name: Load host specific variables + ansible.builtin.include_vars: + dir: "{{ configuration_directory }}/{{ item.item }}/{{ inventory_hostname }}" + files_matching: "{{ configuration_global_vars_file }}" + loop: "{{ _host_config_file.results }}" + when: item.stat.exists + delegate_to: localhost # - name: "Load host specific variables" # ansible.builtin.include_vars: