# VMware VM cloned from template: Error "The name XXX already exists" on second run

**URL:** <https://forum.ansible.com/t/vmware-vm-cloned-from-template-error-the-name-xxx-already-exists-on-second-run/3865>\
**Category:** Get Help\
**Tags:** vmware, collections\
**Created:** [February 14, 2024, 7:20am UTC](https://forum.ansible.com/t/vmware-vm-cloned-from-template-error-the-name-xxx-already-exists-on-second-run/3865 "2024-02-14T07:20:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kastl-ars](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kastl-ars/32/2315_2.png) [@kastl-ars](https://forum.ansible.com/u/kastl-ars)\
**Post date:** [February 14, 2024, 7:20am UTC](https://forum.ansible.com/t/vmware-vm-cloned-from-template-error-the-name-xxx-already-exists-on-second-run/3865/1 "2024-02-14T07:20:44Z")

</div>

Hi everyone,

I tried using Ansible with our company’s VMware vSphere and could successfully clone a VM from a template. Hooray!

But when I try to execute the playbook a second time, instead of Ansible being idempotent and showing everything als “OK” I get a big red warning:

```auto
TASK [Clone the template] ***************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to create a virtual machine : The name 'XXX' already exists."}

```

Unfortunately the check mode `--check` only shows this talk as changed without further information:

```auto
TASK [Clone the template] ***************************************************
changed: [localhost] => {"changed": true, "desired_operation": "deploy_vm"}

```

With Terraform and vSphere I had to ignore some attributes of the VM, like tags, the host it was running on etc. I found no way to do that in Ansible.

Any way I can debug this any further and find out, **why** Ansible wants to create a new VM?

Kind Regards,  
Johannes

---

<div class="post-metadata">

**Author:** ![kastl-ars](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kastl-ars/32/2315_2.png) [@kastl-ars](https://forum.ansible.com/u/kastl-ars)\
**Post date:** [February 14, 2024, 7:23am UTC](https://forum.ansible.com/t/vmware-vm-cloned-from-template-error-the-name-xxx-already-exists-on-second-run/3865/2 "2024-02-14T07:23:32Z")

</div>

This is the task in question:

```auto
    - name: 'Clone the template'
      community.vmware.vmware_guest:
        hostname: "{{ vsphere_server }}"
        username: "{{ vsphere_user_name }}"
        password: "{{ vsphere_user_password }}"
        validate_certs: true
        #
        datacenter: "{{ vsphere_datacenter_name }}"
        cluster: "{{ vsphere_cluster_name }}"
        #
        name: "{{ vsphere_vm_name }}"
        template: "/Test/vm/{{ vsphere_template_path_and_name }}"
        folder: "/Test/vm/{{ vsphere_folder_name }}/"
        wait_for_ip_address: true
        state: 'poweredon'
        #
        hardware:
          memory_mb: 4096
          num_cpus: 2
          boot_firmware: 'efi'

```
