Manage Configuration Changes with Git
This content was originally written on the OpenNMS Discourse forum (see Managing Configuration Changes with Git).
If you want to manage your configuration files with Git but haven’t used it for version control before, GitHub’s Using Git tutorial covers the basics. You can also read Developing with Git on the OpenNMS Discourse forum.
If you have an existing OpenNMS Horizon installation, check for the
If your Horizon environment does not have this directory, you will need to upgrade to a version that does.
Remember to stop Horizon before changing files in the
Run the following code to prevent breaking the link between folders:
cd /usr/share/opennms mv etc etc_bad ln -s /etc/opennms etc
Run the following code to move your customized configuration files to
/etc/opennms.bak and replace them with the contents of
mv /etc/opennms /etc/opennms.bak cp -pR /usr/share/opennms/share/etc-pristine /etc/opennms
Run the following code to move your
$OPENNMS_HOME/etc files to a safe place, then copy
etc-pristine to the
mv $OPENNMS_HOME/etc $OPENNMS_HOME/etc.bak cp -pR $OPENNMS_HOME/share/etc-pristine $OPENNMS_HOME/etc
On RPM-based installations, the pristine configuration files are located in
Run the code below to turn your
etc directory into a Git repository and add the pristine files as your first commit:
cd $OPENNMS_HOME/etc git init cat << EOF > $OPENNMS_HOME/etc/.gitignore foreign-sources/ imports/ examples/ include *.dpkg-old opennms-upgrade-status.properties libraries.properties pluginManifestData.xml org.opennms.features.datachoices.cfg include configured EOF git add . git commit -m "Initial checkin of OpenNMS x.x.x configuration."
x.x.x in the last line with your current Horizon version.
Run the code below to create a new branch in your repository:
cd $OPENNMS_HOME/etc git branch local-modifications git checkout local-modifications
You can now edit your configuration files as you normally would. If you previously backed up your modified configuration files, you can run this code to restore them:
rsync -avr $OPENNMS_HOME/etc.bak/ $OPENNMS_HOME/etc/
Any time you want to save your changes to the
etc directory, run this code to commit them to the branch you created (in this case,
cd $OPENNMS_HOME/etc git add . git commit -m "Added initial discovery ranges."
When you are finished modifying your configuration files, you can start Horizon.