From 0f3a828190e4278cafaa72af098d87d90d874809 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Sun, 24 Aug 2014 16:01:32 +0300 Subject: Add ExtremeXOS --- CHANGELOG.md | 1 + README.md | 1 + lib/oxidized/model/xos.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 lib/oxidized/model/xos.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 0607845..9b52beb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # 0.2.4 - FEATURE: Cisco SMB (Nikola series VxWorks) model by @thetamind + - FEATURE: Extreme Networks XOS model (access by sjm) # 0.2.3 - BUGFIX: rescue @ssh.close when far end closes disgracefully (ALU ISAM) diff --git a/README.md b/README.md index 41f1bed..2acfec6 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ * Cisco IOS-XR * Cisco SMB (Nikola series) * DELL PowerConnect + * Extreme Networks XOS * Force10 FTOS * FortiGate FortiOS * HP ProCurve diff --git a/lib/oxidized/model/xos.rb b/lib/oxidized/model/xos.rb new file mode 100644 index 0000000..a8292ca --- /dev/null +++ b/lib/oxidized/model/xos.rb @@ -0,0 +1,40 @@ +class XOS < Oxidized::Model + + # Extreme Networks XOS + + prompt /^*?[\w .-]+# $/ + comment '# ' + + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].join.rstrip + end + + cmd 'show version' do |cfg| + comment cfg + end + + cmd 'show diagnostics' do |cfg| + comment cfg + end + + cmd 'show licenses' do |cfg| + comment cfg + end + + cmd 'show switch'do |cfg| + comment cfg.each_line.reject { |line| line.match /Time:/ or line.match /boot/i }.join + end + + cmd 'show configuration' + + cfg :telnet do + username /^login:/ + password /^passowrd:/ + end + + cfg :telnet, :ssh do + post_login 'disable clipaging' + pre_logout 'exit' + end + +end -- cgit v1.2.1 From 5662795ca35444a3e48eea3c2d8020d63502da84 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Sun, 24 Aug 2014 16:25:30 +0300 Subject: Add Brocade NOS --- CHANGELOG.md | 5 +++-- README.md | 1 + lib/oxidized/model/nos.rb | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 lib/oxidized/model/nos.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b52beb..4660af5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 0.2.4 - - FEATURE: Cisco SMB (Nikola series VxWorks) model by @thetamind - - FEATURE: Extreme Networks XOS model (access by sjm) +- FEATURE: Cisco SMB (Nikola series VxWorks) model by @thetamind +- FEATURE: Extreme Networks XOS model (access by sjm) +- FEATURE: Brocade NOS (Network Operating System) (access by sjm) # 0.2.3 - BUGFIX: rescue @ssh.close when far end closes disgracefully (ALU ISAM) diff --git a/README.md b/README.md index 2acfec6..e4f2629 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ * Arista EOS * Brocade Fabric OS * Brocade Ironware + * Brocade NOS (Network Operating System) * Brocade Vyatta * Cisco AireOS * Cisco ASA diff --git a/lib/oxidized/model/nos.rb b/lib/oxidized/model/nos.rb new file mode 100644 index 0000000..c2f4319 --- /dev/null +++ b/lib/oxidized/model/nos.rb @@ -0,0 +1,45 @@ +class NOS < Oxidized::Model + + # Brocade Network Operating System + + prompt /^(?:\e\[..h)?[\w.-]+# $/ + comment '! ' + + cmd :all do |cfg| + cfg.each_line.to_a[1..-2].join + end + + cmd 'show version' do |cfg| + comment cfg + end + + cmd 'show inventory' do |cfg| + comment cfg + end + + cmd 'show license' do |cfg| + comment cfg + end + + cmd 'show chassis' do |cfg| + comment cfg.each_line.reject { |line| line.match /Time/ }.join + end + + cfg 'show system' do |cfg| + commen cfg.each_line.reject { |line| line.match /Time/ or line.match /speed/ } + end + + cmd 'show running-config' + + cfg :telnet do + username /^.* login: / + username /^Password:/ + end + + cfg :telnet, :ssh do + post_login 'terminal length 0' + #post_login 'terminal width 0' + pre_logout 'exit' + end + +end -- cgit v1.2.1 From cae7076eeed2b3b5fcfecffde17bcb85d8013af2 Mon Sep 17 00:00:00 2001 From: Jari Salo Date: Mon, 25 Aug 2014 16:54:35 +0300 Subject: Match IP address explicitly - New method node_want? - Don't match node to node[:name] if node[:name] is an ip address. Otherwise we might match to wrong ip address. --- CHANGELOG.md | 1 + lib/oxidized/nodes.rb | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4660af5..d6eb83a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - FEATURE: Cisco SMB (Nikola series VxWorks) model by @thetamind - FEATURE: Extreme Networks XOS model (access by sjm) - FEATURE: Brocade NOS (Network Operating System) (access by sjm) +- BUGFIX: Match exactly to node[:name] if node[name] is an ip address. # 0.2.3 - BUGFIX: rescue @ssh.close when far end closes disgracefully (ALU ISAM) diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index 6f30af4..227f656 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -9,16 +9,11 @@ module Oxidized def load node_want=nil with_lock do new = [] - node_want_ip = (IPAddr.new(node_want) rescue false) if node_want @source = CFG.source.default Oxidized.mgr.add_source @source Oxidized.mgr.source[@source].new.load.each do |node| - # we want to load specific node(s), not all of them - if node_want - next unless node_want_ip == node[:ip] or node_want.match(node[:name]) - end - + next unless node_want? node_want, node begin _node = Node.new node new.push _node @@ -33,6 +28,19 @@ module Oxidized end end + def node_want? node_want, node + node_want_ip = (IPAddr.new(node_want) rescue false) + name_is_ip = (IPAddr.new(node[:name]) rescue false) + if name_is_ip and node_want_ip == node[:name] + true + elsif node[:ip] and node_want_ip == node[:ip] + true + elsif node_want.match node[:name] + true unless name_is_ip + end + end + + def list with_lock do map { |e| e.serialize } -- cgit v1.2.1 From 3a24cc5ba5af14bff128c512a039abbfe5266bfa Mon Sep 17 00:00:00 2001 From: Jari Salo Date: Mon, 25 Aug 2014 18:54:45 +0300 Subject: Return true if node_want is nil - Otherwise all nodes can not be loaded. --- lib/oxidized/nodes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index 227f656..032118d 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -29,6 +29,7 @@ module Oxidized end def node_want? node_want, node + return true unless node_want node_want_ip = (IPAddr.new(node_want) rescue false) name_is_ip = (IPAddr.new(node[:name]) rescue false) if name_is_ip and node_want_ip == node[:name] -- cgit v1.2.1 From 4eb1eb2cf9ae0701b6d51a1601b4049e825791d8 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Sat, 30 Aug 2014 11:42:45 +0300 Subject: Remove ntp clock-period completely emj complained that it sometimes pops in, sometimes pops out. I guess really no point having it there. --- lib/oxidized/model/ios.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb index d2b4996..6fa3c5c 100644 --- a/lib/oxidized/model/ios.rb +++ b/lib/oxidized/model/ios.rb @@ -37,9 +37,9 @@ class IOS < Oxidized::Model end cmd 'show running-config' do |cfg| - cfg = cfg.each_line.to_a[3..-1].join + cfg = cfg.each_line.to_a[3..-1] + cfg = cfg.reject { |line| line.match /^ntp clock-period / }.join cfg.gsub! /^Current configuration : [^\n]*\n/, '' - cfg.sub! /^(ntp clock-period).*/, '! \1' cfg.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]*\n*( (?:\ [^\n]*\n*)* tunnel\ mpls\ traffic-eng\ auto-bw)/mx, '\1' -- cgit v1.2.1 From 2914f792870c9bf5c5b09d41e0f64d86f15403fb Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 22 Sep 2014 22:08:12 +0200 Subject: Fixed small bug in powerconnect enable code --- lib/oxidized/model/powerconnect.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb index 1d0352e..8c677b3 100644 --- a/lib/oxidized/model/powerconnect.rb +++ b/lib/oxidized/model/powerconnect.rb @@ -31,8 +31,10 @@ class PowerConnect < Oxidized::Model cfg :telnet, :ssh do if vars :enable - send "enable\n" - send vars(:enable) + "\n" + post_login do + send "enable\n" + send vars(:enable) + "\n" + end end post_login "terminal length 0" -- cgit v1.2.1 From 4a57251c79719a1bedbfe73d8cb5171ff48285cd Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 22 Sep 2014 22:08:53 +0200 Subject: Added model for cisco NXOS --- lib/oxidized/model/nxos.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/oxidized/model/nxos.rb diff --git a/lib/oxidized/model/nxos.rb b/lib/oxidized/model/nxos.rb new file mode 100644 index 0000000..6163724 --- /dev/null +++ b/lib/oxidized/model/nxos.rb @@ -0,0 +1,23 @@ +class NXOS < Oxidized::Model + + prompt /^(\r?[\w.@_()-]+[#]\s?)$/ + comment '! ' + + cmd 'show version' do |cfg| + cfg = cfg.each_line.take_while { |line| not line.match(/uptime/i) } + comment cfg.join "" + end + + cmd 'show inventory' do |cfg| + comment cfg + end + + cmd 'show running-config' do |cfg| + cfg.gsub! /^!Time:[^\n]*\n/, '' + end + + cfg :ssh do + post_login 'terminal length 0' + pre_logout 'exit' + end +end -- cgit v1.2.1 From 49b7ec647b3050d35e8162afb63c7c43333f0ee5 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 26 Sep 2014 09:51:29 +0200 Subject: Removed ever-changing output from powerconnect model, thanks @artmann --- lib/oxidized/model/powerconnect.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb index 8c677b3..6a743db 100644 --- a/lib/oxidized/model/powerconnect.rb +++ b/lib/oxidized/model/powerconnect.rb @@ -18,8 +18,9 @@ class PowerConnect < Oxidized::Model end cmd 'show system' do |cfg| - cfg = cfg.each_line.take_while { |line| not line.match(/uptime/i) } - comment cfg.join "\n" + cfg = cfg.split("\n").select { |line| not line[/Up Time/] } + cfg = cfg[0..-28]<<" " + comment cfg.join("\n") end cmd 'show running-config' -- cgit v1.2.1 From 5bc5aa28a205c300e80956a257372bc2a6fcf6a7 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 2 Oct 2014 11:50:30 +0200 Subject: Fixed more ever changing output in powerconnect model, only shows up on some firmware versions --- lib/oxidized/model/powerconnect.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb index 6a743db..a1fe229 100644 --- a/lib/oxidized/model/powerconnect.rb +++ b/lib/oxidized/model/powerconnect.rb @@ -14,11 +14,12 @@ class PowerConnect < Oxidized::Model end cmd 'show version' do |cfg| - comment cfg + cfg = cfg.split("\n").select { |line| not line[/Up\sTime/] } + comment cfg.join("\n") + "\n" end cmd 'show system' do |cfg| - cfg = cfg.split("\n").select { |line| not line[/Up Time/] } + cfg = cfg.split("\n").select { |line| not line[/Up\sTime/] } cfg = cfg[0..-28]<<" " comment cfg.join("\n") end -- cgit v1.2.1 From 79cd46115a964568b231180218f58b522b430f6a Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 2 Oct 2014 20:46:45 +0200 Subject: Added Cisco NXOS to the list of supported platforms --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e4f2629..ba342b2 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ * Cisco ASA * Cisco IOS * Cisco IOS-XR + * Cisco NXOS * Cisco SMB (Nikola series) * DELL PowerConnect * Extreme Networks XOS -- cgit v1.2.1 From c90bd50b6b40870d78c77d43b447e3c7c9170a2e Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Wed, 22 Oct 2014 22:17:37 +0200 Subject: Overhauling project README.md Cleaning up documentation and adding new Cookbook examples. --- README.md | 237 +++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 156 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index ba342b2..1ab1ad3 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,35 @@ -# Pitch - * automatically adds/removes threads to meet configured retrieval interval - * restful API to move node immediately to head-of-queue (GET/POST /node/next/[NODE]) - * syslog udp+file example to catch config change event (ios/junos) and trigger config fetch - * will signal ios/junos user who made change, which output module can (git does) use (via POST) - * 'git blame' will show for each line who and when the change was made - * restful API to reload list of nodes (GET /reload) - * restful API to fetch configurations (/node/fetch/[NODE] or /node/fetch/group/[NODE]) - * restful API to show list of nodes (GET /nodes) +# Oxidized + +Oxidized is a network device configration backup tool. Its a RANCID replcament! + +* automatically adds/removes threads to meet configured retrieval interval +* restful API to move node immediately to head-of-queue (GET/POST /node/next/[NODE]) + * syslog udp+file example to catch config change event (ios/junos) and trigger config fetch + * will signal ios/junos user who made change, which output module can (git does) use (via POST) + * 'git blame' will show for each line who and when the change was made +* restful API to reload list of nodes (GET /reload) +* restful API to fetch configurations (/node/fetch/[NODE] or /node/fetch/group/[NODE]) +* restful API to show list of nodes (GET /nodes) + +[Youtube Video: Oxidized TREX 2014 presentation](http://youtu.be/kBQ_CTUuqeU#t=3h) + +#### Index +1. [Supported OS Types](#supported-os-types) +2. [Installation](#installation) + * [Debian](#debian) + * [CentOS, Oracle Linux, Red Hat Linux version 6](#centos-oracle-linux-red-hat-linux-version 6) +3. [Initial Configuration](#configuration) +4. [Installing Ruby 2.1.2 using RVM](#installing-ruby-2.1.2-using-rvm) +5. [Cookbook](#cookbook) + * [Debugging](#debugging) + * [Privileged mode](#privileged-mode) + * [SQLite Example Configuration](#sqlite-example-configuration) + * [Default Configuration](#default-configuration) +6. [Ruby API](#ruby-api) + * [Input](#input) + * [Output](#output + * [Source](#source + * [Model](#model # Supported OS types @@ -37,84 +60,106 @@ * Juniper ScreenOS (Netscreen) * Ubiquiti AirOS -# Install - - * Debian - 1. apt-get install ruby ruby-dev libsqlite3-dev libssl-dev - 2. gem install oxidized - 3. gem install oxidized-script oxidized-web # if you don't install oxidized-web, make sure you remove "rest" from your config - 4. oxidized - 5. vi ~/.config/oxidized/config - 6. (maybe point to your rancid/router.db or copy it there) - 7. oxidized - - * CentOS, Oracle Linux, Red Hat Linux version 6 - 1. Install Ruby 1.9.3 or greater - * For Ruby 2.1.2 installation instructions see "Installing Ruby 2.1.2 using RVM" - 2. Install Oxidized dependencies - * yum install cmake sqlite-devel openssl-devel - 3. Install Oxidized daemon and Web front-end from Ruby Gems - * gem install oxidized - * gem install oxidized-script oxidized-web - 4. Start Oxidized, this will create initial configuration - * oxidized - 5. Edit Oxidized configuration and create device database - * vi ~/.config/oxidized/config - * vi ~/.config/oxidized/router.db - 6. If you are using file system storage create config directory - * mkdir -p ~/.config/oxidized/configs/default - 7. Start Oxidized - * oxidized - - * Installing Ruby 2.1.2 using RVM - 1. Install Ruby 2.1.2 build dependencies - * yum install curl gcc-c++ patch readline readline-devel zlib zlib-devel - * yum install libyaml-devel libffi-devel openssl-devel make cmake - * yum install bzip2 autoconf automake libtool bison iconv-devel - 2. Install RVM - * curl -L get.rvm.io | bash -s stable - 3. Setup RVM environment - * source /etc/profile.d/rvm.sh - 4. Compile and install Ruby 2.1.2 - * rvm install 2.1.2 - 5. Set Ruby 2.1.2 as default - * rvm use --default 2.1.2 - -# API -## Input - * gets config from nodes - * must implement 'connect', 'get', 'cmd' - * 'ssh' and 'telnet' implemented -## Output - * stores config - * must implement 'store' (may implement 'fetch') - * 'git' and 'file' (store as flat ascii) implemented +# Installation +## Debian +Install all required packages and gems. -## Source - * gets list of nodes to poll - * must implement 'load' - * source can have 'name', 'model', 'group', 'username', 'password', 'input', 'output', 'prompt' - * name - name of the devices - * model - model to use ios/junos/xyz, model is loaded dynamically when needed (Also default in config file) - * input - method to acquire config, loaded dynamically as needed (Also default in config file) - * output - method to store config, loaded dynamically as needed (Also default in config file) - * prompt - prompt used for node (Also default in config file, can be specified in model too) - * 'sql' and 'csv' (supports any format with single entry per line, like router.db) +``` +apt-get install ruby ruby-dev libsqlite3-dev libssl-dev +gem install oxidized +gem install oxidized-script oxidized-web # if you don't install oxidized-web, make sure you remove "rest" from your config +``` -## Model - * lists commands to gather from given device model - * can use 'cmd', 'prompt', 'comment', 'cfg' - * cfg is executed in input/output/source context - * cmd is executed in instance of model - * 'junos', 'ios', 'ironware' and 'powerconnect' implemented +## CentOS, Oracle Linux, Red Hat Linux version 6 +Install Ruby 1.9.3 or greater (for Ruby 2.1.2 installation instructions see "Installing Ruby 2.1.2 using RVM"), then install Oxidized dependencies +``` +yum install cmake sqlite-devel openssl-devel +``` + +Now lets install oxidized via Rubygems: +``` +gem install oxidized +gem install oxidized-script oxidized-web +``` + +# Configuration + +To initialize an empty configuration file, simply run ```oxidized``` once to create a config in you home directory ```~/.config/oxidized/config```. The configuration file is in YAML format. + +Lets tell Oxidized where it finds a list of network devices to backup configuration from. You can either use CSV or SQLite as source. To create a CVS source add the following snippet: + +``` +source: + default: csv + csv: + file: ~/.config/oxidized/router.db + delimiter: !ruby/regexp /:/ + map: + name: 0 + model: 1 + username: 2 + password: 3 +``` + +Now lets create a file based device database (you might want to switch to sqlite later on). Put your routers in ```~/.config/oxidized/router.db``` (file format is compatible with rancid). Simply add a item per line: + +``` +router01.example.com:ios +switch01.example.com:procurve +router02.example.com:ios:admin:S3cre37x +``` + +Run ```oxidized``` again to take the first backups. + +# Installing Ruby 2.1.2 using RVM + +Install Ruby 2.1.2 build dependencies +``` +yum install curl gcc-c++ patch readline readline-devel zlib zlib-devel +yum install libyaml-devel libffi-devel openssl-devel make cmake +yum install bzip2 autoconf automake libtool bison iconv-devel +``` + +Install RVM +``` +curl -L get.rvm.io | bash -s stable +``` + +Setup RVM environment and compile and install Ruby 2.1.2 and set it as default +``` +source /etc/profile.d/rvm.sh +rvm install 2.1.2 +rvm use --default 2.1.2 +``` -## Media - * TREX 2014 presentation - http://youtu.be/kBQ_CTUuqeU#t=3h ## Cookbook +### Debugging +In case a plugin doesn't work correctly, you can enable live debugging of SSH/Telnet sessions. Just add the ```debug``` option, specifying a log file destination to the ```input``` section. + +The following example will log an active ssh session to ```/home/fisakytt/.config/oxidized/log_input-ssh``` and telnet to ```log_input-telnet```. The file will be truncated with each newly created session, so you need to put a ```tailf``` or ```tail -f``` on that file. + +``` +input: + default: ssh, telnet + debug: ~/.config/oxidized/log_input + ssh: + secure: false +``` + +### Privileged mode + +To put your routers in privileged mode, Oxidized needs to send the enable command. You can globally enable this, +by adding the following snippet to the global configuration file. -### Configuration I use in one environment +``` +--- +vars: + enable: S3cre7 +``` + +### SQLite Example Configuration ``` --- username: LANA @@ -136,7 +181,7 @@ source: model: model ``` -### Configuration you end up after first run +### Default Configuration If you don't configure output and source, it'll further fill them with example configs for your chosen output/source in subsequent runs ``` @@ -193,3 +238,33 @@ System wide configurations can be stored in /etc/oxidized/config, this might be useful for storing for example source information, if many users are using oxs/Oxidized::Script, which would allow user specific config only to include username+password. + +# Ruby API + +## Input + * gets config from nodes + * must implement 'connect', 'get', 'cmd' + * 'ssh' and 'telnet' implemented + +## Output + * stores config + * must implement 'store' (may implement 'fetch') + * 'git' and 'file' (store as flat ascii) implemented + +## Source + * gets list of nodes to poll + * must implement 'load' + * source can have 'name', 'model', 'group', 'username', 'password', 'input', 'output', 'prompt' + * name - name of the devices + * model - model to use ios/junos/xyz, model is loaded dynamically when needed (Also default in config file) + * input - method to acquire config, loaded dynamically as needed (Also default in config file) + * output - method to store config, loaded dynamically as needed (Also default in config file) + * prompt - prompt used for node (Also default in config file, can be specified in model too) + * 'sql' and 'csv' (supports any format with single entry per line, like router.db) + +## Model + * lists commands to gather from given device model + * can use 'cmd', 'prompt', 'comment', 'cfg' + * cfg is executed in input/output/source context + * cmd is executed in instance of model + * 'junos', 'ios', 'ironware' and 'powerconnect' implemented -- cgit v1.2.1 From 444ed4ddbf3a0dd3796d402f5ee27989d98dbd56 Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Wed, 22 Oct 2014 22:19:01 +0200 Subject: Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1ab1ad3..c06ca0f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Oxidized -Oxidized is a network device configration backup tool. Its a RANCID replcament! +Oxidized is a network device configration backup tool. Its a RANCID replacment! * automatically adds/removes threads to meet configured retrieval interval * restful API to move node immediately to head-of-queue (GET/POST /node/next/[NODE]) @@ -27,9 +27,9 @@ Oxidized is a network device configration backup tool. Its a RANCID replcament! * [Default Configuration](#default-configuration) 6. [Ruby API](#ruby-api) * [Input](#input) - * [Output](#output - * [Source](#source - * [Model](#model + * [Output](#output) + * [Source](#source) + * [Model](#model) # Supported OS types -- cgit v1.2.1 From 6b28ac0667b1f1a84353e0d3ac5f10462d87a98c Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Wed, 22 Oct 2014 22:24:13 +0200 Subject: Update README.md --- README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c06ca0f..47a7879 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,11 @@ gem install oxidized-script oxidized-web To initialize an empty configuration file, simply run ```oxidized``` once to create a config in you home directory ```~/.config/oxidized/config```. The configuration file is in YAML format. +Create the directory where the ```output``` is going to store configurations: +``` +mkdir ~/.config/oxidized/configs +``` + Lets tell Oxidized where it finds a list of network devices to backup configuration from. You can either use CSV or SQLite as source. To create a CVS source add the following snippet: ``` @@ -182,27 +187,30 @@ source: ``` ### Default Configuration -If you don't configure output and source, it'll further fill them with example -configs for your chosen output/source in subsequent runs +If you don't configure output and source, it'll further fill them with example configs for your chosen output/source in subsequent runs. + ``` --- username: username password: password model: junos interval: 3600 -log: "/home/fisakytt/.config/oxidized/log" +log: ~/.config/oxidized/log debug: false threads: 30 -timeout: 30 +timeout: 20 +retries: 3 prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/ rest: 127.0.0.1:8888 vars: {} +groups: {} input: default: ssh, telnet + debug: false ssh: secure: false output: - default: git + default: file source: default: csv model_map: @@ -217,11 +225,11 @@ output: git: user: Oxidized email: o@example.com - repo: "/home/fisakytt/.config/oxidized/oxidized.git" + repo: "~/.config/oxidized/oxidized.git" source: default: csv csv: - file: "/home/fisakytt/.config/oxidized/router.db" + file: "~/.config/oxidized/router.db" delimiter: !ruby/regexp /:/ map: name: 0 -- cgit v1.2.1 From b8e24bceb9ea0145d18a77b3c97bbec5402c5806 Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Wed, 22 Oct 2014 23:14:11 +0200 Subject: Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 47a7879..14bbd2e 100644 --- a/README.md +++ b/README.md @@ -201,9 +201,9 @@ threads: 30 timeout: 20 retries: 3 prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/ -rest: 127.0.0.1:8888 vars: {} groups: {} +rest: 127.0.0.1:8888 input: default: ssh, telnet debug: false @@ -213,6 +213,12 @@ output: default: file source: default: csv + csv: + file: ~/.config/oxidized/router.db + delimiter: !ruby/regexp /:/ + map: + name: 0 + model: 1 model_map: cisco: ios juniper: junos -- cgit v1.2.1 From 20611365cb166d8b2558c56f21da138c0ebb6def Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Thu, 23 Oct 2014 00:01:38 +0200 Subject: Update README.md --- README.md | 151 ++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 89 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 14bbd2e..f1ca7fc 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Oxidized is a network device configration backup tool. Its a RANCID replacment! ## Debian Install all required packages and gems. -``` +```shell apt-get install ruby ruby-dev libsqlite3-dev libssl-dev gem install oxidized gem install oxidized-script oxidized-web # if you don't install oxidized-web, make sure you remove "rest" from your config @@ -73,26 +73,39 @@ gem install oxidized-script oxidized-web # if you don't install oxidized-web, ma ## CentOS, Oracle Linux, Red Hat Linux version 6 Install Ruby 1.9.3 or greater (for Ruby 2.1.2 installation instructions see "Installing Ruby 2.1.2 using RVM"), then install Oxidized dependencies -``` +```shell yum install cmake sqlite-devel openssl-devel ``` Now lets install oxidized via Rubygems: -``` +```shell gem install oxidized gem install oxidized-script oxidized-web ``` # Configuration -To initialize an empty configuration file, simply run ```oxidized``` once to create a config in you home directory ```~/.config/oxidized/config```. The configuration file is in YAML format. +Oxidized configuration is in YAML format. Configuration files are subsequently sourced from ```/etc/oxidized/config``` then ```~/.config/oxidized/config```. The hashes will be merged, this might be useful for storing source information in a system wide file and user specific configuration in the home directory (to only include a staff specific username and password). Eg. if many users are using ```oxs```, see [Oxidized::Script](https://github.com/ytti/oxidized-script). + +To initialize a default configuration in your home directory ```~/.config/oxidized/config```, simply run ```oxidized``` once. If you don't further configure anything from the output and source sections, it'll extend the examples on a subsequent ```oxidized``` execution. This is useful to see what options for a specific input or output backend are available. + +## Inputs + +Oxidized supports CSV and SQLite as input backends. The CSV backend reads nodes from a rancid compatible router.db file. The SQLite backend will fire queries against a database and map certain fields to model items. + +## Outputs + +Possible outputs are either ```file``` or ```git```. The file backend takes a destination directory as argument and will keep a file per device, with most recent running version of a device. The GIT backend (recommended) will initialize an empty GIT repository in the specified path and create a new commit on every configuration change. + +Maps define how to map a model's fields to model [model fields](https://github.com/ytti/oxidized/tree/master/lib/oxidized/model). Most of the settings should be self explanatory, log is ignored if Syslog::Logger exists (>=2.0) and syslog is used instead. -Create the directory where the ```output``` is going to store configurations: +First create the directory where the CSV ```output``` is going to store device configs and start Oxidized once. ``` mkdir ~/.config/oxidized/configs +oxidized ``` -Lets tell Oxidized where it finds a list of network devices to backup configuration from. You can either use CSV or SQLite as source. To create a CVS source add the following snippet: +Now tell Oxidized where it finds a list of network devices to backup configuration from. You can either use CSV or SQLite as source. To create a CVS source add the following snippet: ``` source: @@ -103,16 +116,14 @@ source: map: name: 0 model: 1 - username: 2 - password: 3 ``` -Now lets create a file based device database (you might want to switch to sqlite later on). Put your routers in ```~/.config/oxidized/router.db``` (file format is compatible with rancid). Simply add a item per line: +Now lets create a file based device database (you might want to switch to SQLite later on). Put your routers in ```~/.config/oxidized/router.db``` (file format is compatible with rancid). Simply add an item per line: ``` router01.example.com:ios switch01.example.com:procurve -router02.example.com:ios:admin:S3cre37x +router02.example.com:ios ``` Run ```oxidized``` again to take the first backups. @@ -141,9 +152,9 @@ rvm use --default 2.1.2 ## Cookbook ### Debugging -In case a plugin doesn't work correctly, you can enable live debugging of SSH/Telnet sessions. Just add the ```debug``` option, specifying a log file destination to the ```input``` section. +In case a model plugin doesn't work correctly (ios, procurve, etc.), you can enable live debugging of SSH/Telnet sessions. Just add a ```debug``` option, specifying a log file destination to the ```input``` section. -The following example will log an active ssh session to ```/home/fisakytt/.config/oxidized/log_input-ssh``` and telnet to ```log_input-telnet```. The file will be truncated with each newly created session, so you need to put a ```tailf``` or ```tail -f``` on that file. +The following example will log an active ssh session to ```/home/fisakytt/.config/oxidized/log_input-ssh``` and telnet to ```log_input-telnet```. The file will be truncated on each consecutive ssh/telnet session, so you need to put a ```tailf``` or ```tail -f``` on that file! ``` input: @@ -155,44 +166,78 @@ input: ### Privileged mode -To put your routers in privileged mode, Oxidized needs to send the enable command. You can globally enable this, -by adding the following snippet to the global configuration file. +To start privileged mode before pulling the configuration, Oxidized needs to send the enable command. You can globally enable this, by adding the following snippet to the global section of the configuration file. ``` ---- vars: enable: S3cre7 ``` -### SQLite Example Configuration +### Source: CSV + +One line per device, colon seperated. + +``` +source: + default: csv + csv: + file: /var/lib/oxidized/router.db + delimiter: !ruby/regexp /:/ + map: + name: 0 + model: 1 + username: 2 + enable: 3 +``` + +### Source: SQLite + +One row per device, filtered by hostname. + ``` ---- -username: LANA -password: LANAAAAAAA -output: - default: git - git: - user: Oxidized - email: o@example.com - repo: "/usr/local/lan/oxidized.git" source: default: sql sql: adapter: sqlite - database: "/usr/local/lan/corona.db" - table: device + database: "/var/lib/oxidized/devices.db" + table: devices map: - name: ptr + name: fqdn model: model + username: username + password: password + enable: enable ``` -### Default Configuration -If you don't configure output and source, it'll further fill them with example configs for your chosen output/source in subsequent runs. +### Output: CSV + +Parent directory needs to be created manually, one file per device, with most recent running config. + +``` +output: + file: + directory: /var/lib/oxidized/configs +``` + +### Output: Git + +``` +output: + default: git + git: + user: Oxidized + email: o@example.com + repo: "/var/lib/oxidized/devices.git" +``` + +### Advanced Configuration + +Below is an advanced example configuration. You will be able to (optinally) override options per device. The router.db format used is ```hostname:model:username:password:enable_password```. Hostname and model will be the only required options, all others override the global configuration sections. ``` --- -username: username -password: password +username: oxidized +password: S3cr3tx model: junos interval: 3600 log: ~/.config/oxidized/log @@ -201,7 +246,8 @@ threads: 30 timeout: 20 retries: 3 prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/ -vars: {} +vars: + enable: S3cr3tx groups: {} rest: 127.0.0.1:8888 input: @@ -210,7 +256,11 @@ input: ssh: secure: false output: - default: file + default: git + git: + user: Oxidized + email: oxidized@example.com + repo: "~/.config/oxidized/oxidized.git" source: default: csv csv: @@ -219,42 +269,19 @@ source: map: name: 0 model: 1 + username: 2 + password: 3 + enable: 4 model_map: cisco: ios juniper: junos ``` -Output and Source could be: -``` -output: - default: git - git: - user: Oxidized - email: o@example.com - repo: "~/.config/oxidized/oxidized.git" -source: - default: csv - csv: - file: "~/.config/oxidized/router.db" - delimiter: !ruby/regexp /:/ - map: - name: 0 - model: 1 -``` -which reads nodes from rancid compatible router.db maps their model names to -model names oxidized expects, stores config in git, will try ssh first then -telnet, wont crash on changed ssh keys. - -Hopefully most of them are obvious, log is ignored if Syslog::Logger exists -(>=2.0) and syslog is used instead. - -System wide configurations can be stored in /etc/oxidized/config, this might be -useful for storing for example source information, if many users are using -oxs/Oxidized::Script, which would allow user specific config only to include -username+password. # Ruby API +The following objects exist in Oxidized. + ## Input * gets config from nodes * must implement 'connect', 'get', 'cmd' -- cgit v1.2.1 From d10c7bf47bca7019371a4bc512c9a16651997987 Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Thu, 23 Oct 2014 00:03:50 +0200 Subject: Update README.md --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f1ca7fc..a4450f6 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,11 @@ Oxidized is a network device configration backup tool. Its a RANCID replacment! 5. [Cookbook](#cookbook) * [Debugging](#debugging) * [Privileged mode](#privileged-mode) - * [SQLite Example Configuration](#sqlite-example-configuration) - * [Default Configuration](#default-configuration) + * [Source: CSV](#source-csv) + * [Source: SQLite](#source-sqlite) + * [Output: GIT](#output-git) + * [Output: File](#output-file) + * [Advanced Configuration](#advanced-configuration) 6. [Ruby API](#ruby-api) * [Input](#input) * [Output](#output) @@ -209,7 +212,7 @@ source: enable: enable ``` -### Output: CSV +### Output: File Parent directory needs to be created manually, one file per device, with most recent running config. -- cgit v1.2.1 From a95a77ddda611ca77c67f43d7ff535b885e1aac6 Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Thu, 23 Oct 2014 00:07:05 +0200 Subject: Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a4450f6..e3a8e57 100644 --- a/README.md +++ b/README.md @@ -90,15 +90,15 @@ gem install oxidized-script oxidized-web Oxidized configuration is in YAML format. Configuration files are subsequently sourced from ```/etc/oxidized/config``` then ```~/.config/oxidized/config```. The hashes will be merged, this might be useful for storing source information in a system wide file and user specific configuration in the home directory (to only include a staff specific username and password). Eg. if many users are using ```oxs```, see [Oxidized::Script](https://github.com/ytti/oxidized-script). -To initialize a default configuration in your home directory ```~/.config/oxidized/config```, simply run ```oxidized``` once. If you don't further configure anything from the output and source sections, it'll extend the examples on a subsequent ```oxidized``` execution. This is useful to see what options for a specific input or output backend are available. +To initialize a default configuration in your home directory ```~/.config/oxidized/config```, simply run ```oxidized``` once. If you don't further configure anything from the output and source sections, it'll extend the examples on a subsequent ```oxidized``` execution. This is useful to see what options for a specific source or output backend are available. -## Inputs +## Source -Oxidized supports CSV and SQLite as input backends. The CSV backend reads nodes from a rancid compatible router.db file. The SQLite backend will fire queries against a database and map certain fields to model items. +Oxidized supports ```CSV``` and ```SQLite``` as source backends. The CSV backend reads nodes from a rancid compatible router.db file. The SQLite backend will fire queries against a database and map certain fields to model items. Take a look at the [Cookbook](#cookbook) for more details. ## Outputs -Possible outputs are either ```file``` or ```git```. The file backend takes a destination directory as argument and will keep a file per device, with most recent running version of a device. The GIT backend (recommended) will initialize an empty GIT repository in the specified path and create a new commit on every configuration change. +Possible outputs are either ```file``` or ```git```. The file backend takes a destination directory as argument and will keep a file per device, with most recent running version of a device. The GIT backend (recommended) will initialize an empty GIT repository in the specified path and create a new commit on every configuration change. Take a look at the [Cookbook](#cookbook) for more details. Maps define how to map a model's fields to model [model fields](https://github.com/ytti/oxidized/tree/master/lib/oxidized/model). Most of the settings should be self explanatory, log is ignored if Syslog::Logger exists (>=2.0) and syslog is used instead. -- cgit v1.2.1 From 62fd9283eee5a339bf8e4ed04957e8b6fbafca1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Veli-Matti=20Lepp=C3=A4nen?= Date: Thu, 23 Oct 2014 18:32:41 +0300 Subject: better dependencies --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e3a8e57..ddea527 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,8 @@ Oxidized is a network device configration backup tool. Its a RANCID replacment! Install all required packages and gems. ```shell -apt-get install ruby ruby-dev libsqlite3-dev libssl-dev +apt-get install ruby ruby-dev libsqlite3-dev libssl-dev pkg-config cmake +gem install rugged gem install oxidized gem install oxidized-script oxidized-web # if you don't install oxidized-web, make sure you remove "rest" from your config ``` -- cgit v1.2.1 From 34c4559c845bd6ba239bbf1013fcebbd8041e6c3 Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Thu, 23 Oct 2014 18:11:31 +0200 Subject: model/asa: fixing prompt - hostname regex taken from ios model --- lib/oxidized/model/asa.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb index 3ee4e2d..b2c3e01 100644 --- a/lib/oxidized/model/asa.rb +++ b/lib/oxidized/model/asa.rb @@ -3,7 +3,7 @@ class ASA < Oxidized::Model # Cisco ASA model # # Only SSH supported for the sake of security - prompt /^\r*([\w]+[#>]\s?)$/ + prompt /^\r*([\w.@()-]+[#>]\s?)$/ comment '! ' cmd :all do |cfg| -- cgit v1.2.1 From 764ebd865a8360057dea1b913cd41d6361e0a01f Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Thu, 23 Oct 2014 18:59:44 +0200 Subject: model/asa: removing >show clock and ignoring uptime in >show version --- lib/oxidized/model/asa.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb index b2c3e01..11db547 100644 --- a/lib/oxidized/model/asa.rb +++ b/lib/oxidized/model/asa.rb @@ -16,11 +16,10 @@ class ASA < Oxidized::Model cfg end - cmd 'show clock' do |cfg| - comment cfg - end - cmd 'show version' do |cfg| + # avoid commits due to uptime / ixo-router01 up 2 mins 28 secs / ixo-router01 up 1 days 2 hours + cfg = cfg.each_line.select { |line| not line.match /\s+up\s+\d+\s+/ } + cfg = cfg.join comment cfg end -- cgit v1.2.1 From c59b4b5c0605f5f09721bc04d48c1894dfc7694d Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Mon, 27 Oct 2014 17:26:40 +0100 Subject: model/asa: ASA prompt contains HA Failover state separated by slashes --- lib/oxidized/model/asa.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb index 11db547..8335b1d 100644 --- a/lib/oxidized/model/asa.rb +++ b/lib/oxidized/model/asa.rb @@ -3,7 +3,7 @@ class ASA < Oxidized::Model # Cisco ASA model # # Only SSH supported for the sake of security - prompt /^\r*([\w.@()-]+[#>]\s?)$/ + prompt /^\r*([\w.@()-\/]+[#>]\s?)$/ comment '! ' cmd :all do |cfg| -- cgit v1.2.1 From 418c90bb10a650d717e9e63a674ea31f7aa6bd4e Mon Sep 17 00:00:00 2001 From: Stefan Schlesinger Date: Mon, 27 Oct 2014 19:27:03 +0100 Subject: docs: enable mapping update --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ddea527..5c4ea0c 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,9 @@ source: name: 0 model: 1 username: 2 - enable: 3 + password: 3 + var_map: + enable: 4 ``` ### Source: SQLite @@ -210,6 +212,7 @@ source: model: model username: username password: password + var_map: enable: enable ``` @@ -275,6 +278,7 @@ source: model: 1 username: 2 password: 3 + var_map: enable: 4 model_map: cisco: ios -- cgit v1.2.1