# Ansible - vmware\_guest - deploy from template - object has no attribute port

**URL:** <https://forum.ansible.com/t/ansible-vmware-guest-deploy-from-template-object-has-no-attribute-port/24388>\
**Category:** Ansible Project\
**Created:** [May 3, 2017, 1:19pm UTC](https://forum.ansible.com/t/ansible-vmware-guest-deploy-from-template-object-has-no-attribute-port/24388 "2017-05-03T13:19:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricardo\_Esteves](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@Ricardo\_Esteves](https://forum.ansible.com/u/Ricardo_Esteves)\
**Post date:** [May 3, 2017, 1:19pm UTC](https://forum.ansible.com/t/ansible-vmware-guest-deploy-from-template-object-has-no-attribute-port/24388/1 "2017-05-03T13:19:53Z")

</div>

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
