networklore / ansible-snmp Goto Github PK
View Code? Open in Web Editor NEWSNMP modules for Ansible
License: Other
SNMP modules for Ansible
License: Other
When I run my playbook, the task for GET LLDP NEIGHBORS fails and it seems to be because the SNMP task does not return the proper version. The switch is an Aruba 3810M running KB.16.04.0009 soon to be running KB.16.05.0007.
Troubleshooting: I have tested with Cisco and had (not in uploaded files) been calling a variable from the group_vars to call the correct version of "show lldp neighbors" (even though the present file shows a cdp command).
Thanks in advance! I don't know if you plan on keeping this up-to-date, but it has been an asset to us thus far.
Any thoughts as to why the version info returned would be UNKNOWN?
Main output:
ok: [itb-neteng-b-nomon] => {
"ansible_facts": {
"ansible_device_os": "UNKNOWN",
"ansible_device_vendor": "UNKNOWN",
"ansible_device_version": "UNKNOWN"
},
"changed": false,
"invocation": {
"module_args": {
"authkey": null,
"community": "expand",
"host": "itb-neteng-b-nomon",
"integrity": null,
"level": null,
"port": 161,
"privacy": null,
"privkey": null,
"username": null,
"version": "2c"
}
}
}
TASK [GET SNMP DISCOVERY INFORMATION] **********************************************************************************************************************************************************************
task path: /home/adm.bwood7/ansible/auto-config-port-descriptions.yml:14
Using module file /home/adm.bwood7/.ansible/plugins/modules/ansible-snmp/library/snmp_device_version.py-ORIG
ESTABLISH LOCAL CONNECTION FOR USER: adm.bwood7
EXEC /bin/sh -c 'echo ~adm.bwood7 && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /home/adm.bwood7/.ansible/tmp/ansible-tmp-1529962064.11-245345196987957
" && echo ansible-tmp-1529962064.11-245345196987957="echo /home/adm.bwood7/.ansible/tmp/ansible-tmp-1529962064.11-245345196987957
" ) && sleep 0'
PUT /home/adm.bwood7/.ansible/tmp/ansible-local-11605g0vFl4/tmpjr92pd TO /home/adm.bwood7/.ansible/tmp/ansible-tmp-1529962064.11-245345196987957/snmp_device_version.py-ORIG
EXEC /bin/sh -c 'chmod u+x /home/adm.bwood7/.ansible/tmp/ansible-tmp-1529962064.11-245345196987957/ /home/adm.bwood7/.ansible/tmp/ansible-tmp-1529962064.11-245345196987957/snmp_device_version.py-ORIG && sleep 0'
EXEC /bin/sh -c '/usr/bin/python /home/adm.bwood7/.ansible/tmp/ansible-tmp-1529962064.11-245345196987957/snmp_device_version.py-ORIG && sleep 0'
EXEC /bin/sh -c 'rm -f -r /home/adm.bwood7/.ansible/tmp/ansible-tmp-1529962064.11-245345196987957/ > /dev/null 2>&1 && sleep 0'
ok: [itb-neteng-b-nomon] => {
"ansible_facts": {
"ansible_device_os": "UNKNOWN",
"ansible_device_vendor": "UNKNOWN",
"ansible_device_version": "UNKNOWN"
},
"changed": false,
"invocation": {
"module_args": {
"authkey": null,
"community": "expand",
"host": "itb-neteng-b-nomon",
"integrity": null,
"level": null,
"port": 161,
"privacy": null,
"privkey": null,
"username": null,
"version": "2c"
}
}
}
TASK [GET LLDP NEIGHBORS] **********************************************************************************************************************************************************************************
task path: /home/adm.bwood7/ansible/auto-config-port-descriptions.yml:20
fatal: [itb-neteng-b-nomon]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The error was: 'creds' is undefined\n\nThe error appears to have been in '/home/adm.bwood7/ansible/auto-config-port-descriptions.yml': line 20, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: GET LLDP NEIGHBORS\n ^ here\n"
}
PLAY RECAP *************************************************************************************************************************************************************************************************
itb-neteng-b-nomon : ok=1 changed=0 unreachable=0 failed=1
Files are included in the .zip file (ansible.cfg, playbook (auto-config-port-descriptions.yml), group_vars, and hosts):
PREVIOUS OUTPUT FOR 'GET LLDP NEIGHBORS'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_LLbyrs/ansible_module_ntc_show_command.py", line 511, in
main()
File "/tmp/ansible_LLbyrs/ansible_module_ntc_show_command.py", line 454, in main
device = ConnectHandler(**device_args)
File "/usr/lib/python2.7/site-packages/netmiko/ssh_dispatcher.py", line 176, in ConnectHandler
'currently supported platforms are: {}'.format(platforms_str))
ValueError: Unsupported device_type: currently supported platforms are:
a10
accedian
alcatel_aos
alcatel_sros
arista_eos
aruba_os
avaya_ers
avaya_vsp
brocade_fastiron
brocade_netiron
brocade_nos
brocade_vdx
brocade_vyos
calix_b6
checkpoint_gaia
ciena_saos
cisco_asa
cisco_ios
cisco_nxos
cisco_s300
cisco_tp
cisco_wlc
cisco_xe
cisco_xr
coriant
dell_force10
dell_powerconnect
eltex
enterasys
extreme
extreme_wing
f5_ltm
fortinet
generic_termserver
hp_comware
hp_procurve
huawei
huawei_vrpv8
juniper
juniper_junos
linux
mellanox
mrv_optiswitch
netapp_cdot
ovs_linux
paloalto_panos
pluribus
quanta_mesh
ruckus_fastiron
ubiquiti_edge
ubiquiti_edgeswitch
vyatta_vyos
vyos
Attached files:
I was testing snmp_device_version.py
with python3 on Ansible and it would throw this error:
The full traceback is:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/executor/task_executor.py", line 140, in run
res = self._execute()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/executor/task_executor.py", line 612, in _execute
result = self._handler.run(task_vars=variables)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/plugins/action/normal.py", line 46, in run
result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/plugins/action/__init__.py", line 742, in _execute_module
(module_style, shebang, module_data, module_path) = self._configure_module(module_name=module_name, module_args=module_args, task_vars=task_vars)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/plugins/action/__init__.py", line 178, in _configure_module
environment=final_environment)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/executor/module_common.py", line 973, in modify_module
environment=environment)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/executor/module_common.py", line 791, in _find_module_utils
recursive_finder(module_name, b_module_data, py_module_names, py_module_cache, zf)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/executor/module_common.py", line 538, in recursive_finder
tree = ast.parse(data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 157
except Exception, err:
^
SyntaxError: invalid syntax
fatal: [csr1]: FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}
After changing the code in lines 157
and 163
to update to python3 syntax, it fixed the issue.
Python2 syntax:
try:
dev = SnmpHandler(**nelsnmp_args)
except Exception, err:
module.fail_json(msg=str(err))
hostinfo = HostInfo(dev)
try:
hostinfo.get_version()
except Exception, err:
module.fail_json(msg=str(err))
Python3 syntax:
try:
dev = SnmpHandler(**nelsnmp_args)
except Exception as err:
module.fail_json(msg=str(err))
hostinfo = HostInfo(dev)
try:
hostinfo.get_version()
except Exception as err:
module.fail_json(msg=str(err))
Hi ,
When I run the following code I get no data back from the device. When I run the module using Ansible I do get data back. Can you help explain that ?
from nelsnmp.snmp import SnmpHandler
from nelsnmp.hostinfo.device import HostInfo
def main():
try:
dev = SnmpHandler(host='1.1.1.1', community='xxxxx', version='2c')
hostinfo = HostInfo(dev)
print "trying..."
print hostinfo.get_version()
except Exception as err:
print "Must be a timeout or something", err
main()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.