name: Refresh inventory to ensure new instances exist in inventory
meta: refresh_inventory
delegate_to: localhost
But in the sameplaybook I connect to the newly created vm but this fails because I don’t know the host.
I was hopen meta: refresh_inventory did a inventory refresh but this works not for awx
This is kind of a sore spot for AWX/Tower IMHO. I ran into the same issue (I deploy a VM but it has to be in inventory for me to do anything with it). I ended up writing a small inventory script, and working my VM deployment into a workflow.
It goes something like this: Deploy from template > inventory script (now it is in inventory) > Secondary configs.
You might try creating a workflow too, kind of what I did, and the actual VM creation is how you have it, followed by an inventory sync, followed by your follow on tasks. I cannot remember if I tried using that awx-manage command or not.
I also tried doing a vsphere inventory sync between my deploy and follow on tasks, but the vsphere inventory sync was taking too long (20+ minutes).