Refactor the use of include_vars
Move remaining os-default files to vars directory, where the include_vars expects them to be. Use a first_found lookup instead of a with_first_found loop so that the 'paths' parameter can be used. This ensures that only vars from the role are included, and not vars from a parent calling role. This can happen when a parent role has a higher priority vars file available for inclusion than the role it calls. Change-Id: I49c041b2217c51048fa182106009d334b6b38f6f
This commit is contained in:
parent
e0a5a7216d
commit
b1f70ce6bf
@ -1,2 +0,0 @@
|
||||
---
|
||||
# Note(TheJulia): This file is intentionally left empty. Do not edit.
|
@ -23,18 +23,18 @@
|
||||
- ansible_distribution == "CentOS"
|
||||
- ansible_distribution_version|int >= 9
|
||||
|
||||
- name: "Load distribution defaults"
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "../defaults/required_defaults_{{ ansible_distribution }}.yml"
|
||||
- "../defaults/required_defaults_{{ ansible_os_family }}.yml"
|
||||
|
||||
- name: "Include OS version-specific defaults"
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "../defaults/required_defaults_{{ ansible_distribution }}_{{ ansible_distribution_release }}.yml"
|
||||
- "../defaults/required_defaults_{{ ansible_distribution }}_{{ ansible_distribution_version }}.yml"
|
||||
- "../defaults/dummy-defaults.yml"
|
||||
- name: Gather variables for each operating system
|
||||
include_vars: "{{ lookup('first_found', params) }}"
|
||||
vars:
|
||||
params:
|
||||
files:
|
||||
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml"
|
||||
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
|
||||
- "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
|
||||
- "{{ ansible_facts['distribution'] | lower }}.yml"
|
||||
- "{{ ansible_facts['os_family'] | lower }}.yml"
|
||||
paths:
|
||||
- "{{ role_path }}/vars"
|
||||
|
||||
- name: "Install required packages"
|
||||
package:
|
||||
|
Loading…
x
Reference in New Issue
Block a user