Failed to clone a VM with Ansible | Nutanix Community
Skip to main content

In waiting for possibility to deploy VMs from templates with Ansible (see https://next.nutanix.com/ahv-virtualization-27/how-deploy-vm-from-prismcentral-template-with-ansible-nutanix-module-41800), i’tm trying to use cloning, see playbook below.
 

 

The demo playbook with same parameters works fine to get cluster info for "{{ prism_cluster }}".
The cloning fails with error  :
KeyError: 'cluster_reference'

What is missing in playbook ?

Thx
 

 

Not sure from where you got the option to add a key named cluster. 
 

Have a look to this example https://github.com/nutanix/nutanix.ansible/blob/main/examples/vm_operations.yml and also use the help option from the CLI to see the syntax and what’s optional or required. 


I found the option in  “ansible-doc nutanix.ncp.ntnx_vms_clone”.

If I don’t add it , I get the following error :


If I add the option with a bad cluster name, I get :

If I set the good cluster name , I get :

 

What should I do ?


Check the steps on the PC GUI with the values you are passing in Ansible and confirm everything works. You don’t need to provide the cluster attribute in Ansible, it is optional. Also, you cannot clone a VM to a different cluster to the source VM. 

The only mandatory attribute for clone module is “src_vm_uuid”. Keep it simple until you find where the issue is.