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

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:

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:

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

This is the task in question:

    - 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'