AWX workflow

Hi!

I have an AWX job, that uses a playbook tell virsh to build me a VM. It’s pretty straight forward, ssh’s in then runs the commands.

Now, I’d like to create a workflow that runs and SSH’s into that newly created machine, but i don’t know how to make a new inventory entry on the fly.

Can someone point me in the direction to do this?
awx - ssh → virsh - then awx - ssh → new-vm different job

Hopefully this makes sense :slight_smile:

Thanks!

I think this is what you want.

https://docs.ansible.com/ansible/latest/modules/tower_host_module.html

Ah! Thanks but I don’t think that’s what I’m looking for. Let me try to clear it up.

I have a playbook that runs a clone command with virsh on a remote machine with a hypervisor. The virtual machine spins up and boots with a new IP.
I’d like to run a post provisioning playbook on a workflow.

AWX to hypervisor then vm gets created and a new run to a new vm to post provision. I have no way of knowing ahead of time what IP will be because of DHCP.

Does that make sense?

  • JJ Asghar

Hi JJ. I’ve solved similar problems in the past using an inventory update block in the workflow. The general idea is to place an inventory synchronization step between the job template that creates the vm and the one that runs a playbook against it.

[job template 1: creates vm] ----> [inventory sync] ----> [job template 2: run tasks against vm]

You will need to configure your inventory and job template such that job template 2 runs on the set of host(s) you expect given the updated inventory. There’s more than one way to do that, but it can generally be accomplished with a combination of inventory source parameters and limit filters on the job template.