Help with ovirt_vms module

Hey everyone.
I am working on a role that will delete VM’s from RHV and remove their entries from satelite and AD.
The challenge I have is that I need to pass the current host into the name field without doing a loop. Right now my task called destroyvm.yml looks like this:

  • task to unregister from Satellite 6

  • task to run a script to leave the AD domain.

  • task to log into RHV

  • name: Destroy VMs
    ovirt_vms:
    auth: “{{ ovirt_auth }}”
    name: “{{ item }}”
    cluster: “{{ cluster }}”
    state: absent
    with_items: “{{ group }}”
    delegate_to: “{{ rhv }}”
    async: 1
    poll: 0

I have about 6 groups of servers with multiple servers in each group. What is happening is for the first server in each group it runs through everything fine and when it gets to the Destroy VMs task it destroys all the VM’s in the group before they are unregistered from Satellite and AD (except for the first VM which is removed fine). So my question is…is there a way to just pass the current host/VM into the name slot without doing the loop.

Thanks

Robert

Robert,

checkout this out for examples https://github.com/oVirt/ovirt-ansible-vm-infra/blob/master/tasks/main.yml. I been using it for what you describe but, basically you have to pass a dictionary of the VM’s you want to remove and the automation does everything else, with a loop and what not.

Thanks I will definitely check it out.