oxidized 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +135 -865
  5. data/docs/Configuration.md +186 -0
  6. data/docs/Hooks.md +143 -0
  7. data/docs/Outputs.md +190 -0
  8. data/docs/Ruby-API.md +115 -0
  9. data/docs/Sources.md +110 -0
  10. data/docs/Supported-OS-Types.md +149 -0
  11. data/docs/VRP-Huawei.md +27 -0
  12. data/extra/oxidized-report-git-commits +21 -40
  13. data/extra/oxidized-ubuntu.haproxy +45 -0
  14. data/extra/oxidized.service +4 -0
  15. data/lib/oxidized/hook.rb +1 -0
  16. data/lib/oxidized/hook/exec.rb +0 -1
  17. data/lib/oxidized/input/ssh.rb +11 -8
  18. data/lib/oxidized/model/acsw.rb +67 -0
  19. data/lib/oxidized/model/aen.rb +20 -0
  20. data/lib/oxidized/model/alteonos.rb +60 -0
  21. data/lib/oxidized/model/asa.rb +53 -18
  22. data/lib/oxidized/model/asyncos.rb +49 -0
  23. data/lib/oxidized/model/audiocodes.rb +32 -0
  24. data/lib/oxidized/model/boss.rb +76 -0
  25. data/lib/oxidized/model/ciscosma.rb +45 -0
  26. data/lib/oxidized/model/ciscosmb.rb +6 -1
  27. data/lib/oxidized/model/coriantgroove.rb +30 -0
  28. data/lib/oxidized/model/dlink.rb +1 -0
  29. data/lib/oxidized/model/enterasys.rb +30 -0
  30. data/lib/oxidized/model/fiberdriver.rb +1 -1
  31. data/lib/oxidized/model/fortios.rb +3 -1
  32. data/lib/oxidized/model/ftos.rb +2 -0
  33. data/lib/oxidized/model/hirschmann.rb +41 -0
  34. data/lib/oxidized/model/hpemsa.rb +13 -0
  35. data/lib/oxidized/model/ios.rb +2 -2
  36. data/lib/oxidized/model/iosxr.rb +1 -0
  37. data/lib/oxidized/model/ipos.rb +7 -1
  38. data/lib/oxidized/model/ironware.rb +4 -1
  39. data/lib/oxidized/model/netgear.rb +12 -4
  40. data/lib/oxidized/model/panos.rb +1 -1
  41. data/lib/oxidized/model/planet.rb +2 -1
  42. data/lib/oxidized/model/powerconnect.rb +5 -0
  43. data/lib/oxidized/model/procurve.rb +13 -0
  44. data/lib/oxidized/model/routeros.rb +12 -5
  45. data/lib/oxidized/model/sgos.rb +46 -0
  46. data/lib/oxidized/model/ucs.rb +31 -0
  47. data/lib/oxidized/model/voss.rb +12 -3
  48. data/lib/oxidized/model/vrp.rb +6 -0
  49. data/lib/oxidized/model/weos.rb +22 -0
  50. data/lib/oxidized/model/xos.rb +4 -0
  51. data/lib/oxidized/node.rb +4 -2
  52. data/lib/oxidized/nodes.rb +1 -0
  53. data/lib/oxidized/version.rb +1 -1
  54. data/lib/oxidized/worker.rb +23 -2
  55. data/oxidized.gemspec +1 -1
  56. metadata +54 -46
