Oxidized

From HackerNet
Jump to: navigation, search

Oxidized är ett backup tool för nätverk devices. Alltså en ersättare till Rancid.

Supportade OS

  • A0 Networks
    • ACOS
  • Alcatel-Lucent
    • AOS
    • AOS7
    • ISAM
    • TiMOS
    • Wireless
  • Arista
    • EOS
  • Arris
    • C4CMTS
  • Aruba
    • AOSW
  • Brocade
    • FabricOS
    • Ironware
    • NOS (Network Operating System)
    • Vyatta
  • Ciena
    • SOAS
  • Cisco
    • AireOS
    • ASA
    • IOS
    • IOSXR
    • NXOS
    • SMB (Nikola series)
  • Citrix
    • NetScaler (Virtual Applicance)
  • Cumulus
    • Linux
  • DataCom
    • DmSwitch 3000
  • DELL
    • PowerConnect
    • AOSW
  • Ericsson/Redback
    • IPOS (former SEOS)
  • Extreme Networks
    • XOS
    • WM
  • F5
    • TMOS
  • Force0
    • DNOS
    • FTOS
  • FortiGate
    • FortiOS
  • HP
    • Comware (HP A-series, H3C, 3Com)
    • Procurve
  • Huawei
    • VRP
  • Juniper
    • JunOS
    • ScreenOS (Netscreen)
  • Mikrotik
    • RouterOS
  • Motorola
    • RFS
  • MRV
    • MasterOS
  • Netonix
    • WISP Switch (As Netonix)
  • Opengear
    • Opengear
  • Palo Alto
    • PANOS
  • Supermicro
    • Supermicro
  • Ubiquiti
    • AirOS
    • Edgeos
    • EdgeSwitch
  • Zyxel
    • ZyNOS

Installation

requires Ruby version >= 2.0

Skapa Oxidized användaren

useradd -d /opt/oxidized oxidized

Installera EPEL och SCL

yum install epel-release centos-release-scl-rh centos-release-scl

Installera Ruby samt extra paket för att kompilera Oxidized.

yum install make cmake which sqlite-devel openssl-devel libssh2-devel gcc libicu-devel gcc-c++ rh-ruby26-ruby-devel rh-ruby26-ruby git python-ldap

Installera Oxidized

scl enable rh-ruby26 bash
gem install oxidized
gem install oxidized-script oxidized-web

Skapa en systemd fil åt Oxidized.

#For debian 8 put it in /lib/systemd/system/
#To set OXIDIZED_HOME instead of the default:
# ~${oxidized_user}/.config/oxidized in debian 8, then uncomment
#(and modify as required) the "Environment" variable below so
#systemd sets the correct environment. Tested only on Debian 8.8.
#YMMV otherwise.
#
#For RHEL / CentOS 7 put it in /etc/systemd/system/
#and call it with systemctl start oxidized.service
 
[Unit]
Description=Oxidized - Network Device Configuration Backup Tool
After=network-online.target multi-user.target
Wants=network-online.target
 
[Service]
ExecStart=/bin/scl enable rh-ruby26 /opt/rh/rh-ruby26/root/usr/local/bin/oxidized
User=oxidized
KillSignal=SIGKILL
Restart=always
RestartSec=20
#Environment="OXIDIZED_HOME=/etc/oxidized"
 
[Install]
WantedBy=multi-user.target
sudo add-apt-repository universe
sudo apt-get -y install ruby ruby-dev libsqlite3-dev libssl-dev pkg-config cmake libssh2-1-dev libicu-dev zlib1g-dev g++
sudo gem install oxidized
sudo gem install oxidized-script oxidized-web

Konfiguration

Konfigurationen är på YAML-format. Default-konf finns i: /etc/oxidized/config och sedan används~/.config/oxidized/config

För att initiera oxidized i ditt home directory kör:

mkdir -p ~/.config/oxidized
oxidized
nano ~/.config/oxidized/config

Man kan ändra var man vill att oxidized ska lägga sig genom att ändra environment variable

OXIDIZED_HOME=/etc/oxidized

Logging

log: "/home/$USER/.config/oxidized/oxidized.log"

Input

Input hämtar konfiguration från enheterna.

input:
  default: ssh, telnet
  debug: false
  ssh:
    secure: false

Source

Source läser vilka enheter som ska konfigbackas. Oxidized har stöd för CSV, SQLite och HTTP som source backends.

CSV backend läser vilka enheter som det ska tas backup på från en rancid-kompatibel fil.

source:
  default: csv
  csv:
    file: "/home/$USER/.config/oxidized/router.db"
    delimiter: !ruby/regexp /:/
    map:
      name: 0
      model: 1
      username: 2
      password: 3
    vars_map:
      enable: 4

router.db
Format: 0:1:2:3:4

router01.example.com:ios:user:pw:enablepw
172.20.0.1:ios:user:pw:enablepw

Output

Output lagrar konfigurationen. Man måste köra git för att få versionshantering på konfig-filerna.

output:
  default: file
  file:
    directory: "/home/$USER/.config/oxidized/configs"

GIT

output:
  default: git
  git:
      user: Oxidized
      email: oxidized@example.com
      repo: "/home/$USER/.config/oxidized/oxidized.git"

Exceptions
Man kan lägga in egna undantag för rader som ej borde vara med i konfigen, t.ex. rader med tidsstämplar som ändras ofta.

Exempel IOS, edit /var/lib/gems/2.3.0/gems/oxidized-0.21.0/lib/oxidized/model/ios.rb

  cmd 'show running-config' do |cfg|
    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.gsub! /^! Last configuration change at [^\n]*\n/, ''
    cfg.gsub! /^! NVRAM config last updated at [^\n]*\n/, ''
    cfg.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]*\n*(
                  (?:\ [^\n]*\n*)*
                  tunnel\ mpls\ traffic-eng\ auto-bw)/mx, '\1'
    cfg
  end

Execute

För att starta oxidized och ta en första backup

oxidized

RESTful web API

rest: <IP>:8888

Service

Skapa en service med hjälp av Systemd.

sudo cat <<'__EOF__'>> /lib/systemd/system/oxidized.service
[Unit]
Description=Oxidized - Network Device Configuration Backup Tool

[Service]
ExecStart=/usr/local/bin/oxidized
User=oxidized

[Install]
WantedBy=multi-user.target
__EOF__
sudo systemctl enable oxidized
sudo systemctl start oxidized
sudo systemctl status oxidized