After provisioning a machine on ec2 module, the inventory doesn’t reflect the new host (using ec2.py).
I am using a tag_name for the target host that comes from the inventory.
I have tried all of the following:
pause of 60 seconds after provisioning.
local_action to refresh the cache, calling ec2.py --refresh-cache
changing the cache_max_age timeout to 0 in ec2.ini
The other thing I tried was to use not use the inventory script, but to use add_host with the same group name as my tag name. This seems hacky though and seems also not read the group_vars, which is a problem.
Having a look at the inventory file immediately after the machine is provisioned, it does in fact update correctly.
However it appears that the inventory file is run/read only once at the beginning of a playbook, so it will not reflect the new host if the deploy playbook is run by including it after the provisioning playbook.
Looks like I will need to use add_host then, or find a way to get Ansible to refresh the inventory in the middle of a play.