I try to test one simple playbook with ansible. My goal is to create a new VM with it.

# create a new VM from a template

- name: VM from template
  hosts: localhost
  gather_facts: false
  connection: local
    vcenter_hostname: vcenter-app
    vcenter_user: john@doe
    vcenter_pass: blabla6
    esxhost: esx-4.cbalo.fr
    datastore: VM-PROD-02-NORMAL
    vmtemplate: Centos7-template
    name: "newvm2"
    notes: Ansible Test
    dumpfacts: False
    - name: Create VM from template
        validate_certs: False
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_user }}"
        password: "{{ vcenter_pass }}"
        esxi_hostname: "{{ esxhost }}"
        datacenter: CD06
        folder: Test
        name: "{{ name }}"
        template: "{{ vmtemplate }}"
          - size_gb: "{{ disk_size | default(17) }}"
            type: thin
            datastore: "{{ datastore }}"
          memory_mb: "{{ vm_memory | default(1024) }}"
        wait_for_ip_address: True
        state: present
      register: newvm2

The connection to my VMcenter is fine but i see that error message :

**ansible-playbook test_vmware.yml**

PLAY [Create VM from template] ******************************************************************************************************************************************************

TASK [Clone VM from template] *******************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to create a virtual machine : Cannot complete the operation because the file or folder /vmfs/volumes/5d25e76b-5475ac54-9cdb-e4434b69d662/newvm2/newvm2.vmdk already exists"}

Even if i change the name newvm2 for an other one, i still have the same message. Someone can maybe help me with that case ?

Many Thanks

1 Answer 1



The fix is included in Ansible 2.8.3 or higher. I had the 2.8.2 version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.