Recently I decided that I would backup the network and device configurations for the gear at my work, because we didn’t have any backups more recent than 2018. I started off trying to find some automated solution in the devices themselves but unfortunately only one of them was able to be backed up in this way. I took some manual backups and tried to be happy with that but the problem gnawed at my brain for a bit till I finally looked for a proper automated solution that would work with the majority of our random assortment of devices.
I initially looked at using RANCID however it didn’t support CheckPoint Gaia devices out of the box and I didn’t much feel equipped to create my own check. It was around this time that I had Oxidized suggested to me and I started looking into and installing it.
All went smoothly with the installation by following the official Oxidized instructions. My configurations would download with no issues when I was running directly from the command line during testing. I ran into real issues when I started looking into how to daemonize Oxidized. It seemed like there wasn’t a very good set of instructions for CentOS specifically. I did find a blog post that covers it off really well for Ubuntu and I did actually follow this one for the Oxidized user tasks. In the end, I did a lot of searching and a lot of trying different things (and removing things I tried to see which ones I could keep), before finding the solution outlined here.
With that said let’s step through the config I did.
Installation
This config is simply copied from the GitHub page and is pretty standard stuff.
|
|
User Configuration
The following is taken from the Ubuntu guide above.
|
|
The first line here is self-explanatory.
The second line changes the default shell of the Oxidized user to disallow logins, this is a security measure so that you cannot su to the user. It may be useful to leave this line out for initial testing.
The third line creates (if it does not already exist), the oxidized folder in /opt/ as well as subfolders output, config, and oxidized. Basically just creating the basic folder structure that Oxidized will put in your home directory if allowed to default.
The fourth line changes the home directory of the oxidized user to the folders we just created. This is a good way to ensure that if Oxidized decides to default to the home directory, it defaults somewhere sensible.Ā
Symlinks, Service File and Shared Libraries
Oxidized requires Ruby 2.3 and the version that ships with CentOS 7.6 is Ruby 2.0. This obviously poses a bit of a problem when you install the version from the SCL repository. To fix this, symlink the newer version to /usr/bin/ruby to use this as the default version like the below.
|
|
This will allow the service to act as though the scl enable rh-ruby23 bash command was run by virtue of it using the newer binary for Ruby. Obviously do not do this if you need to maintain backwards compatibility with Ruby 2.0.0, in this case I would suggest using the an environment file calledĀ /etc/sysconfig/oxidized and including this in your systemd config under [Service] EnvironmentFile=/etc/sysconfig/oxidized. In the file, you would add the following line of configuration.
|
|
At this point I also symlinked /usr/local/bin/oxidized to /opt/rh/rh-ruby23/root/usr/local/bin/oxidized to make my service file a little cleaner.
From here, I created the service file under /lib/systemd/system/oxidized.service and added the below:
|
|
Simply, when the machine boots, Oxidized will wait for the network module to be completely loaded before executing the program located in /usr/local/bin under user oxidized, utilising the environment file to set the required environment variables.
Finally, I added /opt/rh/rh-ruby23/root/usr/lib64 as a line inĀ /etc/ld.so.conf. After this, I ran the ldconfig command to ensure that the path was updated and added.
Oxidized Config
At this point, all the bones are in place and Oxidized will start correctly and generate a sample configuration in the Oxidized user’s home directory (/opt/oxidized). The next logical step is to create a config file so that you can start importing your configs. This is a lot more arbitrary, but I went with a CSV source to import my devices as I only had a relatively small number of them. If you go for the CSV route, you will need to create a router.db file which will be mapped in the main config file.
The below is a sample of what my config looks like. The config is in YAML format and the # symbol is a comment. I will add comments to each line in order to try to explain what each line/section does. The config is located in the /opt/oxidized/.config/oxidized folder and is simply called config.
|
|
Once you’ve got all your configuration together, you should be able to start the service and see the magic happen. To confirm that everything is working as expect, you can go to the website that is presented on port 8888 and you should see all your devices starting to pull configs.