oxidized 0.29.1 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.coderabbit.yaml +21 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +45 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
- data/.github/ISSUE_TEMPLATE/support-request.md +39 -0
- data/.github/workflows/codeql.yml +4 -4
- data/.github/workflows/publishdocker.yml +108 -13
- data/.github/workflows/ruby.yml +3 -12
- data/.github/workflows/stale.yml +6 -1
- data/.gitignore +2 -0
- data/.rubocop.yml +69 -13
- data/.rubocop_todo.yml +13 -143
- data/CHANGELOG.md +431 -4
- data/CONTRIBUTING.md +189 -0
- data/Dockerfile +89 -34
- data/README.md +59 -188
- data/Rakefile +58 -12
- data/bin/oxidized +2 -5
- data/docs/Configuration.md +382 -149
- data/docs/Creating-Models.md +262 -10
- data/docs/DeviceSimulation.md +196 -0
- data/docs/Docker.md +246 -0
- data/docs/Hooks.md +146 -51
- data/docs/Inputs.md +237 -0
- data/docs/Issues.md +123 -0
- data/docs/Model-Notes/APC.md +72 -0
- data/docs/Model-Notes/Cumulus.md +5 -0
- data/docs/Model-Notes/EatonNetwork.md +18 -0
- data/docs/Model-Notes/ExaLink.md +43 -0
- data/docs/Model-Notes/FSOS.md +17 -0
- data/docs/Model-Notes/Fortinet.md +75 -0
- data/docs/Model-Notes/GrandstreamHT8xx.md +8 -0
- data/docs/Model-Notes/HPEAruba.md +32 -0
- data/docs/Model-Notes/IvantiConnectSecure.md +59 -0
- data/docs/Model-Notes/OS6.md +10 -0
- data/docs/Model-Notes/README.md +1 -20
- data/docs/Model-Notes/RouterOS.md +28 -0
- data/docs/Model-Notes/SikluMHTG.md +7 -0
- data/docs/Model-Notes/TrueNAS.md +23 -0
- data/docs/Model-Notes/XGS4600-Zyxel.md +5 -0
- data/docs/ModelUnitTests.md +219 -0
- data/docs/Outputs.md +102 -5
- data/docs/Release.md +102 -0
- data/docs/Ruby-API.md +135 -2
- data/docs/Sources.md +34 -0
- data/docs/Supported-OS-Types.md +207 -270
- data/docs/Troubleshooting.md +43 -1
- data/extra/device2yaml.rb +259 -0
- data/extra/gitdiff-msteams.sh +32 -5
- data/extra/hooks/modelrules.rb +55 -0
- data/extra/hooks/modelrulesadvanced.rb +167 -0
- data/extra/hooks/srcipmap.rb +54 -0
- data/extra/nagios_check_failing_nodes.rb +1 -1
- data/extra/oxidized.runit +1 -1
- data/extra/rest_client.rb +5 -4
- data/extra/syslog.rb +11 -6
- data/lib/oxidized/cli/support.rb +152 -0
- data/lib/oxidized/cli.rb +21 -6
- data/lib/oxidized/config/vars.rb +33 -14
- data/lib/oxidized/config.rb +28 -17
- data/lib/oxidized/core.rb +50 -8
- data/lib/oxidized/hook/ciscosparkdiff.rb +11 -9
- data/lib/oxidized/hook/exec.rb +5 -4
- data/lib/oxidized/hook/githubrepo.rb +55 -18
- data/lib/oxidized/hook/noophook.rb +2 -2
- data/lib/oxidized/hook/slackdiff.rb +50 -14
- data/lib/oxidized/hook/xmppdiff.rb +9 -9
- data/lib/oxidized/hook.rb +68 -16
- data/lib/oxidized/input/cli.rb +8 -3
- data/lib/oxidized/input/debugtext.rb +40 -0
- data/lib/oxidized/input/debugyaml.rb +82 -0
- data/lib/oxidized/input/exec.rb +2 -11
- data/lib/oxidized/input/ftp.rb +2 -19
- data/lib/oxidized/input/http.rb +67 -17
- data/lib/oxidized/input/input.rb +35 -14
- data/lib/oxidized/input/scp.rb +27 -0
- data/lib/oxidized/input/ssh.rb +59 -83
- data/lib/oxidized/input/sshbase.rb +102 -0
- data/lib/oxidized/input/telnet.rb +20 -19
- data/lib/oxidized/input/tftp.rb +8 -8
- data/lib/oxidized/job.rb +18 -7
- data/lib/oxidized/jobs.rb +11 -1
- data/lib/oxidized/logger.rb +51 -0
- data/lib/oxidized/manager.rb +18 -17
- data/lib/oxidized/model/acos.rb +2 -1
- data/lib/oxidized/model/addpack.rb +26 -0
- data/lib/oxidized/model/adtran.rb +5 -1
- data/lib/oxidized/model/adva.rb +3 -3
- data/lib/oxidized/model/airfiber.rb +1 -1
- data/lib/oxidized/model/aos7.rb +11 -0
- data/lib/oxidized/model/aoscx.rb +37 -29
- data/lib/oxidized/model/aosw.rb +39 -29
- data/lib/oxidized/model/apc_aos.rb +7 -2
- data/lib/oxidized/model/apcaos.rb +39 -0
- data/lib/oxidized/model/aricentiss.rb +9 -2
- data/lib/oxidized/model/arubainstant.rb +93 -0
- data/lib/oxidized/model/asa.rb +11 -10
- data/lib/oxidized/model/asternos.rb +22 -0
- data/lib/oxidized/model/asyncos.rb +3 -3
- data/lib/oxidized/model/audiocodes.rb +2 -2
- data/lib/oxidized/model/awplus.rb +15 -12
- data/lib/oxidized/model/axos.rb +1 -1
- data/lib/oxidized/model/bdcom.rb +1 -0
- data/lib/oxidized/model/c4cmts.rb +1 -2
- data/lib/oxidized/model/ciscosma.rb +1 -1
- data/lib/oxidized/model/ciscosmb.rb +6 -1
- data/lib/oxidized/model/cnos.rb +13 -10
- data/lib/oxidized/model/comtrol.rb +1 -1
- data/lib/oxidized/model/comware.rb +5 -3
- data/lib/oxidized/model/cumulus.rb +14 -2
- data/lib/oxidized/model/defacto.rb +26 -0
- data/lib/oxidized/model/dellx.rb +1 -1
- data/lib/oxidized/model/dlink.rb +5 -2
- data/lib/oxidized/model/dlinknextgen.rb +55 -0
- data/lib/oxidized/model/dnos.rb +3 -0
- data/lib/oxidized/model/dslcommands.rb +93 -0
- data/lib/oxidized/model/dslsetup.rb +102 -0
- data/lib/oxidized/model/eatonnetwork.rb +70 -0
- data/lib/oxidized/model/edgecos.rb +3 -1
- data/lib/oxidized/model/edgeos.rb +7 -6
- data/lib/oxidized/model/edgeswitch.rb +3 -1
- data/lib/oxidized/model/efos.rb +41 -0
- data/lib/oxidized/model/eltex.rb +4 -2
- data/lib/oxidized/model/enterasys800.rb +2 -2
- data/lib/oxidized/model/enterprise_sonic.rb +46 -0
- data/lib/oxidized/model/eos.rb +3 -1
- data/lib/oxidized/model/exalink.rb +36 -0
- data/lib/oxidized/model/f5os.rb +17 -0
- data/lib/oxidized/model/fabricos.rb +2 -2
- data/lib/oxidized/model/fastiron.rb +5 -3
- data/lib/oxidized/model/firebrick.rb +2 -2
- data/lib/oxidized/model/firelinuxos.rb +13 -6
- data/lib/oxidized/model/firewareos.rb +10 -1
- data/lib/oxidized/model/fortigate.rb +160 -0
- data/lib/oxidized/model/fortios.rb +38 -48
- data/lib/oxidized/model/fsos.rb +46 -0
- data/lib/oxidized/model/gaiaos.rb +4 -4
- data/lib/oxidized/model/garderos.rb +38 -0
- data/lib/oxidized/model/grandstreamht8xx.rb +19 -0
- data/lib/oxidized/model/h3c.rb +1 -1
- data/lib/oxidized/model/ibos.rb +1 -0
- data/lib/oxidized/model/ingate.rb +47 -0
- data/lib/oxidized/model/ios.rb +57 -30
- data/lib/oxidized/model/iosxr.rb +2 -2
- data/lib/oxidized/model/ironware.rb +7 -5
- data/lib/oxidized/model/ivanti.rb +54 -0
- data/lib/oxidized/model/junos.rb +12 -5
- data/lib/oxidized/model/kornfeldos.rb +33 -0
- data/lib/oxidized/model/lenovonos.rb +2 -0
- data/lib/oxidized/model/linksyssrw.rb +3 -3
- data/lib/oxidized/model/linuxgeneric.rb +4 -2
- data/lib/oxidized/model/macros.rb +60 -0
- data/lib/oxidized/model/mimosab11.rb +34 -0
- data/lib/oxidized/model/ml66.rb +33 -0
- data/lib/oxidized/model/mlnxos.rb +18 -14
- data/lib/oxidized/model/model.rb +98 -103
- data/lib/oxidized/model/mtrlrfs.rb +1 -0
- data/lib/oxidized/model/ndms.rb +6 -0
- data/lib/oxidized/model/netgear.rb +14 -3
- data/lib/oxidized/model/netonix.rb +1 -1
- data/lib/oxidized/model/netscaler.rb +1 -1
- data/lib/oxidized/model/nodegrid.rb +1 -1
- data/lib/oxidized/model/nsxdfw.rb +31 -0
- data/lib/oxidized/model/nsxfirewall.rb +2 -1
- data/lib/oxidized/model/nxos.rb +20 -15
- data/lib/oxidized/model/ocnos.rb +42 -0
- data/lib/oxidized/model/onefinity.rb +18 -0
- data/lib/oxidized/model/openbsd.rb +1 -1
- data/lib/oxidized/model/opengear.rb +36 -1
- data/lib/oxidized/model/openwrt.rb +6 -6
- data/lib/oxidized/model/opnsense.rb +9 -1
- data/lib/oxidized/model/os6.rb +48 -0
- data/lib/oxidized/model/outputs.rb +5 -0
- data/lib/oxidized/model/panos.rb +2 -0
- data/lib/oxidized/model/perle.rb +41 -0
- data/lib/oxidized/model/pfsense.rb +9 -0
- data/lib/oxidized/model/powerconnect.rb +32 -11
- data/lib/oxidized/model/procurve.rb +6 -2
- data/lib/oxidized/model/qtech.rb +3 -1
- data/lib/oxidized/model/quantaos.rb +8 -6
- data/lib/oxidized/model/rgos.rb +33 -0
- data/lib/oxidized/model/riverbed.rb +104 -0
- data/lib/oxidized/model/routeros.rb +18 -11
- data/lib/oxidized/model/saos.rb +18 -1
- data/lib/oxidized/model/saos10.rb +38 -0
- data/lib/oxidized/model/siklu.rb +1 -1
- data/lib/oxidized/model/siklumhtg.rb +22 -0
- data/lib/oxidized/model/sixwind.rb +28 -0
- data/lib/oxidized/model/slxos.rb +3 -3
- data/lib/oxidized/model/smartbyte.rb +48 -0
- data/lib/oxidized/model/sonicos.rb +27 -20
- data/lib/oxidized/model/speedtouch.rb +1 -1
- data/lib/oxidized/model/sros.rb +3 -3
- data/lib/oxidized/model/srosmd.rb +1 -1
- data/lib/oxidized/model/supermicro.rb +1 -1
- data/lib/oxidized/model/telco.rb +1 -1
- data/lib/oxidized/model/tmos.rb +1 -0
- data/lib/oxidized/model/tnsr.rb +57 -0
- data/lib/oxidized/model/tplink.rb +5 -5
- data/lib/oxidized/model/trango.rb +4 -2
- data/lib/oxidized/model/truenas.rb +64 -3
- data/lib/oxidized/model/ucs.rb +1 -1
- data/lib/oxidized/model/unifiap.rb +144 -0
- data/lib/oxidized/model/uplinkolt.rb +46 -0
- data/lib/oxidized/model/voltaire.rb +1 -1
- data/lib/oxidized/model/voss.rb +3 -0
- data/lib/oxidized/model/vrp.rb +5 -1
- data/lib/oxidized/model/vyatta.rb +9 -3
- data/lib/oxidized/model/vyos.rb +37 -0
- data/lib/oxidized/model/xos.rb +10 -1
- data/lib/oxidized/model/zhoneolt.rb +4 -2
- data/lib/oxidized/model/zynos.rb +67 -3
- data/lib/oxidized/model/zynosadsl.rb +14 -0
- data/lib/oxidized/model/zynoscli.rb +1 -1
- data/lib/oxidized/model/zynosgs.rb +2 -0
- data/lib/oxidized/model/zynosmgs.rb +32 -0
- data/lib/oxidized/node.rb +99 -64
- data/lib/oxidized/nodes.rb +40 -19
- data/lib/oxidized/output/file.rb +80 -43
- data/lib/oxidized/output/git.rb +295 -151
- data/lib/oxidized/output/gitcrypt.rb +193 -185
- data/lib/oxidized/output/http.rb +63 -51
- data/lib/oxidized/output/output.rb +20 -4
- data/lib/oxidized/signals.rb +44 -0
- data/lib/oxidized/source/csv.rb +49 -49
- data/lib/oxidized/source/http.rb +76 -63
- data/lib/oxidized/source/jsonfile.rb +68 -0
- data/lib/oxidized/source/source.rb +73 -18
- data/lib/oxidized/source/sql.rb +71 -59
- data/lib/oxidized/version.rb +6 -4
- data/lib/oxidized/worker.rb +57 -29
- data/lib/oxidized.rb +4 -24
- data/lib/refinements.rb +21 -1
- data/oxidized.gemspec +45 -21
- metadata +248 -41
- data/lib/oxidized/model/timos.rb +0 -10
data/docs/Docker.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Running oxidized within an OCI container (docker, podman...)
|
|
2
|
+
|
|
3
|
+
## Docker image
|
|
4
|
+
The official Docker image is automatically built and pushed to hub.docker.com
|
|
5
|
+
as [oxidized/oxidized](https://hub.docker.com/r/oxidized/oxidized/) with a
|
|
6
|
+
[GitHub CI](/.github/workflows/publishdocker.yml).
|
|
7
|
+
|
|
8
|
+
There are three different types of tags:
|
|
9
|
+
- Each commit to the master branch will be published with the tag
|
|
10
|
+
`master-(git sha oid)`
|
|
11
|
+
- Each release will be published with the full version as a tag (e.g. `0.35.0`)
|
|
12
|
+
- Each release will also be published with the major version as a tag (e.g. `0`)
|
|
13
|
+
- Latest is the latest release, either from a commit or a release tag
|
|
14
|
+
|
|
15
|
+
Currently, Docker Hub automatically builds the master branch for linux/amd64 and
|
|
16
|
+
linux/arm64 platforms as
|
|
17
|
+
[oxidized/oxidized](https://hub.docker.com/r/oxidized/oxidized/). You can make
|
|
18
|
+
use of this container or build your own.
|
|
19
|
+
|
|
20
|
+
## Choose a container running environment
|
|
21
|
+
There are many options to run containers. Two main options are
|
|
22
|
+
[docker](https://www.docker.com/) and [podman](https://podman.io/). A main
|
|
23
|
+
difference is that docker requires root rights to run, and podman can be run
|
|
24
|
+
by a local user. Both work with oxidized, so the choice is up to you.
|
|
25
|
+
|
|
26
|
+
Oxidized has also been reported to work with
|
|
27
|
+
[Portainer](https://www.portainer.io/).
|
|
28
|
+
|
|
29
|
+
## File rights in the container userspace and host userspace
|
|
30
|
+
As oxidized runs under the user "oxidized" (UID: 30000) in the container
|
|
31
|
+
userspace, docker and podman will map this UID in the shared volumes, producing
|
|
32
|
+
weird UIDs in the host userspace.
|
|
33
|
+
|
|
34
|
+
### docker
|
|
35
|
+
When docker runs the container as root, the mapping to the UIDs in the host
|
|
36
|
+
userspace will be the same as in the container, so the files produced by the
|
|
37
|
+
oxidized user in the container will have UID 30000 in the host.
|
|
38
|
+
|
|
39
|
+
If you map a volume between the host and the container and need it to be
|
|
40
|
+
accessed by the oxidized user, you need to fix the UIDs:
|
|
41
|
+
```
|
|
42
|
+
sudo chown 30000:30000 ~/oxidized-config
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### podman
|
|
46
|
+
When podman is run as a user, the mapping of UIDs between the container and the
|
|
47
|
+
linux host will depend on your UID on the host.
|
|
48
|
+
|
|
49
|
+
If you map a volume between the host and the container and need it to be
|
|
50
|
+
accessed by the oxidized user, you need to fix the UIDs:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
podman unshare chown 30000:30000 ~/oxidized-config
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If you need to access the files from the linux host, you can do this by
|
|
57
|
+
prefixing `podman unshare` to your shell commands.
|
|
58
|
+
|
|
59
|
+
## Build you own container image
|
|
60
|
+
To build your own container image, clone the git repository:
|
|
61
|
+
|
|
62
|
+
```shell
|
|
63
|
+
git clone https://github.com/ytti/oxidized
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Then, build the container locally:
|
|
67
|
+
|
|
68
|
+
```shell
|
|
69
|
+
sudo docker build -q -t oxidized/oxidized:latest oxidized/
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- `-q` stands for quiet; remove it if you want to see the build process.
|
|
73
|
+
- `-t oxidized/oxidized:latest` tags the image as `oxidized/oxidized:latest`
|
|
74
|
+
|
|
75
|
+
You can also build with podman:
|
|
76
|
+
```
|
|
77
|
+
podman build -t oxidized:latest oxidized/
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Within the oxidized repository, using `rake build_container` will automatically
|
|
81
|
+
build the container (with podman or docker), name it `localhost/oxidized` and
|
|
82
|
+
give it the tags `latest` and `<branchname>-<sha-tag>`, for example
|
|
83
|
+
`localhost/oxidized:master-65baab9`.
|
|
84
|
+
|
|
85
|
+
## Set up an environment for the container
|
|
86
|
+
Once you've built the container (or chosen to make use of the automatically
|
|
87
|
+
built container in Docker Hub, which will be downloaded for you by docker on the
|
|
88
|
+
first `run` command had you not built it), you need to set up an environment
|
|
89
|
+
for the container.
|
|
90
|
+
|
|
91
|
+
First, you need a configuration directory in the host system that you can map
|
|
92
|
+
in the container. You can choose any directory you want, we'll take
|
|
93
|
+
`~/oxidized-config` in our example. Don't forget to adjust the permissions as
|
|
94
|
+
explained above.
|
|
95
|
+
|
|
96
|
+
If you already have a configuration for oxidized (`config`), you can skip this
|
|
97
|
+
step. Just save it under `~/oxidized-config` and run the container (see below).
|
|
98
|
+
|
|
99
|
+
If you don't have a configuration, you can make oxidized produce one for you, so
|
|
100
|
+
that you just have to adapt it to your needs.
|
|
101
|
+
|
|
102
|
+
```shell
|
|
103
|
+
sudo docker run --rm -v ~/oxidized-config:/home/oxidized/.config/oxidized docker.io/oxidized/oxidized:latest su - oxidized -c oxidized
|
|
104
|
+
```
|
|
105
|
+
```shell
|
|
106
|
+
podman run --rm -v ~/oxidized-config:/home/oxidized/.config/oxidized docker.io/oxidized/oxidized:latest su - oxidized -c oxidized
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- `--rm` tells docker to automatically remove the container when he exits
|
|
110
|
+
- `-v ~/oxidized-config:/home/oxidized/.config/oxidized` maps your local
|
|
111
|
+
`~/oxidized-config` into `/home/oxidized/.config/oxidized`in the container
|
|
112
|
+
environment.
|
|
113
|
+
- `su - oxidized -c oxidized` runs oxidized under the user oxidized, so that it
|
|
114
|
+
can produce a configuration under `/home/oxidized/.config/oxidized`
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
This will return `edit /home/oxidized/.config/oxidized/config`, which is the
|
|
118
|
+
path in the container context. Now you can edit `~/oxidized-config/config` to
|
|
119
|
+
fit your needs.
|
|
120
|
+
|
|
121
|
+
You can reiterate this process a few times, until oxidized is happy with the
|
|
122
|
+
config, an then you're finished with setting up the environment.
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
You also need to create the `router.db` file under
|
|
126
|
+
`~/oxidized-config/config/router.db` (see
|
|
127
|
+
[CSV Source](/docs/Sources.md#source-csv) for further info) or configure another
|
|
128
|
+
source to suit your needs. Don't forget to set the file permissions (owner)
|
|
129
|
+
properly!
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
## Run the container
|
|
134
|
+
Now you can run the container without specifying an entry point. It will
|
|
135
|
+
automatically start oxidized and every other process needed.
|
|
136
|
+
```shell
|
|
137
|
+
sudo docker run --rm -v ~/oxidized-config:/home/oxidized/.config/oxidized -p 8888:8888/tcp docker.io/oxidized/oxidized:latest
|
|
138
|
+
```
|
|
139
|
+
```shell
|
|
140
|
+
podman run --rm -v ~/oxidized-config:/home/oxidized/.config/oxidized -p 8888:8888/tcp docker.io/oxidized/oxidized:latest
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`-p 8888:8888/tcp` maps the TCP port 8888 in the container with the port
|
|
144
|
+
8888 on the host, so that you can access the RESTful API and Web Interface
|
|
145
|
+
from the host.
|
|
146
|
+
If the RESTful API and Web Interface should be enabled, edit the
|
|
147
|
+
configuration (in our example `~/oxidized-config/config`) and modify
|
|
148
|
+
`rest: 127.0.0.1:8888` to `rest: 0.0.0.0:8888`. This will bind port 8888 to all
|
|
149
|
+
interfaces, and expose the port so that it can be accessed externally.
|
|
150
|
+
[(Issue #445)](https://github.com/ytti/oxidized/issues/445)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
## Run with with docker-compose / podman-compose
|
|
154
|
+
Alternatively, you can use docker-compose or podman-compose to run the
|
|
155
|
+
container:
|
|
156
|
+
|
|
157
|
+
```yaml
|
|
158
|
+
# docker-compose.yml
|
|
159
|
+
# docker-compose file example for oxidized that will start along with docker daemon
|
|
160
|
+
---
|
|
161
|
+
version: "3"
|
|
162
|
+
services:
|
|
163
|
+
oxidized:
|
|
164
|
+
restart: always
|
|
165
|
+
image: docker.io/oxidized/oxidized:latest
|
|
166
|
+
ports:
|
|
167
|
+
- 8888:8888/tcp
|
|
168
|
+
environment:
|
|
169
|
+
# Reload hosts list once per day
|
|
170
|
+
CONFIG_RELOAD_INTERVAL: 86400
|
|
171
|
+
volumes:
|
|
172
|
+
- ~/oxidized-config/config:/home/oxidized/.config/oxidized/
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
To start the pod, use `docker-compose up` or `podman-compose down`.
|
|
176
|
+
|
|
177
|
+
## Special configurations of the official container
|
|
178
|
+
### Reload the configuration
|
|
179
|
+
If you want to have the config automatically reloaded (e.g. when using a http
|
|
180
|
+
source that changes), you need to set the environment variable
|
|
181
|
+
CONFIG_RELOAD_INTERVAL. This can be done in `docker-compose.yml` (see above) or
|
|
182
|
+
on the command line:
|
|
183
|
+
|
|
184
|
+
```shell
|
|
185
|
+
sudo docker run -v ~/oxidized-config:/home/oxidized/.config/oxidized -p 8888:8888/tcp -e CONFIG_RELOAD_INTERVAL=3600 docker.io/oxidized/oxidized:latest
|
|
186
|
+
```
|
|
187
|
+
### Use an internal CA
|
|
188
|
+
If you need to use an internal CA (e.g. to connect to an private github instance):
|
|
189
|
+
|
|
190
|
+
```shell
|
|
191
|
+
docker run -v /etc/oxidized:/home/oxidized/.config/oxidized -v /path/to/MY-CA.crt:/usr/local/share/ca-certificates/MY-CA.crt -p 8888:8888/tcp -e UPDATE_CA_CERTIFICATES=true -t oxidized/oxidized:latest
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Pass the ssh passphrase for a remote git
|
|
195
|
+
If you don't want to authenticate with user & password but with a ssh-key, you
|
|
196
|
+
can set the ssh passphrase with the environment variable
|
|
197
|
+
`OXIDIZED_SSH_PASSPHRASE`
|
|
198
|
+
|
|
199
|
+
## Tipps & tricks
|
|
200
|
+
### podman & Debian Bookworm
|
|
201
|
+
To install podman in Debian Bookwork, you need following packages:
|
|
202
|
+
```shell
|
|
203
|
+
sudo apt install podman containers-storage podman-compose
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Ensure Podman is using the overlay driver for image storage.
|
|
207
|
+
Without this driver, Podman may save every container layer separately rather
|
|
208
|
+
than only the changes, which can quickly consume disk space.
|
|
209
|
+
|
|
210
|
+
This issue can occur if podman was run before installing the
|
|
211
|
+
`container-storage` package.
|
|
212
|
+
|
|
213
|
+
```shell
|
|
214
|
+
podman info | grep graphDriverName
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
You should get this reply
|
|
218
|
+
```shell
|
|
219
|
+
graphDriverName: overlay
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
If not, a quick way to solve it is to delete `~/.local/share/containers/`.
|
|
223
|
+
Beware - this will delete **all** your containers!
|
|
224
|
+
|
|
225
|
+
### Store the ssh keys a remote git repository
|
|
226
|
+
When you use the githubrepo hook to upload your configs to a remote git
|
|
227
|
+
repository, you have to store your ssh-key and the public keys of the remote
|
|
228
|
+
server. Create a directory `~/oxidized-ssh` and map it to `/home/oxidized/.ssh`.
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
To generate an ssh-key, run:
|
|
232
|
+
```shell
|
|
233
|
+
ssh-keygen -q -t ed25519 -C "Oxidized Push Key@`hostname`" -N "YOURPASSPHRASE" -m PEM -f ~/oxidized-ssh/oxidized-key
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
You also need to store the public keys of the remote git server in known_hosts.
|
|
237
|
+
If you don't store the keys, oxidized will refuse to push to the remote Git with
|
|
238
|
+
the error
|
|
239
|
+
`#<Rugged::SshError: invalid or unknown remote ssh hostkey>`, see Issue #2753.
|
|
240
|
+
|
|
241
|
+
```shell
|
|
242
|
+
ssh-keyscan git-server.example.com > ~/oxidized-ssh/known_hosts
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Don't forget to set the permission (owner) of the files for the user oxidized
|
|
246
|
+
inside the container, or this will not work!
|
data/docs/Hooks.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
You can define an arbitrary number of hooks that subscribe to different events. The hook system is modular and different kind of hook types can be enabled.
|
|
4
4
|
|
|
5
|
+
1. [Events](#events)
|
|
6
|
+
2. Hook types
|
|
7
|
+
* [exec](#hook-type-exec)
|
|
8
|
+
* [githubrepo](#hook-type-githubrepo)
|
|
9
|
+
* [awssns](#hook-type-awssns)
|
|
10
|
+
* [slackdiff](#hook-type-slackdiff)
|
|
11
|
+
* [ciscosparkdiff](#ciscosparkdiff)
|
|
12
|
+
* [xmppdiff](#hook-type-xmppdiff)
|
|
13
|
+
|
|
5
14
|
## Configuration
|
|
6
15
|
|
|
7
16
|
Following configuration keys need to be defined for all hooks:
|
|
@@ -46,7 +55,7 @@ Exec hook recognizes the following configuration keys:
|
|
|
46
55
|
* `async`: Execute the command in an asynchronous fashion. The main thread by default will wait for the hook command execution to complete. Set this to `true` for long running commands so node configuration pulls are not blocked. Default: `false`
|
|
47
56
|
* `cmd`: command to run.
|
|
48
57
|
|
|
49
|
-
###
|
|
58
|
+
### Exec Hook configuration example
|
|
50
59
|
|
|
51
60
|
```yaml
|
|
52
61
|
hooks:
|
|
@@ -62,52 +71,140 @@ hooks:
|
|
|
62
71
|
timeout: 120
|
|
63
72
|
```
|
|
64
73
|
|
|
74
|
+
### Exec Hook configuration example to send mail
|
|
75
|
+
|
|
76
|
+
To send mail you need the package `msmtp` (It is pre-installed with the docker container)
|
|
77
|
+
|
|
78
|
+
You then need to update the `~/.msmtprc` file to contain your SMTP credentials like this:
|
|
79
|
+
|
|
80
|
+
*Note: In the docker container the file is in /home/oxidized/.config/oxidized/.msmtprc so you can create the file if it doesn't exist in your oxidized config folder.*
|
|
81
|
+
|
|
82
|
+
```cfg
|
|
83
|
+
# Default settings
|
|
84
|
+
defaults
|
|
85
|
+
auth on
|
|
86
|
+
tls on
|
|
87
|
+
# Outlook SMTP
|
|
88
|
+
account mainaccount
|
|
89
|
+
host smtp.office365.com
|
|
90
|
+
port 587
|
|
91
|
+
from user@domain.com
|
|
92
|
+
user user@domain.com
|
|
93
|
+
password edit-password
|
|
94
|
+
|
|
95
|
+
account default : mainaccount
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
For non docker users this file should have the 600 permission, using: `chmod 600 .msmtprc` and the owner of the file should be the owner of oxidized `chown oxidized:oxidized .msmtprc`
|
|
99
|
+
|
|
100
|
+
Then, you can configure Hooks to send mail like this:
|
|
101
|
+
|
|
102
|
+
```yaml
|
|
103
|
+
hooks:
|
|
104
|
+
send_mail_hook:
|
|
105
|
+
type: exec
|
|
106
|
+
events: [node_fail]
|
|
107
|
+
cmd: '/usr/bin/echo -e "Subject: [Oxidized] Error on node $OX_NODE_NAME \n\nThe device $OX_NODE_NAME has not been backed-up, reason: \n\n$OX_EVENT: $OX_ERR_REASON" | msmtp destination@domain.com'
|
|
108
|
+
```
|
|
109
|
+
|
|
65
110
|
## Hook type: githubrepo
|
|
66
111
|
|
|
67
|
-
|
|
112
|
+
The `githubrepo` hook executes a `git push` to a configured `remote_repo` when
|
|
113
|
+
the specified event is triggered.
|
|
114
|
+
|
|
115
|
+
### Configuration keys
|
|
116
|
+
|
|
117
|
+
| Key | Description |
|
|
118
|
+
|---------------|-------------|
|
|
119
|
+
| `remote_repo` | The remote repository to push to. Use a URL string (no groups) or a group dictionary (see [Using groups](#using-groups)). |
|
|
120
|
+
| `username` | Username for authentication. Defaults to the user part of the `remote_repo` URI, falling back to `git`. |
|
|
121
|
+
| `password` | Password for username/password authentication. |
|
|
122
|
+
| `privatekey` | Path to the private key file. Must be in legacy PEM format (see note below). |
|
|
123
|
+
| `publickey` | Path to the public key file (optional — inferred from `privatekey` + `.pub` if omitted). |
|
|
124
|
+
|
|
125
|
+
Notes:
|
|
126
|
+
- `remote_repo` must not match the name of any local `git` output repo configured under `output`. Use unique names for each.
|
|
127
|
+
- If using SSH key authentication with a passphrase-protected private key, provide the passphrase with the `OXIDIZED_SSH_PASSPHRASE` environment variable.
|
|
128
|
+
- The `privatekey` must be in the legacy PEM format (`BEGIN RSA PRIVATE KEY`), not the newer OpenSSH format (`BEGIN OPENSSH PRIVATE KEY`). See [#1877](https://github.com/ytti/oxidized/issues/1877) and [#2324](https://github.com/ytti/oxidized/issues/2324).
|
|
129
|
+
- To convert an existing key to PEM format, run:
|
|
130
|
+
```shell
|
|
131
|
+
ssh-keygen -p -m PEM -f $MY_KEY_HERE
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Authentication methods
|
|
68
135
|
|
|
69
|
-
|
|
136
|
+
Choose one of the following methods:
|
|
70
137
|
|
|
71
|
-
|
|
138
|
+
| Method | Required keys |
|
|
139
|
+
|-------------------------------|---------------|
|
|
140
|
+
| Username + password | `username` (optional), `password` |
|
|
141
|
+
| SSH key pair | `privatekey`, `publickey` (optional - assumed to be at `privatekey` + `.pub`) |
|
|
142
|
+
| SSH agent | no credentials needed |
|
|
72
143
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
144
|
+
### Configuration examples
|
|
145
|
+
|
|
146
|
+
**Username and password:**
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
hooks:
|
|
150
|
+
push_to_remote:
|
|
151
|
+
type: githubrepo
|
|
152
|
+
events: [post_store]
|
|
153
|
+
remote_repo: git@git.intranet:oxidized/test.git
|
|
154
|
+
username: user
|
|
155
|
+
password: pass
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**SSH key pair:**
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
hooks:
|
|
162
|
+
push_to_remote:
|
|
163
|
+
type: githubrepo
|
|
164
|
+
events: [post_store]
|
|
165
|
+
remote_repo: git@git.intranet:oxidized/test.git
|
|
166
|
+
publickey: /root/.ssh/id_rsa.pub
|
|
167
|
+
privatekey: /root/.ssh/id_rsa
|
|
168
|
+
```
|
|
77
169
|
|
|
78
|
-
The username will be set to the relevant part of the `remote_repo` URI, with a fallback to `git`. It is also possible to provide one by setting the `username` configuration key.
|
|
79
170
|
|
|
80
|
-
|
|
171
|
+
**SSH agent:**
|
|
81
172
|
|
|
82
|
-
|
|
173
|
+
```yaml
|
|
174
|
+
hooks:
|
|
175
|
+
push_to_remote:
|
|
176
|
+
type: githubrepo
|
|
177
|
+
events: [post_store]
|
|
178
|
+
remote_repo: git@git.intranet:oxidized/test.git
|
|
179
|
+
```
|
|
83
180
|
|
|
84
|
-
|
|
85
|
-
* `username`: username for repository auth.
|
|
86
|
-
* `password`: password for repository auth.
|
|
87
|
-
* `publickey`: public key file path for repository auth. (optional)
|
|
88
|
-
* `privatekey`: private key file path for repository auth.
|
|
89
|
-
* NOTE: this key needs to be in the legacy PEM format, not the newer OpenSSL format [#1877](https://github.com/ytti/oxidized/issues/1877), [#2324](https://github.com/ytti/oxidized/issues/2324)
|
|
90
|
-
* To convert a key beginning with `BEGIN OPENSSH PRIVATE KEY` to the legacy PEM format, run this command:
|
|
91
|
-
`ssh-keygen -p -m PEM -f $MY_KEY_HERE`
|
|
181
|
+
### Using groups
|
|
92
182
|
|
|
93
|
-
When using groups
|
|
183
|
+
When using groups and `single_repo` is set to `true` (default) in the
|
|
184
|
+
configuration section output/git, `remote_repo` must be a dictionary mapping
|
|
185
|
+
group names to remote repositories. Groups not listed in the dictionary are
|
|
186
|
+
silently skipped.
|
|
94
187
|
|
|
95
|
-
|
|
188
|
+
Each entry can be either a plain URL string:
|
|
96
189
|
|
|
97
190
|
```yaml
|
|
98
191
|
hooks:
|
|
99
192
|
push_to_remote:
|
|
193
|
+
type: githubrepo
|
|
194
|
+
events: [post_store]
|
|
100
195
|
remote_repo:
|
|
101
196
|
routers: git@git.intranet:oxidized/routers.git
|
|
102
197
|
switches: git@git.intranet:oxidized/switches.git
|
|
103
198
|
firewalls: git@git.intranet:oxidized/firewalls.git
|
|
104
199
|
```
|
|
105
200
|
|
|
106
|
-
...
|
|
201
|
+
...or a dictionary with `url` and `privatekey` to use a per-group SSH key:
|
|
107
202
|
|
|
108
203
|
```yaml
|
|
109
204
|
hooks:
|
|
110
205
|
push_to_remote:
|
|
206
|
+
type: githubrepo
|
|
207
|
+
events: [post_store]
|
|
111
208
|
remote_repo:
|
|
112
209
|
routers:
|
|
113
210
|
url: git@git.intranet:oxidized/routers.git
|
|
@@ -120,33 +217,31 @@ hooks:
|
|
|
120
217
|
privatekey: /root/.ssh/id_rsa_firewalls
|
|
121
218
|
```
|
|
122
219
|
|
|
123
|
-
Both forms can be mixed
|
|
220
|
+
Both forms can be mixed within the same configuration.
|
|
124
221
|
|
|
125
|
-
###
|
|
222
|
+
### Custom branch name
|
|
126
223
|
|
|
127
|
-
|
|
224
|
+
The `githubrepo` hook uses the branch name from the
|
|
225
|
+
[git output](Outputs.md#output-git) as the remote branch name. When the
|
|
226
|
+
repository is first created, Oxidized uses the default branch name from
|
|
227
|
+
`git config --global init.defaultBranch`. The default is `master`.
|
|
128
228
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
push_to_remote:
|
|
132
|
-
type: githubrepo
|
|
133
|
-
events: [post_store]
|
|
134
|
-
remote_repo: git@git.intranet:oxidized/test.git
|
|
135
|
-
username: user
|
|
136
|
-
password: pass
|
|
137
|
-
```
|
|
229
|
+
You can manually rename the branch after Oxidized has already created the
|
|
230
|
+
repository. Be aware that you may break things, so make backups.
|
|
138
231
|
|
|
139
|
-
|
|
232
|
+
To rename the branch after Oxidized has already created the repository:
|
|
140
233
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
234
|
+
1. Stop oxidized.
|
|
235
|
+
2. Back up your oxidized git repository.
|
|
236
|
+
3. Change to your oxidized git repository directory.
|
|
237
|
+
4. Inspect the current branches: `git branch -avv`
|
|
238
|
+
5. Rename the local branch: `git branch -m <NewName>`
|
|
239
|
+
6. Remove the stale remote-tracking reference: `git branch -r -d origin/<OldName>`
|
|
240
|
+
7. Verify the result: `git branch -avv`
|
|
241
|
+
8. Restart oxidized.
|
|
242
|
+
|
|
243
|
+
Oxidized will push to a new remote branch. When everything is fine, you can
|
|
244
|
+
remove the old branch from the remote repository.
|
|
150
245
|
|
|
151
246
|
## Hook type: awssns
|
|
152
247
|
|
|
@@ -179,7 +274,7 @@ Your AWS credentials should be stored in `~/.aws/credentials`.
|
|
|
179
274
|
|
|
180
275
|
## Hook type: slackdiff
|
|
181
276
|
|
|
182
|
-
The `slackdiff` hook posts colorized config diffs to a [Slack](https://www.slack.com) channel of your choice. It only triggers for `post_store` events.
|
|
277
|
+
The `slackdiff` hook posts colorized config diffs to a [Slack](https://www.slack.com) channel of your choice. It only triggers for `post_store` events. The used output must be capable of generating a diff. E.g. file output is not usable while git/gitcrypt will work.
|
|
183
278
|
|
|
184
279
|
You will need to manually install the `slack-ruby-client` gem on your system:
|
|
185
280
|
|
|
@@ -189,16 +284,18 @@ gem install slack-ruby-client
|
|
|
189
284
|
|
|
190
285
|
### slackdiff hook configuration example
|
|
191
286
|
|
|
287
|
+
> Please note that the channel needs to be your Slack channel ID.
|
|
288
|
+
|
|
192
289
|
```yaml
|
|
193
290
|
hooks:
|
|
194
291
|
slack:
|
|
195
292
|
type: slackdiff
|
|
196
293
|
events: [post_store]
|
|
197
294
|
token: SLACK_BOT_TOKEN
|
|
198
|
-
channel: "
|
|
295
|
+
channel: "CHANNEL_ID"
|
|
199
296
|
```
|
|
200
297
|
|
|
201
|
-
The token parameter is a Slack API token that can be generated following [this tutorial](https://api.slack.com/tutorials/tracks/getting-a-token). Until Slack stops supporting them, legacy tokens can also be used.
|
|
298
|
+
The token parameter is a Slack API token that can be generated following [this tutorial](https://api.slack.com/tutorials/tracks/getting-a-token). Until Slack stops supporting them, legacy tokens can also be used. If the token has channels:join permission, the bot will attempt to automatically join the configured channel if necessary.
|
|
202
299
|
|
|
203
300
|
Optionally you can disable snippets and post a formatted message, for instance linking to a commit in a git repo. Named parameters `%{node}`, `%{group}`, `%{model}` and `%{commitref}` are available.
|
|
204
301
|
|
|
@@ -208,13 +305,11 @@ hooks:
|
|
|
208
305
|
type: slackdiff
|
|
209
306
|
events: [post_store]
|
|
210
307
|
token: SLACK_BOT_TOKEN
|
|
211
|
-
channel: "
|
|
308
|
+
channel: "CHANNEL_ID"
|
|
212
309
|
diff: false
|
|
213
310
|
message: "%{node} %{group} %{model} updated https://git.intranet/network-changes/commit/%{commitref}"
|
|
214
311
|
```
|
|
215
312
|
|
|
216
|
-
Note the channel name must be in quotes.
|
|
217
|
-
|
|
218
313
|
A proxy can optionally be specified if needed to reach the Slack API endpoint.
|
|
219
314
|
|
|
220
315
|
```yaml
|
|
@@ -223,7 +318,7 @@ hooks:
|
|
|
223
318
|
type: slackdiff
|
|
224
319
|
events: [post_store]
|
|
225
320
|
token: SLACK_BOT_TOKEN
|
|
226
|
-
channel: "#
|
|
321
|
+
channel: "#CHANNEL_ID"
|
|
227
322
|
proxy: http://myproxy:8080
|
|
228
323
|
```
|
|
229
324
|
|