1

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

Peutre
  • 43
  • 5

1 Answers1

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

Peutre
  • 43
  • 5