Hey Folks,
So in a simple test playbook I am playing with that only plays against 1 host, I do 2 vars_files imports. When I run the playbook (from the devel branch pulled a day ago), I get an unexpected behavior that seems odd to me. Based on the output, it would appear that regardless of how many hosts are declared in the playbook, it does a variable import for all hosts found in the inventory file. Am I correct in my assumption? It seems wasteful on a few levels, as it adds to the runtime of the playbook as it iterates over all the hosts (basically unnecessary work for hosts not used in the playbook) and then as it outputs it adds to console spam that is unnecessary and cluttered, imo. This would result in variable import routines and corresponding console output for X (# of imported variable files) times N hosts found in the inventory file, which could grow to be quite large depending on the size of your inventory. I run a YAML inventory file tho I would presume this behavior would happen for however the inventory file is declared (flat, YAML, or script pull in), but I haven’t tested the other two cases yet. Thoughts?
Here’s an example of what I am seeing…
VARIABLE IMPORT PHASE ******************
hosta01: importing site/vars/my_vars.yml
hosta01: importing site/release.yml
hosta02: importing site/vars/my_vars.yml
hosta02: importing site/release.yml
hostd01: importing site/vars/my_vars.yml
hostd01: importing site/release.yml
hostd02: importing site/vars/my_vars.yml
hostd02: importing site/release.yml
hostp01: importing site/vars/my_vars.yml
hostp01: importing site/release.yml
hostp02: importing site/vars/my_vars.yml
hostp02: importing site/release.yml
hostk01: importing site/vars/my_vars.yml
hostk01: importing site/release.yml
ok: [hostk01]
hostk01 is the only host in the playbook, yet it runs through for all hosts in my inventory. Cheers!
Dave