# Help with ovirt\_vms module

**URL:** <https://forum.ansible.com/t/help-with-ovirt-vms-module/30294>\
**Category:** Ansible Project\
**Created:** [May 9, 2019, 5:26pm UTC](https://forum.ansible.com/t/help-with-ovirt-vms-module/30294 "2019-05-09T17:26:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert2](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@Robert2](https://forum.ansible.com/u/Robert2)\
**Post date:** [May 9, 2019, 5:26pm UTC](https://forum.ansible.com/t/help-with-ovirt-vms-module/30294/1 "2019-05-09T17:26:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [May 9, 2019, 5:46pm UTC](https://forum.ansible.com/t/help-with-ovirt-vms-module/30294/2 "2019-05-09T17:46:58Z")

</div>

Robert,

checkout this out for examples [https://github.com/oVirt/ovirt-ansible-vm-infra/blob/master/tasks/main.yml](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.

---

<div class="post-metadata">

**Author:** ![Robert2](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@Robert2](https://forum.ansible.com/u/Robert2)\
**Post date:** [May 9, 2019, 6:01pm UTC](https://forum.ansible.com/t/help-with-ovirt-vms-module/30294/3 "2019-05-09T18:01:21Z")

</div>

Thanks I will definitely check it out.
