Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"TypeError: 'NoneType' object is not iterable" thrown when device_filter doesn't match devices #1293

Closed
1 task done
noredistribution opened this issue Oct 28, 2021 · 4 comments
Assignees
Labels
state: stale type: bug Something isn't working

Comments

@noredistribution
Copy link
Contributor

Issue Summary

Seems like if device_filter is set in the playbook, even when using cvp v3 modules it is not ignored so if the filter doesn't match any devices the playbook will fail with something like below:

TypeError: 'NoneType' object is not iterable\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",

found some refs here: https://github.com/aristanetworks/ansible-avd/blob/devel/ansible_collections/arista/avd/roles/eos_config_deploy_cvp/templates/cvp-devices-v3.j2
https://github.com/aristanetworks/ansible-avd/blob/devel/ansible_collections/arista/avd/plugins/modules/inventory_to_container.py

we should either completely ignore this with v3 and/or improve the error handling and print that the filter didn't match on any devices

Which component(s) of AVD impacted

cvp_configlet_upload, eos_config_deploy_cvp

How do you run AVD ?

Ansible CLI (with virtual-env or native python)

Steps to reproduce

to repro simply add a `device_filter` that wouldn't match on any device, like in this playbook: https://github.com/arista-netdevops-community/ipspace-webinar-september15-2020/blob/master/playbooks/dc1-fabric-deploy-cvp.yml


- name: Configuration deployment with CVP
  hosts: AVD-CVP-1
  connection: local
  gather_facts: no
  tasks:
    - name: run CVP provisioning
      import_role:
         name: arista.avd.eos_config_deploy_cvp
      vars:
        container_root: 'TP_FABRIC'
        configlets_prefix: 'tp-avd'
        cv_collection: v3
        device_filter: 'tP-avd'
        state: present


### Relevant log output

```shell
TASK [arista.avd.eos_config_deploy_cvp : Configure devices on AVD-CVP-1] ******************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: 'NoneType' object is not iterable
fatal: [AVD-CVP-1]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/avd/.ansible/tmp/ansible-local-6068c2fjihx0/ansible-tmp-1635425729.7986908-7573-252610785688833/AnsiballZ_cv_device_v3.py\", line 100, in <module>\n    _ansiballz_main()\n  File \"/home/avd/.ansible/tmp/ansible-local-6068c2fjihx0/ansible-tmp-1635425729.7986908-7573-252610785688833/AnsiballZ_cv_device_v3.py\", line 92, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/avd/.ansible/tmp/ansible-local-6068c2fjihx0/ansible-tmp-1635425729.7986908-7573-252610785688833/AnsiballZ_cv_device_v3.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.arista.cvp.plugins.modules.cv_device_v3', init_globals=dict(_module_fqn='ansible_collections.arista.cvp.plugins.modules.cv_device_v3', _modlib_path=modlib_path),\n  File \"/usr/local/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/local/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/local/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_arista.cvp.cv_device_v3_payload_2txlj912/ansible_arista.cvp.cv_device_v3_payload.zip/ansible_collections/arista/cvp/plugins/modules/cv_device_v3.py\", line 219, in <module>\n  File \"/tmp/ansible_arista.cvp.cv_device_v3_payload_2txlj912/ansible_arista.cvp.cv_device_v3_payload.zip/ansible_collections/arista/cvp/plugins/modules/cv_device_v3.py\", line 194, in main\n  File \"/tmp/ansible_arista.cvp.cv_device_v3_payload_2txlj912/ansible_arista.cvp.cv_device_v3_payload.zip/ansible_collections/arista/cvp/plugins/module_utils/device_tools.py\", line 265, in __init__\nTypeError: 'NoneType' object is not iterable\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Contributing Guide

  • I agree to follow this project's Code of Conduct
@noredistribution
Copy link
Contributor Author

fixed by aristanetworks/ansible-cvp#412

@noredistribution
Copy link
Contributor Author

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 15 days

@github-actions
Copy link

github-actions bot commented May 2, 2022

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 15 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: stale type: bug Something isn't working
Projects
None yet
2 participants