ansible-cvp
ansible-cvp copied to clipboard
Unhelpful error message when CVP token auth fails
Issue Summary
When token authentication fails while retrieving CVP facts, the error message is unhelpful. There seems to be no error handling for this case. Also the actual CVP error message is logged by invoking MODULE_LOGGER.error
which is not displayed by Ansible.
Ansible Task:
- name: Gather CVP facts
arista.cvp.cv_facts_v3:
facts:
- devices
register: cvp_facts
Error Message:
ASK [corp.cvp.upload_config : Gather CVP facts] ***************************************************************************************
Friday 31 March 2023 09:49:55 +0200 (0:00:00.020) 0:00:01.876 **********
fatal: [cvp.test.corp.de]: FAILED! => {
"changed": false,
"rc": 1
}
MSG:
MODULE FAILURE
See stdout/stderr for the exact error
MODULE_STDERR:
/Users/dummyuser/repositories/work/testcvp1/venv/lib/python3.11/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'cvp.test.corp.de'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
/Users/dummyuser/repositories/work/testcvp1/venv/lib/python3.11/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'cvp.test.corp.de'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
/Users/dummyuser/repositories/work/testcvp1/venv/lib/python3.11/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'cvp.test.corp.de'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
Traceback (most recent call last):
File "/Users/dummyuser/.ansible/tmp/ansible-local-56212b3ist0rc/ansible-tmp-1680248996.800731-56291-56091543789778/AnsiballZ_cv_facts_v3.py", line 107, in <module>
_ansiballz_main()
File "/Users/dummyuser/.ansible/tmp/ansible-local-56212b3ist0rc/ansible-tmp-1680248996.800731-56291-56091543789778/AnsiballZ_cv_facts_v3.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/Users/dummyuser/.ansible/tmp/ansible-local-56212b3ist0rc/ansible-tmp-1680248996.800731-56291-56091543789778/AnsiballZ_cv_facts_v3.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.arista.cvp.plugins.modules.cv_facts_v3', init_globals=dict(_module_fqn='ansible_collections.arista.cvp.plugins.modules.cv_facts_v3', _modlib_path=modlib_path),
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 "/var/folders/nv/vdqjyk_d4sqd0h_sxl5q_rsw0000gn/T/ansible_arista.cvp.cv_facts_v3_payload_4gs1b37z/ansible_arista.cvp.cv_facts_v3_payload.zip/ansible_collections/arista/cvp/plugins/modules/cv_facts_v3.py", line 152, in <module>
File "/var/folders/nv/vdqjyk_d4sqd0h_sxl5q_rsw0000gn/T/ansible_arista.cvp.cv_facts_v3_payload_4gs1b37z/ansible_arista.cvp.cv_facts_v3_payload.zip/ansible_collections/arista/cvp/plugins/modules/cv_facts_v3.py", line 143, in main
File "/var/folders/nv/vdqjyk_d4sqd0h_sxl5q_rsw0000gn/T/ansible_arista.cvp.cv_facts_v3_payload_4gs1b37z/ansible_arista.cvp.cv_facts_v3_payload.zip/ansible_collections/arista/cvp/plugins/module_utils/facts_tools.py", line 275, in facts
File "/var/folders/nv/vdqjyk_d4sqd0h_sxl5q_rsw0000gn/T/ansible_arista.cvp.cv_facts_v3_payload_4gs1b37z/ansible_arista.cvp.cv_facts_v3_payload.zip/ansible_collections/arista/cvp/plugins/module_utils/facts_tools.py", line 490, in __fact_devices
UnboundLocalError: cannot access local variable 'cv_devices' where it is not associated with a value
Which component(s) of AVD impacted
cv_facts_v3
How do you run AVD ?
Ansible CLI (with virtual-env or native python)
Input variables
No response
Steps to reproduce
No response
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
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
@sebastianw What is ansible-cvp version you tested this on? And what CVP version was this? On my end, this is what I am seeing with invalid token on on-perm cvp version: 2023.1.1
and ansible-cvp version 3.10.1
(avd) ➜ Facts ansible-playbook facts_devices.yml -i ../Inventory_files/inventory_ATD.yml
PLAY [cv_facts_v3 benchmarking] ******************************************************************************************************************************************************************************************************************************************
TASK [gather cvp facts] **************************************************************************************************************************************************************************************************************************************************
fatal: [CloudVision]: FAILED! => changed=false
msg: 'GET: https://staticstudio-1-cfec4cc2-eos.topo.testdrive.arista.com:443/web/cvpInfo/getCvpInfo.do : Request Error: Unauthorized'
PLAY RECAP ***************************************************************************************************************************************************************************************************************************************************************
CloudVision : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0