On Fri, Jan 23, 2015 at 11:42:11AM +0100, Tomasz Kontusz wrote:
> There is another way: you can put "foo: '{{ default_foo }}' in
> defaults, and only set default_foo in the per-OS variables
Ok, It took me a little while to understand what you meant with "only set
default_foo in the per-OS variables"
but I think I got it. Thanks Tomasz, that's clever :-)
For the record, this is what I ended up with and it seems to work fine (I can
override one or more vars using the inventory hierarchy under /etc/ansible):
(of course I have to duplicate all vars from defaults.yml into the OS-specific
vars files, not just the ones that need overriding, but I can leave with that)
# tasks/main.yml
- name: OS-specific vars
include_vars: "{{ item }}"
with_first_found:
- "defaults_{{ ansible_distribution }}.yml"
- "defaults_{{ ansible_os_family }}.yml"
- "defaults.yml"
# defaults/main.yml
foobar: '{{ def_foobar }}'
# vars/defaults.yml
def_foobar: blahblah
# vars/defaults_CentOS.yml
def_foobar: blahblah-for-centos
# var/defaults_Debian.yml
def_foobar: blahblah-for-debian-family
Thank you again Tomasz.
Unless someone has a better idea...
--
Antoine
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20150123131345.GJ29678%40janus.obspm.bsdfrog.org.
For more options, visit https://groups.google.com/d/optout.