Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity and support for distributed, non-linear workflows. Let’s see how to deploy splunk addons and apps using git.

The following diagram shows the workflow of the various processes between the local computer, git server and our deployment server.

Phase 1: This is the phase that happens in the individual local computer.
  • Install git bash
https://git-scm.com/downloads
  • Create a directory that you want your git repository to reside and initialize your git.
Git init
  • Login to your git bash and clone the remote repository to your local machine.
Git clone
  • Create your git branch
Git branch
  • Checkout your branch. Checking out your branch basically means switching your branch from master to your branch.
Git checkout
  • Now make changes to the conf files that need to be changed. After this time to add those changes.
Git add .
  • Before pushing your branch always check its status.
Git status
  • After checking the status commit your branch.
Git commit –m ‘message’
  • After your commit is successful time to push your branch.

        Git Push origin

Phase 2: This is the phase that happens in the Git server.
  • After the Push request is done a Pull request needs to be created in the Git web UI
  • Click on the new pull request to create it and the pull request is then verified and accepted by the admin.
Phase 3: This is the phase that happens in the Deployment Server.
  • When the pull request has been approved by the admin only then will the changes be reflected in the git server
  • When these changes are reflected, a git pull command is run in the deployment server using cron schedule.
  • This cron schedule runs the git pull command and the changes that are reflected in the git server are now shown in the staging server that is made in the deployment server.
  • A staging server is made by going to the desired folder and running the git init command.
  • After the cron is run and the changes are reflected in the staging server a git hook is triggered.
  • Git hooks are scripts that Git executes before or after events such as: commit, push, and receive. Git hooks are a built-in feature – no need to download anything. Git hooks are run locally. 
  • We create a git hook named post-merge, add our script into it and make it executable.
  • When the git hook gets triggered, the changes made in the staging server gets copied and stored into our deployment server in its etc/deployment-apps folder.
  • Here, after the changes can be seen in etc/deployment-apps folder a cron schedule is run triggering the reload server class command and the add-ons and apps present in the etc/deployment-apps folder are pushed to their respective clients.
If you are still facing issue regarding deploy splunk addons and apps using git Feel free to Ask Doubts in the Comment Box Below and Don’t Forget to Follow us on 👍 Social Networks, happy Splunking >😉