Hi,
I’m trying to deploy a VM from a template using vmware_guest module, but i’m getting this error:
The full traceback is:
Traceback (most recent call last):
File “/tmp/ansible_yfXPli/ansible_module_vmware_guest.py”, line 1332, in
main()
File “/tmp/ansible_yfXPli/ansible_module_vmware_guest.py”, line 1321, in main
result = pyv.deploy_vm()
File “/tmp/ansible_yfXPli/ansible_module_vmware_guest.py”, line 1070, in deploy_vm
self.configure_network(vm_obj=vm_obj)
File “/tmp/ansible_yfXPli/ansible_module_vmware_guest.py”, line 674, in configure_network
if nic.device.backing and ( nic.device.backing.port.portgroupKey != pg_obj.key or nic.device.backing.port.switchUuid != pg_obj.config.distributedVirtualSwitch.uuid ):
AttributeError: ‘vim.vm.device.VirtualEthernetCard.NetworkBackingIn’ object has no attribute ‘port’
fatal: [127.0.0.1]: FAILED! => {
“changed”: false,
“failed”: true,
“module_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible_yfXPli/ansible_module_vmware_guest.py", line 1332, in \n main()\n File "/tmp/ansible_yfXPli/ansible_module_vmware_guest.py", line 1321, in main\n result = pyv.deploy_vm()\n File "/tmp/ansible_yfXPli/ansible_module_vmware_guest.py", line 1070, in deploy_vm\n self.configure_network(vm_obj=vm_obj)\n File "/tmp/ansible_yfXPli/ansible_module_vmware_guest.py", line 674, in configure_network\n if nic.device.backing and ( nic.device.backing.port.portgroupKey != pg_obj.key or nic.device.backing.port.switchUuid != pg_obj.config.distributedVirtualSwitch.uuid ):\nAttributeError: ‘vim.vm.device.VirtualEthernetCard.NetworkBackingIn’ object has no attribute ‘port’\n”,
“module_stdout”: “”,
“msg”: “MODULE FAILURE”,
“rc”: 0
}
This is my playbook:
Create a VM from a template
- hosts: 127.0.0.1
connection: local
gather_facts: no
tasks: - name: create the VM
vmware_guest:
hostname: 192.168.xxx.xxx
username: xxxxxxxxxxxxxxxxx
password: xxxxxxxxxxxxxxxxx
validate_certs: no
esxi_hostname: 192.168.xxx.xxx
datacenter: DATACENTER
folder: /TEST/
name: ANSIBLE-TESTVM
state: poweredoff
hardware:
memory_mb: 512
num_cpus: 1
scsi: paravirtual
disk: - size_kb: 279552
type: thin
datastore: datastore1 - size_gb: 10
type: thin
datastore: datastore1
networks: - name: “DPG-Lan”
ip: 192.168.xxxx.xxx
netmask: 255.255.255.0
gateway: 192.168.xxx.xxx - name: “DPG-Cluster”
ip: 192.168.xxx.xxx
netmask: 255.255.255.0 - name: “DPG-iSCSI1”
ip: 192.168.xxx.xxx
netmask: 255.255.255.0 - name: “DPG-iSCSI2”
ip: 192.168.xxx.xxx
netmask: 255.255.255.0
template: Template_CentOS_7_x86_64
wait_for_ip_address: yes
register: deploy - debug: var=deploy