Help with ovirt_vms module

14 views
Skip to first unread message

Robert

unread,
May 9, 2019, 1:27:18 PM5/9/19
to ansible...@googlegroups.com
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

Jonathan Lozada De La Matta

unread,
May 9, 2019, 1:47:19 PM5/9/19
to ansible...@googlegroups.com
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJLEWMdH_GdnDtTwGqC-679nttr9beVhNBMJi4a6SZ3Nc%2BX5%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Automation Practice

Senior Automation Consultant & Automation CoP Manager

Red Hat


 

Robert

unread,
May 9, 2019, 2:01:44 PM5/9/19
to ansible...@googlegroups.com
Thanks I will definitely check it out.

Reply all
Reply to author
Forward
0 new messages