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.
- Install git bash
- Create a directory that you want your git repository to reside and initialize your git.
- Login to your git bash and clone the remote repository to your local machine.
- Create your git branch
- Checkout your branch. Checking out your branch basically means switching your branch from master to your branch.
- Now make changes to the conf files that need to be changed. After this time to add those changes.
- Before pushing your branch always check its status.
- After checking the status commit your branch.
- After your commit is successful time to push your branch.
Git Push origin
- 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.