How to clone a VM from snapshot with Ansible

Latest response

I need to automate the following task:

  1. Create a VM snapshot
  2. Clone a VM from the snapshot
  3. On new new VM, bring NIC down
  4. Start the new VM

Step 2 seems to be doable manually only. Is there a way to automate it?

The reason for this task is verifying virtual machines, there is a long story behind it.

Thank you,


I am looking for the same. To clone a VM from a snapshot using ansible. Let me know if you figured out a way. Thanks.

Hi Ilya Palagin and Naga Naveen Vaddi,

When you say VM here, I do not know if you mean Red Hat Enterprise Virtualization, or "Kernel Virtual Machine" (KVM is a poor name for generic virtualization method) or Oracle's Virtual Box, or (shudder) perhaps Microsoft's hyper-v.

If you happen to be using ESX (VMware) here's some documentation direct from Ansible on an Ansible module for snapshots. I'd certainly verify the version of Ansible you are using to make sure the expectation of using the latest version of Ansible is valid in your own environment.

Let us know how it goes, you'll have to read through the Ansible module and compose a recipe in terms of a playbook to do this. I've personally never done an Ansible playbook for a snapshot as you say using this Ansible Module. There is an example at that link, but I'd recommend not taking it at face value and scrutinize it and change it as needed for sanity for your environment and intentions.



Thanks for the response Hinton! Yes i am talking about ESX(VMware). The module vmware_guest_snapshot helps us to create a snapshot but i was looking for cloning a VM. You can find the manual steps here: