community.vmware
community.vmware copied to clipboard
vmware_guest: Error Network does not exist. while vmware_guest_network works with same data.
SUMMARY
vmware_guest_network works with this data:
"network_data": {
"0": {
"allow_guest_ctl": true,
"connected": true,
"device_type": "vmxnet3",
"label": "Network adapter 1",
"mac_addr": "00:xx:xx:xx:xx:xx",
"mac_address": "00:xx:xx:xx:xx:xx",
"name": "0012_04_SAP-Zone2",
"network_name": "0012_04_SAP-Zone2",
"start_connected": true,
"switch": "xxx",
"unit_number": 7,
"wake_onlan": false
}
},
"network_info": [
{
"allow_guest_ctl": true,
"connected": true,
"device_type": "vmxnet3",
"label": "Network adapter 1",
"mac_address": "00:xx:xx:xx:xx:xx",
"network_name": "0012_04_SAP-Zone2",
"start_connected": true,
"switch": "xxx",
"unit_number": 7,
"wake_onlan": false
}
while vmware_guest with the same vm_networks settings gives:
fatal: [ztest]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"annotation": null,
"cdrom": [],
"cluster": null,
"convert": null,
"customization": {
"dns_servers": [
"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
],
"domain": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
},
"customization_spec": null,
"customvalues": [],
"datacenter": "xxx",
"datastore": null,
"delete_from_inventory": false,
"disk": [],
"esxi_hostname": null,
"folder": null,
"force": false,
"guest_id": null,
"hardware": {
"memory_mb": "4096",
"memory_reservation_lock": true,
"num_cpu_cores_per_socket": "4",
"num_cpus": "4"
},
"hostname": "vmvc1.********",
"is_template": false,
"linked_clone": false,
"name": "ztest",
"name_match": "first",
"networks": [
{
"gateway": "xx.xx.xx.xx",
"ip": "xx.xx.xx.xx",
"label": "Network adapter 1",
"name": "0012_04_SAP-Zone2",
"netmask": "255.255.255.0",
"start_connected": true,
"state": "present",
"type": "static",
"vlan": "xxx"
}
],
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 443,
"proxy_host": null,
"proxy_port": null,
"resource_pool": null,
"snapshot_src": null,
"state": "present",
"state_change_timeout": 0,
"template": null,
"use_instance_uuid": false,
"username": "gdm_ansible",
"uuid": null,
"validate_certs": false,
"vapp_properties": [],
"wait_for_customization": true,
"wait_for_customization_timeout": 3600,
"wait_for_ip_address": true,
"wait_for_ip_address_timeout": 300
}
},
"msg": "Network '0012_04_SAP-Zone2' does not exist."
}
ISSUE TYPE
- Bug Report
COMPONENT NAME
vmware_guest
ANSIBLE VERSION
ansible 2.9.10
config file = /root/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /bin/ansible
python version = 3.6.8 (default, Dec 5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
CONFIGURATION
ANSIBLE_PIPELINING(/root/ansible/ansible.cfg) = True
DEFAULT_HOST_LIST(/root/ansible/ansible.cfg) = ['/root/ansible/inventory']
DEFAULT_REMOTE_USER(/root/ansible/ansible.cfg) = ansible
DEFAULT_ROLES_PATH(/root/ansible/ansible.cfg) = ['/root/ansible/roles']
HOST_KEY_CHECKING(/root/ansible/ansible.cfg) = False
OS / ENVIRONMENT
Rhel7, vmware 7
STEPS TO REPRODUCE
- name: Adapt VM OS guest settings
community.vmware.vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
state: present
name: "{{ vm_name | default(inventory_hostname) }}"
# customvalues: "{{ vm_customvalues }}"
hardware:
memory_mb: "{{ vm_memory_mb | default(1024) }}"
memory_reservation_lock: true
num_cpus: "{{ vm_num_cpus | default(4) }}"
num_cpu_cores_per_socket: "{{ vm_num_cpus | default(4) }}"
# version: latest
# disk: "{{ vm_disk_std }}"
networks: "{{ vm_networks }}"
wait_for_customization: true
wait_for_ip_address: true
customization: "{{ vm_cust }}"
register: changed_vm
delegate_to: localhost
EXPECTED RESULTS
No error.
ACTUAL RESULTS
Files identified in the description:
- [
plugins/modules/vmware_guest.py](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/vmware_guest.py)
If these files are inaccurate, please update the component name section of the description or use the !component bot command.
cc @Akasurde @Tomorrow9 @goneri @lparkes @nerzhul @pdellaert @pgbidkar @warthog9 click here for bot help
We're facing the same symptoms in our environment (various versions of Ansible and pyvmomi, until most recent). I like to add some observations: The problem only occurs, if the vCenter user has access to multiple data centres using the same network labels, AND the name of the network contains characters of a typical IPv4 prefix. E.g. "192.168.10.0/24"
This would be quite easy to fix in plugins/modules/vmware_guest.py:
def get_network(self, network):
network = quote_obj_name(network) # <-- remove this line, since it's quoting an already quoted string
Would be great, if someone with project involvement can have a quick look.
+1
This issue has been opened for ansible 2.9.10, which is EOL meanwhile. Can someone please test if this problem still exists in the current version of community.vmware (2.7.0)?
I've tested the same with collection version 2.7.0 now: Same result, the bug still persists and the respective part of the code was not changed in the meantime.