@@ -0,0 +1,186 @@
1
+ ## Configuration
2
+ ### Debugging
3
+ 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 containing the value true to the `input` section. The log files will be created depending on the parent directory of the logfile option.
4
+
5
+ The following example will log an active ssh/telnet session `/home/oxidized/.config/oxidized/log/<IP-Adress>-<PROTOCOL>`. The file will be truncated on each consecutive ssh/telnet session, so you need to put a `tailf` or `tail -f` on that file!
6
+
7
+ ```
8
+ log: /home/oxidized/.config/oxidized/log
9
+
10
+ ...
11
+
12
+ input:
13
+ default: ssh, telnet
14
+ debug: true
15
+ ssh:
16
+ secure: false
17
+ ```
18
+
19
+ ### Privileged mode
20
+
21
+ 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.
22
+
23
+ ```
24
+ vars:
25
+ enable: S3cre7
26
+ ```
27
+
28
+ ### Removing secrets
29
+
30
+ To strip out secrets from configurations before storing them, Oxidized needs the the remove_secrets flag. You can globally enable this by adding the following snippet to the global sections of the configuration file.
31
+
32
+ ```
33
+ vars:
34
+ remove_secret: true
35
+ ```
36
+
37
+ Device models can contain substitution filters to remove potentially sensitive data from configs.
38
+
39
+ As a partial example from ios.rb:
40
+
41
+ ```
42
+ cmd :secret do |cfg|
43
+ cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
44
+ (...)
45
+ cfg
46
+ end
47
+ ```
48
+ The above strips out snmp community strings from your saved configs.
49
+
50
+ **NOTE:** Removing secrets reduces the usefulness as a full configuration backup, but it may make sharing configs easier.
51
+
52
+ ### Disabling SSH exec channels
53
+
54
+ Oxidized uses exec channels to make information extraction simpler, but there are some situations where this doesn't work well, e.g. configuring devices. This feature can be turned off by setting the `ssh_no_exec`
55
+ variable.
56
+
57
+ ```
58
+ vars:
59
+ ssh_no_exec: true
60
+ ```
61
+
62
+ ### SSH Proxy Command
63
+
64
+ Oxidized can `ssh` through a proxy as well. To do so we just need to set `ssh_proxy` variable.
65
+
66
+ ```
67
+ ...
68
+ map:
69
+ name: 0
70
+ model: 1
71
+ vars_map:
72
+ enable: 2
73
+ ssh_proxy: 3
74
+ ...
75
+ ```
76
+
77
+ ### Advanced Configuration
78
+
79
+ Below is an advanced example configuration. You will be able to (optionally) 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.
80
+
81
+ ```
82
+ ---
83
+ username: oxidized
84
+ password: S3cr3tx
85
+ model: junos
86
+ interval: 3600
87
+ log: ~/.config/oxidized/log
88
+ debug: false
89
+ threads: 30
90
+ timeout: 20
91
+ retries: 3
92
+ prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/
93
+ vars:
94
+ enable: S3cr3tx
95
+ groups: {}
96
+ rest: 127.0.0.1:8888
97
+ pid: ~/.config/oxidized/oxidized.pid
98
+ input:
99
+ default: ssh, telnet
100
+ debug: false
101
+ ssh:
102
+ secure: false
103
+ output:
104
+ default: git
105
+ git:
106
+ user: Oxidized
107
+ email: oxidized@example.com
108
+ repo: "~/.config/oxidized/oxidized.git"
109
+ source:
110
+ default: csv
111
+ csv:
112
+ file: ~/.config/oxidized/router.db
113
+ delimiter: !ruby/regexp /:/
114
+ map:
115
+ name: 0
116
+ model: 1
117
+ username: 2
118
+ password: 3
119
+ vars_map:
120
+ enable: 4
121
+ model_map:
122
+ cisco: ios
123
+ juniper: junos
124
+
125
+ ```
126
+
127
+ ### Advanced Group Configuration
128
+
129
+ For group specific credentials
130
+
131
+ ```
132
+ groups:
133
+ mikrotik:
134
+ username: admin
135
+ password: blank
136
+ ubiquiti:
137
+ username: ubnt
138
+ password: ubnt
139
+ ```
140
+ and add group mapping
141
+ ```
142
+ map:
143
+ model: 0
144
+ name: 1
145
+ group: 2
146
+ ```
147
+ For model specific credentials
148
+
149
+ ```
150
+ models:
151
+ junos:
152
+ username: admin
153
+ password: password
154
+ ironware:
155
+ username: admin
156
+ password: password
157
+ vars:
158
+ enable: enablepassword
159
+ apc_aos:
160
+ username: apc
161
+ password: password
162
+ ```
163
+
164
+ ### RESTful API and Web Interface
165
+
166
+ The RESTful API and Web Interface is enabled by configuring the `rest:` parameter in the config file. This parameter can optionally contain a relative URI.
167
+
168
+ ```
169
+ # Listen on http://127.0.0.1:8888/
170
+ rest: 127.0.0.1:8888
171
+ ```
172
+
173
+ ```
174
+ # Listen on http://10.0.0.1:8000/oxidized/
175
+ rest: 10.0.0.1:8000/oxidized
176
+ ```
177
+
178
+ ### Triggered backups
179
+
180
+ A node can be moved to head-of-queue via the REST API `GET/POST /node/next/[NODE]`.
181
+
182
+ In the default configuration this node will be processed when the next job worker becomes available, it could take some time if existing backups are in progress. To execute moved jobs immediately a new job can be added:
183
+
184
+ ```
185
+ next_adds_job: true
186
+ ```
@@ -0,0 +1,143 @@
1
+ # Hooks
2
+ You can define arbitrary number of hooks that subscribe different events. The hook system is modular and different kind of hook types can be enabled.
3
+
4
+ ## Configuration
5
+ Following configuration keys need to be defined for all hooks:
6
+
7
+ * `events`: which events to subscribe. Needs to be an array. See below for the list of available events.
8
+ * `type`: what hook class to use. See below for the list of available hook types.
9
+
10
+ ### Events
11
+ * `node_success`: triggered when configuration is succesfully pulled from a node and right before storing the configuration.
12
+ * `node_fail`: triggered after `retries` amount of failed node pulls.
13
+ * `post_store`: triggered after node configuration is stored (this is executed only when the configuration has changed).
14
+ * `nodes_done`: triggered after finished fetching all nodes.
15
+
16
+ ## Hook type: exec
17
+ The `exec` hook type allows users to run an arbitrary shell command or a binary when triggered.
18
+
19
+ The command is executed on a separate child process either in synchronous or asynchronous fashion. Non-zero exit values cause errors to be logged. STDOUT and STDERR are currently not collected.
20
+
21
+ Command is executed with the following environment:
22
+ ```
23
+ OX_EVENT
24
+ OX_NODE_NAME
25
+ OX_NODE_IP
26
+ OX_NODE_FROM
27
+ OX_NODE_MSG
28
+ OX_NODE_GROUP
29
+ OX_JOB_STATUS
30
+ OX_JOB_TIME
31
+ OX_REPO_COMMITREF
32
+ OX_REPO_NAME
33
+ ```
34
+
35
+ Exec hook recognizes following configuration keys:
36
+
37
+ * `timeout`: hard timeout for the command execution. SIGTERM will be sent to the child process after the timeout has elapsed. Default: 60
38
+ * `async`: influences whether main thread will wait for the command execution. Set this true for long running commands so node pull is not blocked. Default: false
39
+ * `cmd`: command to run.
40
+
41
+
42
+ ## Hook configuration example
43
+ ```
44
+ hooks:
45
+ name_for_example_hook1:
46
+ type: exec
47
+ events: [node_success]
48
+ cmd: 'echo "Node success $OX_NODE_NAME" >> /tmp/ox_node_success.log'
49
+ name_for_example_hook2:
50
+ type: exec
51
+ events: [post_store, node_fail]
52
+ cmd: 'echo "Doing long running stuff for $OX_NODE_NAME" >> /tmp/ox_node_stuff.log; sleep 60'
53
+ async: true
54
+ timeout: 120
55
+ ```
56
+
57
+ ### githubrepo
58
+
59
+ This hook configures the repository `remote` and _push_ the code when the specified event is triggerd. If the `username` and `password` are not provided, the `Rugged::Credentials::SshKeyFromAgent` will be used.
60
+
61
+ `githubrepo` hook recognizes following configuration keys:
62
+
63
+ * `remote_repo`: the remote repository to be pushed to.
64
+ * `username`: username for repository auth.
65
+ * `password`: password for repository auth.
66
+ * `publickey`: publickey for repository auth.
67
+ * `privatekey`: privatekey for repository auth.
68
+
69
+ When using groups repositories, each group must have its own `remote` in the `remote_repo` config.
70
+
71
+ ``` yaml
72
+ hooks:
73
+ push_to_remote:
74
+ remote_repo:
75
+ routers: git@git.intranet:oxidized/routers.git
76
+ switches: git@git.intranet:oxidized/switches.git
77
+ firewalls: git@git.intranet:oxidized/firewalls.git
78
+ ```
79
+
80
+
81
+ ## Hook configuration example
82
+
83
+ ``` yaml
84
+ hooks:
85
+ push_to_remote:
86
+ type: githubrepo
87
+ events: [post_store]
88
+ remote_repo: git@git.intranet:oxidized/test.git
89
+ username: user
90
+ password: pass
91
+ ```
92
+
93
+ ## Hook type: awssns
94
+
95
+ The `awssns` hook publishes messages to AWS SNS topics. This allows you to notify other systems of device configuration changes, for example a config orchestration pipeline. Multiple services can subscribe to the same AWS topic.
96
+
97
+ Fields sent in the message:
98
+
99
+ * `event`: Event type (e.g. `node_success`)
100
+ * `group`: Group name
101
+ * `model`: Model name (e.g. `eos`)
102
+ * `node`: Device hostname
103
+
104
+ Configuration example:
105
+
106
+ ``` yaml
107
+ hooks:
108
+ hook_script:
109
+ type: awssns
110
+ events: [node_fail,node_success,post_store]
111
+ region: us-east-1
112
+ topic_arn: arn:aws:sns:us-east-1:1234567:oxidized-test-backup_events
113
+ ```
114
+
115
+ AWS SNS hook requires the following configuration keys:
116
+
117
+ * `region`: AWS Region name
118
+ * `topic_arn`: ASN Topic reference
119
+
120
+ Your AWS credentials should be stored in `~/.aws/credentials`.
121
+
122
+ ## Hook type: slackdiff
123
+
124
+ The `slackdiff` hook posts colorized config diffs to a [Slack](http://www.slack.com) channel of your choice. It only triggers for `post_store` events.
125
+
126
+ You will need to manually install the `slack-api` gem on your system:
127
+
128
+ ```
129
+ gem install slack-api
130
+ ```
131
+
132
+ Configuration example:
133
+
134
+ ``` yaml
135
+ hooks:
136
+ slack:
137
+ type: slackdiff
138
+ events: [post_store]
139
+ token: SLACK_BOT_TOKEN
140
+ channel: "#network-changes"
141
+ ```
142
+
143
+ Note the channel name must be in quotes.
@@ -0,0 +1,190 @@
1
+
2
+ ## Output
3
+
4
+ ### Output: File
5
+
6
+ Parent directory needs to be created manually, one file per device, with most recent running config.
7
+
8
+ ```
9
+ output:
10
+ file:
11
+ directory: /var/lib/oxidized/configs
12
+ ```
13
+
14
+ ### Output: Git
15
+
16
+ This uses the rugged/libgit2 interface. So you should remember that normal Git hooks will not be executed.
17
+
18
+ For a single repositories for all devices:
19
+
20
+ ``` yaml
21
+ output:
22
+ default: git
23
+ git:
24
+ user: Oxidized
25
+ email: o@example.com
26
+ repo: "/var/lib/oxidized/devices.git"
27
+ ```
28
+
29
+ And for groups repositories:
30
+
31
+ ``` yaml
32
+ output:
33
+ default: git
34
+ git:
35
+ user: Oxidized
36
+ email: o@example.com
37
+ repo: "/var/lib/oxidized/git-repos/default.git"
38
+ ```
39
+
40
+ Oxidized will create a repository for each group in the same directory as the `default.git`. For
41
+ example:
42
+
43
+ ``` csv
44
+ host1:ios:first
45
+ host2:nxos:second
46
+ ```
47
+
48
+ This will generate the following repositories:
49
+
50
+ ``` bash
51
+ $ ls /var/lib/oxidized/git-repos
52
+
53
+ default.git first.git second.git
54
+ ```
55
+
56
+ If you would like to use groups and a single repository, you can force this with the `single_repo` config.
57
+
58
+ ``` yaml
59
+ output:
60
+ default: git
61
+ git:
62
+ single_repo: true
63
+ repo: "/var/lib/oxidized/devices.git"
64
+
65
+ ```
66
+
67
+ ### Output: Git-Crypt
68
+
69
+ This uses the gem git and system git-crypt interfaces. Have a look at [GIT-Crypt](https://www.agwa.name/projects/git-crypt/) documentation to know how to install it.
70
+ Additionally to user and email informations, you have to provide the users ID that can be a key ID, a full fingerprint, an email address, or anything else that uniquely identifies a public key to GPG (see "HOW TO SPECIFY A USER ID" in the gpg man page).
71
+
72
+
73
+ For a single repositories for all devices:
74
+
75
+ ``` yaml
76
+ output:
77
+ default: gitcrypt
78
+ gitcrypt:
79
+ user: Oxidized
80
+ email: o@example.com
81
+ repo: "/var/lib/oxidized/devices"
82
+ users:
83
+ - "0x0123456789ABCDEF"
84
+ - "<user@example.com>"
85
+ ```
86
+
87
+ And for groups repositories:
88
+
89
+ ``` yaml
90
+ output:
91
+ default: gitcrypt
92
+ gitcrypt:
93
+ user: Oxidized
94
+ email: o@example.com
95
+ repo: "/var/lib/oxidized/git-repos/default"
96
+ users:
97
+ - "0xABCDEF0123456789"
98
+ - "0x0123456789ABCDEF"
99
+ ```
100
+
101
+ Oxidized will create a repository for each group in the same directory as the `default`. For
102
+ example:
103
+
104
+ ``` csv
105
+ host1:ios:first
106
+ host2:nxos:second
107
+ ```
108
+
109
+ This will generate the following repositories:
110
+
111
+ ``` bash
112
+ $ ls /var/lib/oxidized/git-repos
113
+
114
+ default.git first.git second.git
115
+ ```
116
+
117
+ If you would like to use groups and a single repository, you can force this with the `single_repo` config.
118
+
119
+ ``` yaml
120
+ output:
121
+ default: gitcrypt
122
+ gitcrypt:
123
+ single_repo: true
124
+ repo: "/var/lib/oxidized/devices"
125
+ users:
126
+ - "0xABCDEF0123456789"
127
+ - "0x0123456789ABCDEF"
128
+
129
+ ```
130
+
131
+ Please note that user list is only updated once at creation.
132
+
133
+ ### Output: Http
134
+
135
+ POST a config to the specified URL
136
+
137
+ ```
138
+ output:
139
+ default: http
140
+ http:
141
+ user: admin
142
+ password: changeit
143
+ url: "http://192.168.162.50:8080/db/coll"
144
+ ```
145
+
146
+ ### Output types
147
+
148
+ If you prefer to have different outputs in different files and/or directories, you can easily do this by modifying the corresponding model. To change the behaviour for IOS, you would edit `lib/oxidized/model/ios.rb` (run `gem contents oxidized` to find out the full file path).
149
+
150
+ For example, let's say you want to split out `show version` and `show inventory` into separate files in a directory called `nodiff` which your tools will not send automated diffstats for. You can apply a patch along the lines of
151
+
152
+ ```
153
+ - cmd 'show version' do |cfg|
154
+ - comment cfg.lines.first
155
+ + cmd 'show version' do |state|
156
+ + state.type = 'nodiff'
157
+ + state
158
+
159
+ - cmd 'show inventory' do |cfg|
160
+ - comment cfg
161
+ + cmd 'show inventory' do |state|
162
+ + state.type = 'nodiff'
163
+ + state
164
+ + end
165
+
166
+ - cmd 'show running-config' do |cfg|
167
+ - cfg = cfg.each_line.to_a[3..-1].join
168
+ - cfg.gsub! /^Current configuration : [^\n]*\n/, ''
169
+ - cfg.sub! /^(ntp clock-period).*/, '! \1'
170
+ - cfg.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]*\n*(
171
+ + cmd 'show running-config' do |state|
172
+ + state = state.each_line.to_a[3..-1].join
173
+ + state.gsub! /^Current configuration : [^\n]*\n/, ''
174
+ + state.sub! /^(ntp clock-period).*/, '! \1'
175
+ + state.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]*\n*(
176
+ (?:\ [^\n]*\n*)*
177
+ tunnel\ mpls\ traffic-eng\ auto-bw)/mx, '\1'
178
+ - cfg
179
+ + state = Oxidized::String.new state
180
+ + state.type = 'nodiff'
181
+ + state
182
+ ```
183
+
184
+ which will result in the following layout
185
+
186
+ ```
187
+ diff/$FQDN--show_running_config
188
+ nodiff/$FQDN--show_version
189
+ nodiff/$FQDN--show_inventory
190
+ ```