vsphere_guest really efficient tool while working VMware. It has many many feature to boot machine by using Ansible. While working with it I think there is good examples to understand how it works but in my opinion nobody has time to try and work with all examples with all different parameters.
I had problem such a little confusing problem about network.
It has many many features and variables that control source of computer. Just I’ll give partial part of Playbook file.
1 2 3 4 5 |
vm_nic: nic1: type: vmxnet3 network: 'VDS NETWORK' network_type: standart |
While I was running on standart network configuration there was not any problem about connecting to network in my test machine.
Error
Problem was look like that from vCenter
As you see network label is empty area and device status not clicked
But when I wanted to use the same Playbook file with with distributed network there was problem that is not easy to understand. I tried to debugging from ansible-playbook -vvvv option but there was not any problem about it which is related network.
1 2 3 4 |
changed: [127.0.0.1] => {"ansible_facts": {"hw_eth0": {"addresstype": "assigned", "ipaddresses": null, "label": "Network adapter 1", "macaddress": "xx:xx:Xx:Xx:Xx", "macaddress_dash": "xx:xx:xx:xx:xx", "summary": "VDS SUNUCU"}, "hw_guest_full_name": "CentOS 4/5/6/7 (64-bit)", "hw_guest_id": "centos64Guest", "hw_interfaces": ["eth0"], "hw_memtotal_mb": 1024, "hw_name": "enisozgen", "hw_power_status": "POWERED ON", "hw_processor_count": 2, "hw_product_uuid": ":xx:Xx:xx:Xx:x", "module_hw": true}, "changed": true, "changes": "Created VM enisozgen", "invocation": {"module_args": {"cluster": null, "esxi": {"datacenter": "Netinternet DATACENTER", "hostname": "xx:xx:xxxx:xx:"}, "force": false, "from_template": null, "guest": "enisozgen", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "power_on_after_clone": true, "resource_pool": null, "snapshot_to_clone": null, "state": "powered_on", "template_src": null, "username": "root", "vcenter_hostname": "xx:xx:Xx:xx", "vm_disk": {"disk1": {"datastore": "xx:xx:Xx:xx", "size_gb": 50, "type": "thin"}}, "vm_extra_config": {"notes": "Created by Ansible"}, "vm_hardware": {"memory_mb": "1024", "num_cpus": "2", "osid": "centos64Guest", "scsi": "paravirtual", "vm_cdrom": {"iso_path": "/ISO/autoinstall-ubuntu-16.04.1-server-amd64.iso", "type": "iso"}, "vm_extra_config": {"mem.hotadd": "TRUE", "vcpu.hotadd": "TRUE"}}, "vm_hw_version": null, "vm_nic": {"nic1": {"network": "VDS SUNUCU", "network_type": "standard", "type": "vmxnet3"}}, "vmware_guest_facts": null}, "module_name": "vsphere_guest"}} PLAY RECAP ********************************************************************* 127.0.0.1 : ok=1 changed=1 unreachable=0 failed=0 |
Solution
Then I realised this network is distributed virtual switch and change network_type as like dvs.
1 2 3 4 5 |
vm_nic: nic1: type: vmxnet3 network:'VDS NETWORK' network_type: dvs |
This lines changed network settings and machine connected Internet easily with this configurations.
Happy Booting 🙂