Over this weekend, I need to shutdown and restart 1500 VMs while I do work.  Modifying an Ansible playbook I have, to accomplish that, seems easy enough.

 

Last weekend I used the web gui and edited each Virtual Machine and changed the ‘cluster’ to the one I wanted to assign it too.  Now I would like to automate this with Ansible.

 

In between shutting them down and starting them up, I need to change the cluster registration of quite a few of the hosts, and I have concerns on how to do that.

 

The Ansible ovirt_vm documentation on this is a bit fuzzy.  I’m assuming it for assigning the cluster, but in some examples it appears to be used as a filter. Which changes the meaning.  Is it “start the VM in this cluster” or “start this VM if it is in this cluster”.

 

The playbook I’m working from is straight forward and has three tasks.

 

First, an ovirt_auth task to log into the SHE.

 

Second, an ovirt_vm task which loops though the group of virtualmachines, defined in an ‘ini’ file.

 

Third, an ovirt_auth task to logout from the SHE.

 

 

For stopping, I assume I specify a name, and state to ‘stopped’ and that should initiate the shutdown.

 

For starting, I assume I should set the state to ‘running’.

 

For changing the cluster a vm is assigned to, do I simply need to use the ‘cluster’ parameter with a value of new cluster?  Are there other actions that need to be taken?  The VM need to be un and re-registered for the change to take effect?  I’d like to make the cluster change individual playbook, but could it be added to the start or stop playbook.  (ie: stop and change cluster, start on new cluster)

 

Waiting for the wisdom of the community.