Hi list,
I'd like to discuss a proposal for a loop with_all_found.
We have with_first_found, so implementation should be quite easy.
Target:
- name: Include OS specific variables
with_all_found:
- "{{ ansible_os_family }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
include_vars: "{{ item }}"
vars/Debian.yml:
pkg_list:
- foo
- bar
- foobar
pkg_state: installed
service_management: systemd
vars/Ubuntu.yml
service_management: upstart
vars/Ubuntu-15.yml
service_management: systemd
ubuntu_15_specific_var: value
Result, running on Ubuntu 14.
pkg_list:
- foo
- bar
- foobar
pkg_state: installed
service_management: upstart
Running on Ubuntu-15:
pkg_list:
- foo
- bar
- foobar
pkg_state: installed
service_management: systemd
ubuntu_15_specific_var: value
Running on Debian:
see vars/Debian.yml
This might spare one task compared to what I'm doing right now and will
ease to override variables for specific versions/distributions.
- name: Include OS family specific vars
include_vars: "{{ ansible_os_family }}.yml"
- name: Include distribution specific vars
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution }}.yml"
include_vars: "{{ item }}"
What do you think?
# kraM