Affichage des articles dont le libellé est nagios. Afficher tous les articles
Affichage des articles dont le libellé est nagios. Afficher tous les articles

mardi 3 novembre 2020

Gitops & git tracking modifications & Nagios


Context : 

I needed to have all my nagios files on my computer to be able to run some python scripts trying to figure out what refactoring needed to be done, and identifying gaps in the configuration I inherited.

I took that opportunity to version all our nagios configuration files, with a git repository configured at the /usr/local/nagios/etc level.


That proved itself useful to gain some confidence that we're not going to loose anything.


Initial idea was taken from :  


Script to automatically commit changes done in Nagios and push them to the central repo. 
NB : still a few things to investigate, but ...

auto-git-commit-push.sh

#!/bin/bash
cd /usr/local/nagios/etc \
&& /bin/git pull \
&& /bin/git add -A \
&& /bin/git commit -m "updated nagios dynamic files $(date) -- automatic commit" \
&& /bin/git push origin master \
&&  /bin/git pull \
&& if ! $(grep -lr '<<<<<<<' . ) ; then grep -lr '<<<<<<<' . | xargs git checkout --ours; ./$0; fi


identified issues :
* why so many conflicts while we are only modifying and thus commiting files locally and pushing them !?
* I thought about putting in place a workflow that would take the files from the git repository and push them to nagios import with some git hooks, but I eventually found the Nagios REST API which is way easier to delivery to the team handling those creations : just 1 script per use-case and they'll do everything at once.