community.vmware icon indicating copy to clipboard operation
community.vmware copied to clipboard

vmware_guest - 'TypeError: 'NoneType' object is not iterable'

Open neevnuv opened this issue 4 months ago • 1 comments

SUMMARY

When running vmware_guest to create a new vm, we receive the error: TypeError: 'NoneType' object is not iterable in module_utiles/vmware.py line 1281.

This is cause because the actual_vm_folder_path variable is None. Which means the function get_vm_path returns None. Going through the function we have concluded that vm_name.parent has returned None (we haven't yet found why).

As a short fix, my team changed these line with vm_obj = vms[0].

We work in an airgapped environment so it is more difficult to add logs, we hoped by opening this issue that an handler will be added for when the actual_vm_folder_path variable is empty.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • vmware_guest
  • state: poweredon
  • Creating Virtual Machine
ANSIBLE VERSION
ansible-core 2.14
COLLECTION VERSION
latest (5.0.1), this issue happens in all previous versions
CONFIGURATION
Will be added in the future
OS / ENVIRONMENT

VSphere 8.0.3 RHEL 8/7 VM

STEPS TO REPRODUCE
- name: Create a virtual machine from a template
  community.vmware.vmware_guest:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    folder: "{{ vcenter_folder }}"
    name: my-vm
    state: poweredon
    template: rhel8
    disk:
    - size_gb: 10
      type: thin
      datastore: "{{ vcenter_datastore }}"
    hardware:
      memory_mb: 512
      num_cpus: 4
    networks:
    - name: VM Network
      ip: {{ vcenter_ip }}
      netmask: 255.255.255.0
    wait_for_ip_address: true
  delegate_to: localhost
  register: dployed_vm
EXPECTED RESULTS

A new vm was created in the folder specified

ACTUAL RESULTS
TypeError: 'NoneType' object is not iterable

neevnuv avatar Oct 12 '24 15:10 neevnuv