So I know that we’re doing this incorrectly. The question is, how can I do this the correct way?
I have a windows.yml
group variable file that contains a dict that lists the basic software that machines will need:
default_baseline_includes:
7zip: true
bigfix: true
checkmk: true
chrome: true
d4voip: false
firefox: true
git: true
Then I have other group var files, such as windows_admin.yml
windows_32bit.yml
windows_itps.yml
etc, that might have changes:
override_baseline_includes:
bigfix: false
checkmk: false
Then I put them together like this:
baseline_includes: "{{ default_baseline_includes|combine(override_baseline_includes) }}"
I’m under the impression that this definition is evaluated at run-time – that is, not at the moment it’s defined, but whenever the baseline_incluces
variable is actually called/referenced, it uses whatever happens to be in override_baseline_includes
at that time. (Maybe I’m wrong?)
The problem is that, if a machine is in several groups, it might have several options to define (and thus replace) the override_baseline_includes
dict. If this were perl, I could just say
$baseline{bigfix} = false;
and it wouldn’t affect the rest of the dict. But in ansible (as far as I can tell), creating override_baseline_includes
will completely remove and replace a pre-existing override_baseline_includes
So the question is …
How can I, correctly, have several different dicts similar to my override_baseline_includes
, that will all be merged together with my default_baseline_includes
…
(bonus question) merged in the correct order? (I’m not sure what the correct order is yet, other than “host-based should override group-based, and group-based should override the default”
I hope this makes sense. Thanks in advance.