feat(vars): variable loading now mostly works for groups and hosts
This commit is contained in:
parent
a4a3703a2a
commit
7977a2d919
@ -1,5 +1,9 @@
|
|||||||
---
|
---
|
||||||
# hashistack variable injection playbook
|
# hashistack variable injection playbook
|
||||||
|
- name: "Debug"
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ vault_cluster_name }}"
|
||||||
|
|
||||||
- name: "Load global variables"
|
- name: "Load global variables"
|
||||||
block:
|
block:
|
||||||
- name: "Stat global configuration file"
|
- name: "Stat global configuration file"
|
||||||
@ -18,52 +22,62 @@
|
|||||||
ansible.builtin.include_vars:
|
ansible.builtin.include_vars:
|
||||||
dir: "{{ configuration_directory }}"
|
dir: "{{ configuration_directory }}"
|
||||||
files_matching: "{{ configuration_global_vars_file }}"
|
files_matching: "{{ configuration_global_vars_file }}"
|
||||||
|
depth: 1
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: "Load group specific variables"
|
- name: "Load group specific variables"
|
||||||
block:
|
block:
|
||||||
- name: "Stat group specific config file"
|
- name: "Stat group specific config file"
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ configuration_directory }}/{{ item }}/{{ configuration_global_vars_file }}"
|
path: "{{ configuration_directory }}/{{ group_name }}/{{ configuration_global_vars_file }}"
|
||||||
register: _group_config_file
|
register: _group_config_file
|
||||||
loop: "{{ group_names }}"
|
loop: "{{ group_names }}"
|
||||||
delegate_to: localhost
|
loop_control:
|
||||||
|
loop_var: group_name
|
||||||
- name: "debug"
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg: "{{ _group_config_file }}"
|
|
||||||
|
|
||||||
- name: Load group specific variables
|
- name: Load group specific variables
|
||||||
ansible.builtin.include_vars:
|
ansible.builtin.include_vars:
|
||||||
dir: "{{ configuration_directory }}/{{ item.item }}"
|
dir: "{{ configuration_directory }}/{{ item.group_name }}"
|
||||||
files_matching: "{{ configuration_global_vars_file }}"
|
files_matching: "{{ configuration_global_vars_file }}"
|
||||||
|
depth: 1
|
||||||
loop: "{{ _group_config_file.results }}"
|
loop: "{{ _group_config_file.results }}"
|
||||||
when: item.stat.exists
|
when: item.stat.exists
|
||||||
|
and item.group_name in group_names
|
||||||
|
loop_control:
|
||||||
|
loop_var: item
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: "Load host specific variables"
|
- name: "Load host specific variables"
|
||||||
block:
|
block:
|
||||||
- name: "Stat host specific config file"
|
- name: "Stat host specific config file"
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ configuration_directory }}/{{ item }}/{{ inventory_hostname }}/{{ configuration_global_vars_file }}"
|
path: "{{ configuration_directory }}/{{ group_name }}/{{ inventory_hostname }}/{{ configuration_global_vars_file }}"
|
||||||
register: _host_config_file
|
register: _host_config_file
|
||||||
loop: "{{ group_names }}"
|
loop: "{{ group_names }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: group_name
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: "debug"
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg: "{{ _host_config_file }}"
|
|
||||||
|
|
||||||
- name: Load host specific variables
|
- name: Load host specific variables
|
||||||
ansible.builtin.include_vars:
|
ansible.builtin.include_vars:
|
||||||
dir: "{{ configuration_directory }}/{{ item.item }}/{{ inventory_hostname }}"
|
dir: "{{ configuration_directory }}/{{ item.group_name }}/{{ inventory_hostname }}"
|
||||||
files_matching: "{{ configuration_global_vars_file }}"
|
files_matching: "{{ configuration_global_vars_file }}"
|
||||||
loop: "{{ _host_config_file.results }}"
|
loop: "{{ _host_config_file.results }}"
|
||||||
when: item.stat.exists
|
when: item.stat.exists
|
||||||
|
loop_control:
|
||||||
|
loop_var: item
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
|
|
||||||
|
- name: "Debug"
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ group_names }}"
|
||||||
|
|
||||||
|
- name: "Debug"
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ vault_cluster_name }}"
|
||||||
# - name: "Load host specific variables"
|
# - name: "Load host specific variables"
|
||||||
# ansible.builtin.include_vars:
|
# ansible.builtin.include_vars:
|
||||||
# dir: ""
|
# dir: ""
|
||||||
# files_matching: ""
|
# files_matching: ""
|
||||||
- fail:
|
- fail:
|
||||||
|
Loading…
Reference in New Issue
Block a user