group_vars appear to be skipped for implicit localhost when using inventory plugin

Hello list,

I think I’m seeing “group_vars/all” get skipped for implicit localhost when using the ec2.py inventory script. I’ve tried writing a few simplified example plays but they all worked, so I’m either missing something obvious or the issue was in a part I tried to stub out. So here is what I hope will be a succinct verbal description instead…

I’m working on an ec2 deployment that has a few playbooks that are run by separate calls to ansible-playbook, via a pretty simple bash wrapper script. The first call to ansible-playbook creates the ec2 instances pretty normally, getting vars like account credentials and instance type from group_vars/all. Then we return to our bash wrapper which does a bunch of work while the instances start, and then makes a separate call to ansible-playbook (this time using -i ec2.py) that configures the instances. It is in this second call to ansible-playbook that I’m getting errors that my vars to access ec2 are not defined.

I think the culprit is in using a dynamic inventory because I tried specifying ec2.py for the first (instance creation) ansible-playbook call too, and it also started failing saying vars were undefined.

This is roughly what the bash script is doing at the time:

Request the instances, don’t wait for them

ansible-playbook -f 25 create_instances.yml --private-key=key -e “stuff like fqdn of site, server-group name, etc, wait=no”

#prep composer and npm type dependencies on build server while waiting for instances
ec2.py --refresh-cache &>/dev/null

Provision instances in their respective roles

ansible-playbook -f 25 -i ec2.py provision_instances.yml --private-key=key -e “stuff like fqdn of site, server-group name, etc, wait=yes”

Any insights much appreciated.

Thank you,
Mark

The implicit localhost feature is new, and it’s not technically part of any group, so I’m not too surprised it doesn’t read group variables for the host.

If you’d like to file a github ticket we can look into making sure it gets variables from the “all” group.

Can we see the second playbook?

I’d sent the playbook off-list, but I’ve now filed a github ticket with a more succinct example case.

For now as a workaround I’m going to try explicitly importing group_vars/all in cases where this happens, though I’m a little curious what will happen (merge/overwrite with identical, etc.) to the vars once the issue I’m seeing is no longer happening.

Thank you,
Mark