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

vmware_all_snapshots_info: AttributeError: 'NoneType' object has no attribute 'name'

Open StratsScorpio opened this issue 1 year ago • 2 comments

SUMMARY
  • On Execution I get the error "AttributeError: 'NoneType' object has no attribute 'name'"
ISSUE TYPE
  • Bug Report
COMPONENT NAME
  • community.vmware.vmware_all_snapshots_info
ANSIBLE VERSION
ansible-playbook [core 2.18.1]
  python version = 3.12.3 (main, Nov  6 2024, 18:32:19) [GCC 13.2.0] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION
Collection        Version
----------------- -------
ansible.posix     1.5.4  
ansible.utils     5.1.0  
checkmk.general   5.2.1  
community.general 9.3.0  
community.vmware  5.2.0  
vmware.vmware     1.7.1
CONFIGURATION
ANSIBLE_PIPELINING(/home/ansible/server/ansible.cfg) = True
CACHE_PLUGIN(/home/ansible/server/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/ansible/server/ansible.cfg) = ./.ansible-cache
CACHE_PLUGIN_TIMEOUT(/home/ansible/server/ansible.cfg) = 86400
COLLECTIONS_PATHS(/home/ansible/server/ansible.cfg) = ['/home/ansible/server/collections']
CONFIG_FILE() = /home/ansible/server/ansible.cfg
DEFAULT_CALLBACK_PLUGIN_PATH(/home/ansible/server/ansible.cfg) = ['/home/ansible/server/callbacks']
DEFAULT_FORKS(/home/ansible/server/ansible.cfg) = 20
DEFAULT_HOST_LIST(/home/ansible/server/ansible.cfg) = ['/home/ansible/server/inventory']
DEFAULT_REMOTE_USER(/home/ansible/server/ansible.cfg) = root
DEFAULT_ROLES_PATH(/home/ansible/server/ansible.cfg) = ['/home/ansible/server/roles']
DEFAULT_STDOUT_CALLBACK(/home/ansible/server/ansible.cfg) = yaml
DISPLAY_SKIPPED_HOSTS(env: ANSIBLE_DISPLAY_SKIPPED_HOSTS) = False
HOST_KEY_CHECKING(/home/ansible/server/ansible.cfg) = False
MAX_FILE_SIZE_FOR_DIFF(/home/ansible/server/ansible.cfg) = 1044480
OS / ENVIRONMENT
  • Debian 12
  • Mint Linux 22
STEPS TO REPRODUCE

Execute the adhoc-script which calls the role vm_snapshots. The gathering yml is main.yml in tasks from this role. Variables are defined in defaults/main.yml from this role.

---
- name: Clear all VM Snapshots
  hosts: localhost
  roles:
    - role: vm_snapshots
...

roles/vm_snapshots/tasks/main.yml:

---
- name: Gather information of specified snapshots
  community.vmware.vmware_all_snapshots_info:
    validate_certs: false
    hostname: '{{ vmdeploy_vcenter_hostname }}'
    username: '{{ vmdeploy_vcenter_user }}'
    password: '{{ vmdeploy_vcenter_password }}'
    datacenter: '{{ vmdeploy_datacenter }}'
    match_type: 'includes'
    filters:
      name: '{{ vm_snapshots_snapshot_name }}'
  delegate_to: localhost
...
EXPECTED RESULTS

A return like in the ansible-documentation

ACTUAL RESULTS

Unexpected Error.

TASK [vm_snapshots : Gather information of specified snapshots] ********************************************************************
task path: /home/ansible/server/roles/vm_snapshots/tasks/main.yml:6
The full traceback is:
Traceback (most recent call last):
  File "<stdin>", line 107, in <module>
  File "<stdin>", line 99, in _ansiballz_main
  File "<stdin>", line 47, in invoke_module
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/tmp/ansible_community.vmware.vmware_all_snapshots_info_payload_rm50o0_l/ansible_community.vmware.vmware_all_snapshots_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_all_snapshots_info.py", line 204, in <module>
  File "/tmp/ansible_community.vmware.vmware_all_snapshots_info_payload_rm50o0_l/ansible_community.vmware.vmware_all_snapshots_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_all_snapshots_info.py", line 199, in main
  File "/tmp/ansible_community.vmware.vmware_all_snapshots_info_payload_rm50o0_l/ansible_community.vmware.vmware_all_snapshots_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_all_snapshots_info.py", line 164, in gather_snapshots_info
AttributeError: 'NoneType' object has no attribute 'name'
fatal: [localhost]: FAILED! => changed=false 
  module_stderr: |-
    Traceback (most recent call last):
      File "<stdin>", line 107, in <module>
      File "<stdin>", line 99, in _ansiballz_main
      File "<stdin>", line 47, in invoke_module
      File "<frozen runpy>", line 226, in run_module
      File "<frozen runpy>", line 98, in _run_module_code
      File "<frozen runpy>", line 88, in _run_code
      File "/tmp/ansible_community.vmware.vmware_all_snapshots_info_payload_rm50o0_l/ansible_community.vmware.vmware_all_snapshots_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_all_snapshots_info.py", line 204, in <module>
      File "/tmp/ansible_community.vmware.vmware_all_snapshots_info_payload_rm50o0_l/ansible_community.vmware.vmware_all_snapshots_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_all_snapshots_info.py", line 199, in main
      File "/tmp/ansible_community.vmware.vmware_all_snapshots_info_payload_rm50o0_l/ansible_community.vmware.vmware_all_snapshots_info_payload.zip/ansible_collections/community/vmware/plugins/modules/vmware_all_snapshots_info.py", line 164, in gather_snapshots_info
    AttributeError: 'NoneType' object has no attribute 'name'
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

PLAY RECAP *************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

StratsScorpio avatar Dec 05 '24 14:12 StratsScorpio

I'm sorry, but my priority ATM is to make the collection work with the upcoming ansible-core 2.19 release (#2388 and #2391).

It turns out that this is harder than I originally expected. Please bear wit me :pray:

mariolenz avatar May 07 '25 17:05 mariolenz

Thats no problem for me anymore. We are moving away from VMware. In ca. 6 months the last VM is on OpenShift and which VM don't want to work with kubevirt it get Proxmox :) .

But maybe interesting for other users, which will remain with VMware, so this issue should be open until fix.

StratsScorpio avatar May 07 '25 17:05 StratsScorpio