1
votes

This is the error message:

TASK [vsphere_guest] ***********************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: pysphere.resources.vi_exception.VIException: [Object Not Found]: Could not find a VM named 'templatename'
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/var/folders/5_/zznkc3cs38v1wscsgmsdcc1w0000gn/T/ansible_Z0ldZx/ansible_module_vsphere_guest.py\", line 1879, in \n main()\n File \"/var/folders/5_/zznkc3cs38v1wscsgmsdcc1w0000gn/T/ansible_Z0ldZx/ansible_module_vsphere_guest.py\", line 1836, in main\n vm_extra_config=vm_extra_config\n File \"/var/folders/5_/zznkc3cs38v1wscsgmsdcc1w0000gn/T/ansible_Z0ldZx/ansible_module_vsphere_guest.py\", line 655, in deploy_template\n vmTemplate = vsphere_client.get_vm_by_name(template_src)\n File \"/usr/local/lib/python2.7/site-packages/pysphere/vi_server.py\", line 323, in get_vm_by_name\n FaultTypes.OBJECT_NOT_FOUND)\npysphere.resources.vi_exception.VIException: [Object Not Found]: Could not find a VM named 'templatename'\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}

This is the Ansible code:

---
- hosts: all

  tasks:
    - vsphere_guest:
        validate_certs: no
        guest: newbuildvm001
        #state: powered_on
        from_template: yes
        template_src: templatename
        vm_extra_config:
          vcpu.hotadd: yes
          mem.hotadd:  yes
          notes: This is a test VM
          folder: Test
        vm_disk:
          disk1:
            size_gb: 10
            type: thin
            datastore: test
            folder: test-ansible
        vm_nic:
          nic1:
            type: vmxnet3
            network: teset
            network_type: standard
        vm_hardware:
          memory_mb: 2048
          num_cpus: 2
          osid: centos64Guest
          scsi: paravirtual
        esxi:
          datacenter: DC

I was expecting ansible to create a virtual machine based on the template called templatename.

Instead it seems to look for a virtual machine called templatename to clone?

1
I've changed the title.Dennis

1 Answers

1
votes

vsphere_guest module clone existing VMs.

template_src is a name of VM (not template as you might expect) to clone from.
See proof in the module's code.