Answers: <p><a href="https://github.com/ansible/ansible/issues/55551" rel="nofollow noreferrer">https://github.com/ansible/ansible/issues/55551</a></p>
  
  <p>The fix is included in Ansible 2.8.3 or higher. I had the 2.8.2 version</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-08-27T08:18:17.757Z
Answers: 2019-08-27T08:18:17.757Z
Answers: Peutre
Body: <p>I try to test one simple playbook with ansible.
  My goal is to create a new VM with it.</p>
  
  <pre><code>---
  # create a new VM from a template
  
  - name: VM from template
    hosts: localhost
    gather_facts: false
    connection: local
    vars:
      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
    tasks:
      - name: Create VM from template
        vmware_guest:
          validate_certs: False
          hostname: "{{ vcenter_hostname }}"
          username: "{{ vcenter_user }}"
          password: "{{ vcenter_pass }}"
          esxi_hostname: "{{ esxhost }}"
          datacenter: CD06
          folder: Test
          name: "{{ name }}"
          template: "{{ vmtemplate }}"
          disk:
            - size_gb: "{{ disk_size | default(17) }}"
              type: thin
              datastore: "{{ datastore }}"
          hardware:
            memory_mb: "{{ vm_memory | default(1024) }}"
          wait_for_ip_address: True
          state: present
        register: newvm2
  </code></pre>
  
  <p>The connection to my VMcenter is fine but i see that error message :</p>
  
  <pre><code>**ansible-playbook test_vmware.yml**
  
  PLAY [Create VM from template] ******************************************************************************************************************************************************
  
  TASK [Clone VM from template] *******************************************************************************************************************************************************
  fatal: [localhost]: FAILED! =&gt; {"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"}
  </code></pre>
  
  <p>Even if i change the name <strong>newvm2</strong> for an other one, i still have the same message. Someone can maybe help me with that case ?</p>
  
  <p>Many Thanks</p>
  
Tags: <ansible><vmware>
Title: Deploy Vm Vmware with simple Ansible playbook
UserDisplayName: Peutre
ThreadText: # Deploy Vm Vmware with simple Ansible playbook
  
  (Asked by: username_0 on 2019-08-27)
  
  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
    vars:
      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
    tasks:
      - name: Create VM from template
        vmware_guest:
          validate_certs: False
          hostname: "{{ vcenter_hostname }}"
          username: "{{ vcenter_user }}"
          password: "{{ vcenter_pass }}"
          esxi_hostname: "{{ esxhost }}"
          datacenter: CD06
          folder: Test
          name: "{{ name }}"
          template: "{{ vmtemplate }}"
          disk:
            - size_gb: "{{ disk_size | default(17) }}"
              type: thin
              datastore: "{{ datastore }}"
          hardware:
            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
  
  **Tags:** ansible, vmware
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-08-27. Score: 1
  
  <https://github.com/ansible/ansible/issues/55551>
  
  The fix is included in Ansible 2.8.3 or higher. I had the 2.8.2 version
  
  
  ---
  
  