community.network
community.network copied to clipboard
exos_facts error : 'Cli' object has no attribute 'send_requests'
SUMMARY
When using exos_facts module with gather_network_resources parameter (whatever the value is) with ansible_connection: ansible.netcommon.network_cli and network_os: community.network.exos the following error happens :
'Cli' object has no attribute 'send_requests'
ISSUE TYPE
- Bug Report
COMPONENT NAME
exos_facts.py
ANSIBLE VERSION
ansible [core 2.13.3]
config file = /home/yannis/gitlab/test/ansible.cfg
configured module search path = ['/home/yannis/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/yannis/.cache/pypoetry/virtualenvs/ansible-automation-V_pxrf9j-py3.8/lib/python3.8/site-packages/ansible
ansible collection location = /home/yannis/.ansible/collections:/usr/share/ansible/collections
executable location = /home/yannis/.cache/pypoetry/virtualenvs/ansible-automation-V_pxrf9j-py3.8/bin/ansible
python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
jinja version = 3.0.3
libyaml = True
COLLECTION VERSION
# /home/yannis/.ansible/collections/ansible_collections
Collection Version
----------------- -------
community.network 4.0.1
# /home/yannis/.cache/pypoetry/virtualenvs/ansible-automation-V_pxrf9j-py3.8/lib/python3.8/site-packages/ansible_collections
Collection Version
----------------- -------
community.network 4.0.1
CONFIGURATION
ANSIBLE_PIPELINING(/home/yannis/gitlab/test/ansible.cfg) = True
CACHE_PLUGIN(/home/yannis/gitlab/test/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/yannis/gitlab/test/ansible.cfg) = cache
CACHE_PLUGIN_TIMEOUT(/home/yannis/gitlab/test/ansible.cfg) = 3600
DEFAULT_FORCE_HANDLERS(/home/yannis/gitlab/test/ansible.cfg) = True
DEFAULT_FORKS(/home/yannis/gitlab/test/ansible.cfg) = 50
DEFAULT_GATHERING(/home/yannis/gitlab/test/ansible.cfg) = smart
DEFAULT_JINJA2_EXTENSIONS(/home/yannis/gitlab/test/ansible.cfg) = jinja2.ext.do
DEPRECATION_WARNINGS(/home/yannis/gitlab/test/ansible.cfg) = True
HOST_KEY_CHECKING(/home/yannis/gitlab/test/ansible.cfg) = False
INTERPRETER_PYTHON(/home/yannis/gitlab/test/ansible.cfg) = auto_silent
INVENTORY_CACHE_ENABLED(/home/yannis/gitlab/test/ansible.cfg) = True
INVENTORY_CACHE_PLUGIN(/home/yannis/gitlab/test/ansible.cfg) = jsonfile
INVENTORY_CACHE_TIMEOUT(/home/yannis/gitlab/test/ansible.cfg) = 3600
PERSISTENT_COMMAND_TIMEOUT(/home/yannis/gitlab/test/ansible.cfg) = 60
RETRY_FILES_ENABLED(/home/yannis/gitlab/test/ansible.cfg) = False
OS / ENVIRONMENT
Ubuntu 20.04 on WSL2 Extreme EXOS version 22.7.1.2 & 30.7.1.1 & 31.7.1.4
STEPS TO REPRODUCE
---
- hosts: platform_extreme-exos
name: Gather ExtremeOS facts
gather_facts: false
tasks:
- name: Gather network resource and legacy facts
community.network.exos_facts:
#gather_subset: min
gather_network_resources: all
- ansible.builtin.debug:
var: "{{ item }}"
loop:
- ansible_net_version
- ansible_net_model
EXPECTED RESULTS
The module should work and return/set network_resources facts for the host
ACTUAL RESULTS
An error stops the module from working and triggers a fatal error
Loading collection community.network from /home/yannis/.ansible/collections/ansible_collections/community/network
redirecting (type: modules) community.network.exos_facts to community.network.network.exos.exos_facts
Loading callback plugin default of type stdout, v2.0 from /home/yannis/.cache/pypoetry/virtualenvs/ansible-automation-V_pxrf9j-py3.8/lib/python3.8/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
PLAYBOOK: gather_exos_facts.yml **********************************************************************************************************************************************************************************************
Positional arguments: playbooks/gather_exos_facts.yml
verbosity: 4
connection: smart
timeout: 10
force_handlers: True
become_method: sudo
tags: ('all',)
inventory: ('/home/yannis/gitlab/test/inventory',)
subset: xxx-exos-xxx
forks: 50
1 plays in playbooks/gather_exos_facts.yml
PLAY [Gather ExtremeOS facts] *********************************************************************************************************************************************************************************************
META: ran handlers
Loading collection ansible.netcommon from /home/yannis/.ansible/collections/ansible_collections/ansible/netcommon
<10.10.10.10> attempting to start connection
<10.10.10.10> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/yannis/.cache/pypoetry/virtualenvs/ansible-automation-V_pxrf9j-py3.8/bin/ansible-connection
<10.10.10.10> local domain socket does not exist, starting it
<10.10.10.10> control socket path is /home/yannis/.ansible/pc/1e2577eff7
<10.10.10.10> Loading collection ansible.netcommon from /home/yannis/.ansible/collections/ansible_collections/ansible/netcommon
<10.10.10.10> Loading collection community.network from /home/yannis/.ansible/collections/ansible_collections/community/network
<10.10.10.10> local domain socket listeners started successfully
<10.10.10.10> loaded cliconf plugin ansible_collections.community.network.plugins.cliconf.exos from path /home/yannis/.ansible/collections/ansible_collections/community/network/plugins/cliconf/exos.py for network_os community.network.exos
<10.10.10.10> ssh type is set to auto
<10.10.10.10> autodetecting ssh_type
<10.10.10.10> ssh type is now set to libssh
<10.10.10.10>
<10.10.10.10> local domain socket path is /home/yannis/.ansible/pc/1e2577eff7
redirecting (type: modules) community.network.exos_facts to community.network.network.exos.exos_facts
<10.10.10.10> Using network group action community.network.exos for community.network.exos_facts
<10.10.10.10> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
redirecting (type: modules) community.network.exos_facts to community.network.network.exos.exos_facts
<10.10.10.10> ANSIBLE_NETWORK_IMPORT_MODULES: found community.network.exos_facts at /home/yannis/.ansible/collections/ansible_collections/community/network/plugins/modules/network/exos/exos_facts.py
<10.10.10.10> ANSIBLE_NETWORK_IMPORT_MODULES: running community.network.exos_facts
<10.10.10.10> ANSIBLE_NETWORK_IMPORT_MODULES: complete
TASK [Gather network resource and legacy facts] **************************************************************************************************************************************************************************
task path: /home/yannis/gitlab/test/playbooks/gather_exos_facts.yml:9
The full traceback is:
File "/home/yannis/.ansible/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py", line 133, in get_network_resources_facts
inst.populate_facts(
File "/home/yannis/.ansible/collections/ansible_collections/community/network/plugins/module_utils/network/exos/facts/vlans/vlans.py", line 55, in populate_facts
data = send_requests(self._module, requests=request)
File "/home/yannis/.ansible/collections/ansible_collections/community/network/plugins/module_utils/network/exos/exos.py", line 208, in send_requests
return conn.send_requests(to_request(module, requests))
fatal: [xxx-exos-xxx]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"gather_network_resources": [
"all"
],
"gather_subset": [
"!config"
]
}
},
"msg": "'Cli' object has no attribute 'send_requests'"
}
}
PLAY RECAP ***************************************************************************************************************************************************************************************************************
xxx-exos-xxx : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Hello, i just setup my environment. I was able to replicate this and will see what needs to be change din the code in order to make it work.
hello folks, thanks for reporting this!
@LindsayHill @ujwalkomarla @rdvencioneck @hlrichardson @jayalakshmiV you're authors/maintainers of related modules, if you take a look, it'd be great
I took a look at this issue, because i wanted to use the facts gathered using gather_network_resources.
The gather_network_resources parameter does not yet support ansible.netcommon.network_cli
, it only supports ansible.netcommon.httpap
i.
Workaround would be to add ansible_connection: ansible.netcommon.httpapi
to the module call like so:
- exos_facts:
gather_subset: "!all"
gather_network_resources: all
vars:
ansible_connection: ansible.netcommon.httpapi
As you can see for example in:
https://github.com/ansible-collections/community.network/blob/312b5d87cbb73f17acd4d254889145228d35fb19/plugins/module_utils/network/exos/facts/lldp_global/lldp_global.py#L59
the API path is hardcoded and it only imports/calls the send_requests function in every subset class.
ansible.netcommon.network_cli
only implements run_commands
,
ansible.netcommon.httpapi
supports both run_commands and send_requests.
Using the HTTP/REST API is much cleaner and simpler than parsing command output. The later is more complex and error prone.
I don't know if there are use cases that only allow for using network_cli and not httpapi, so i have not yet taken the time to look into implementing gather_network_resources for network_cli.
I will add a commit to my PR #558 to clarify that in the module documentation.