Git Cycle

Git Cycle is a process that I created to help in small-ish environments where Linux servers are often unique little snowflakes and the admins are accustomed to making changes on the fly rather than through config management. By using the Git Cycle, I only had to convince the admins to git add and git commit the config files they were changing on those systems.

I developed this methodology using SaltStack as my config management system, but there’s no reason why it can’t be used in other systems. However, everything here is based on using SaltStack.

Overview Example:
1. An Admin makes a change in the nrpe config file, /etc/nagios/nrpe.cfg
2. The Admin then git adds and commits /etc/nagios/nrpe.cfg
3. From the Salt Master, the script is kicked off via crontab.
4. It connects to this server and pulls the changes from a git repo
5. The next time I execute a state run in the config management system, the changes that were found and pulled back will be used, thus avoiding overwriting the changes that the admin made.

How it works:

On the Salt Master we need to do some setup work:

└── Minion1
├── Minion2

Running the git_cycle/init.sls SaltStack state file on a Minion does several things:

With all that done, go through and git add and commit some files on your minion.

Then, back on the Salt Master as the git user:

# Drop in the nrpe.cfg file specific for this host. Or if its a new host, just use the default
{% set hostname = salt.grains.get('id') %}
- name: /etc/nagios/nrpe.cfg
- source:
- salt://hosts/{{ hostname }}/etc/nagios/nrpe.cfg
- salt://nrpe/nrpe.cfg
- makedirs: True
- user: root
- group: root
- mode: 644

Originally published at on December 15, 2015.



Climber, surfer, yogi, dad who does some IT on the side to get by.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aleksandr Rain

Climber, surfer, yogi, dad who does some IT on the side to get by.