PowerVC

 View Only

Automating PowerVC snapshots using Ansible and REST API

By Nicolae Chirea posted Fri May 27, 2022 08:55 AM

  


Automating PowerVC snapshots using Ansible and REST API

    One interesting feature of PowerVC is the possibility to take a snapshot of a VM and restore it in case of disaster. Even the easy way is to use the GUI, a more programmatic approach opens the possibility to include it in a flow, which can guarantee the image usability (I think in database consistency) and also the use of a scheduler.

     As we can see there is the restore option (sorry for the Spanish - Restaurar) - that means we can recover our virtual machine to the point in time where we take the snapshot (of course we have to shut down it before the restore operation). The process is easy if we have just one VM and we take the snapshot from time to time. But when the number of VM increases and we need to do it on a daily basis, then the task becomes tedious and time-consuming. So, we need to be able to schedule the task and run it in an unattended mode.

   I’ll describe the process of a snapshot using ansible and PowerVC REST API.  In ansible, we have the module URI (Interacts with web services) and in PowerVC we have the Create an instance snapshot API.

  The steps to be accomplished:

  • Get the authorization token
  • Get the tenant
  • Get the VM ID
  • Run the snapshot
  • View the result

   The name of the VM to snapshot will be passed like extra-vars in the call to ansible-playbook and the name of the snapshot will be composed of the VM name and the date/time of playbook run.

   First of all, we need to get the authorization token – it will be used later by all the other APIs:

 

   Then we need to get the tenant – it depends on the project that we have defined in PowerVC. In this case, it is the default one.

 

   Next, we retrieve the list of VM and establish the ID of the VM to snapshot.

 

   And, finally, we put together all the variables and take the snapshot.

 

   We can view the result in a while.

 

  Finally, we run the playbook.

   That’s all. Now, from the GUI, we can manage the new snapshot.

Conclusion

PowerVC is a great solution for IBM Power system management and, in combination with Ansible, it could be integrated in the automation strategy.

For the latest updates, do not forget to follow PowerVC social media handles Twitter, Facebook, LinkedIn, and YouTube.

2 comments
74 views

Permalink

Comments

Tue August 16, 2022 06:12 AM

Hi Dominic,
It is still "work in progress". I will publish it when it will be finished.

Sun July 31, 2022 10:39 PM

Nice work Nicolae - any chance you can put up your scripts into a github repo anywhere ?