Home  >  Blog  >   Puppet  > 

Repository Management - Puppet

Rating: 4


Git Repository Management

Using git to manage puppet modules

Git has become a very popular version control system in recent years. We can use git to version control our module and will be the input to our development pipeline. Initially, git may seem rather easy and trivial; however, it can quickly get complicated.

Learn how to use Puppet, from beginner basics to advanced techniques. Enroll for Free Puppet Training Demo!

We will begin by turning our local module into a local git repository. Most distributions already have git installed, but Ubuntu does not. To install git on Ubuntu run the following command:

$ apt-get install git

Once git is installed, create the local repository in the root of the module directory structure:

$ git init

Create a gitignore file so that we don’t track unnecessary files and directories.

$ vim .gitignore

Add the following contents to the file:

Finally, update the local git repository with our first commit

$ git add .
 $ git commit -m “initial commit”

You can look at the git with the git log command:

$ git log

This shows you our initial commit

Having a local git repository is nice and allows version control, but we more than likely will work in a team and will need something a little more enterprise level. You could use a central git repository using the standard git command line or you could use one of several web based git servers like GitLab or GitHub Enterprise if you are interested in deploying to your local environment. If you are just interested in testing your puppet code automatically then GitHub.com and several other alternatives can be used.

Here,  let us use a locally installed GitLab Server since we are interested in deploying to our environment automatically using continuous integration automation.

Login to your GitLab server and create a new repository by clicking on Create Project. Then fill out the form like the following:

Finally, click on Create project.

Enable access to GIT REPOSITORY

Access to your new GitLab repository can occur in several ways. We will use SSH keys to make the process smooth. Run the following command to generate an SSH key on your development system.

$ ssh-keygen -t rsa

This will generate a key ~/.ssh/id_rsa

Show the contents of this file and copy the key to your clipboard.

$ cat ~/.ssh/id_rsa.pub

Paste this key into GitLab by clicking your username in the lower-left corner then clicking on Profile settings. Then on the left click on SSH keys and the Add SSH key button. Paste the key into the Key field. Click Title field and it should automatically populate. If it doesn’t, then simply put in any title you want to represent this key, like your development system’s hostname. Finally, click on Add key.

                                Frequently Asked Puppet Interview Questions & Answers

Upload module to git

Go to the top of the repository page and get the SSH URL for the repository. This will look like the picture below:

Back on your development system, run the following command to add the remote repository to your local repository:

$ git remote add origin

You can now push your local repository to the origin remote repository which is our GitLab server.

$ git push origin master

You will see git push the repository to GitHub.

You will now see your module contents listed in your GitLab Project repository. We have the input to our workflow. Changes to this repository will kick off our continuous integration server which will perform the tests we created automatically and deploy our module to our puppet master.

MindMajix Youtube Channel

Configure the WebHook for Jenkins

Go to the project settings page, then click on WebHooks and add a new webhook like below:

web hooks 

Explore Puppet Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!


Join our newsletter

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
Puppet TrainingMar 28 to Apr 12
Puppet TrainingApr 01 to Apr 16
Puppet TrainingApr 04 to Apr 19
Puppet TrainingApr 08 to Apr 23
Last updated: 26 March 2023
About Author
Remy Sharp
Ravindra Savaram

Ravindra Savaram is a Content Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.

Recommended Courses

1 /15