networklore / ansible-cisco-snmp Goto Github PK
View Code? Open in Web Editor NEWAnsible modules using SNMP to manage Cisco devices
License: Other
Ansible modules using SNMP to manage Cisco devices
License: Other
Hello Friend,
Is There any way to backup the running configuration into the host that runs ansible?
I looked at cisco_snmp_save_config, but looks like is just "Save the running configuration to startup".
It is possible to extend the script for setup portAdminSpeed and portDuplex on interface?
The problem is Cisoco use in this case a seperate CISCO-STACK-MIB
self.portAdminSpeed = "1.3.6.1.4.1.9.5.1.4.1.1.9"
self.portDuplex = "1.3.6.1.4.1.9.5.1.4.1.1.10"
self.portIfIndex = "1.3.6.1.4.1.9.5.1.4.1.1.11"
And works with portIfIndex mapping to ifIndex here:
| -- portIfIndex (11)
1.3.6.1.4.1.9.5.1.4.1.1.11.1.1 = INTEGER: 10101
1.3.6.1.4.1.9.5.1.4.1.1.11.1.2 = INTEGER: 10102
1.3.6.1.4.1.9.5.1.4.1.1.11.1.3 = INTEGER: 10001
1.3.6.1.4.1.9.5.1.4.1.1.11.1.4 = INTEGER: 10002
1.3.6.1.4.1.9.5.1.4.1.1.11.1.5 = INTEGER: 10003
1.3.6.1.4.1.9.5.1.4.1.1.11.1.6 = INTEGER: 10004
1.3.6.1.4.1.9.5.1.4.1.1.11.1.7 = INTEGER: 10005
The ifIndex are the following interfaces:
IF-MIB::ifDescr.10101 = STRING: GigabitEthernet1/0/1
IF-MIB::ifDescr.10102 = STRING: GigabitEthernet1/0/2
IF-MIB::ifDescr.10001 = STRING: FastEthernet1/0/1
IF-MIB::ifDescr.10002 = STRING: FastEthernet1/0/2
IF-MIB::ifDescr.10003 = STRING: FastEthernet1/0/3
IF-MIB::ifDescr.10004 = STRING: FastEthernet1/0/4
IF-MIB::ifDescr.10005 = STRING: FastEthernet1/0/5
This are the possible values:
portAdminSpeed
Values
1 : autoDetect
2 : autoDetect10100
10 : s10G
64000 : s64000
1544000 : s1544000
2000000 : s2000000
2048000 : s2048000
4000000 : s4000000
10000000 : s10000000
16000000 : s16000000
45000000 : s45000000
64000000 : s64000000
100000000 : s100000000
155000000 : s155000000
400000000 : s400000000
622000000 : s622000000
1000000000 : s1000000000
portDuplex
Values
1 : half
2 : full
3 : disagree
4 : auto
Could you added this or give me a hint how can I write the mapping find function of ifIndex to portIfIndex in python script?
First of all, these modules are AWESOME!
I'm trying to figure out how to solve this error:
failed: [x.x.x.x] => {"failed": true, "parsed": false}
Traceback (most recent call last):
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1446051069.8-34119550336394/cisco_snmp_vlan", line >1914, in <module>
main()
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1446051069.8-34119550336394/cisco_snmp_vlan", line >1898, in main
vartable = dev.getnext(o.vtpVlanEditTable)
File "/usr/local/lib/python2.7/dist-packages/nelsnmp/snmp.py", line 278, in getnext
lookupMib=False
File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 222, in nextCmd
return errorIndication, errorStatus, errorIndex, varBindTable
UnboundLocalError: local variable 'errorIndication' referenced before assignment
FATAL: all hosts have already failed -- aborting
It just happens when I try to create a Vlan on the device, I'm testing using a Catalyst 2960. This error occurs for both SNMP v2c and v3.
Everything else works fine!
Thanks
Hey, I try to use your code with my projet but I don't know how to put multiple final config, how the switch will know to take his config based on mac address or serial number if its possible.
Also use option 125 for ios_version.bin.
Can i contact you by email or slack for exemple?
tank you.
Nicolas
Hi Patrick,
I am first time using this module. Getting this error:
Unable to import cisco_snmp_portsecurity due to invalid syntax
installed nelsnmp
cloned ansible-cisco-snmp
ansible.cfg - pointing library to ansible-cisco-snmp/library
$ cat ansible.cfg
[defaults]
library = /tmp/certs/ansible-cisco-snmp/librar
running following code:
cat test-snmp.yml
---
- hosts: all
connection: local
gather_facts: no
tasks:
# - name: test
# cisco_snmp_interface:
#host={{ inventory_hostname }}
#version=2c
#community=private
- cisco_snmp_portsecurity: host={{ inventory_hostname }} version=v3 community=private interface_name=FastEthernet0/2 portsecurity=enabled max=5
Error:
PLAYBOOK: test_snmp.yml ********************************************************
1 plays in test_snmp.yml
PLAY [all] *********************************************************************
META: ran handlers
TASK [cisco_snmp_portsecurity] *************************************************
task path: /tmp/certs/test_snmp.yml:12
fatal: [wayzataoclab729-swt.XXXX.com]: FAILED! => {"msg": "Unable to import cisco_snmp_portsecurity due to invalid syntax"}
Same Syntax error came when I tried to use interface module
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.