Created
August 27, 2018 16:55
-
-
Save mchubby/8dfb3f11a618a05674c3f7c91fd8fe67 to your computer and use it in GitHub Desktop.
Have host_vars or group_vars greater precedence than include_vars counterparts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Include vars based on various criteria, into platformspec hash. | |
include_vars: | |
file: "{{ item }}" | |
name: platformspec | |
with_first_found: | |
- "{{ ansible_distribution }}.yml" | |
- "{{ ansible_os_family }}.yml" | |
# inspired by https://www.samdarwin.com/ansible-default-vars/ | |
- name: Set facts while having include_vars variables have lower precedence | |
set_fact: | |
"{{ item.key }}": "{{ item.value|default(vars[item.key]) }}" | |
with_dict: "{{ platformspec }}" | |
- name: debug | |
debug: var=vars |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment