Skip to main content
Question

Failed to clone a VM with Ansible

  • April 20, 2023
  • 3 replies
  • 493 views

Forum|alt.badge.img+1

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
 

 

This topic has been closed for replies.

3 replies

JoseNutanix
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • April 20, 2023

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. 


Forum|alt.badge.img+1
  • Author
  • Adventurer
  • May 13, 2023

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 ?


JoseNutanix
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • May 21, 2023

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.