Book Image

Puppet for Containerization

By : Scott Coulton
Book Image

Puppet for Containerization

By: Scott Coulton

Overview of this book

This book teaches you how to take advantage of the new benefits of containerization systems such as Docker, Kubernetes, Docker Swarm, and Docker UCP, without losing the panoptical power of proper configuration management. You will learn how to integrate your containerized applications and modules with your Puppet workflow. You will also understand how to manage, monitor, and orchestrate hosts to keep deployed containers running seamlessly. With the help of this book, you can efficiently automate and document with containers, as a part of your system. The book will also cover use cases of deploying Puppet within a containerized environment.
Table of Contents (16 chapters)

Welcome to the Puppet Forge


In this topic, we will look at how to find modules from the Puppet Forge. Then, we will see how to pull them with their dependencies using a puppetfile and r10k. This will set us up for our last topic, Installing Docker with Puppet.

The Puppet Forge

One of the great things about puppetlabs and their products is the community. If you ever get a chance to attend PuppetConf or a Puppet Camp, depending on where you live, I would really recommend you to attend it. There will be a wealth of knowledge there and you will meet some really great people.

The Puppet Forge is a website that puppetlabs runs. It is a place where other Puppet developers publish modules that are ready to use. You might be asking, what about GitHub? Can't you get modules from there? Yes, you can. The difference between the Puppet Forge and GitHub is that the Puppet Forge is the stable, releasable version of the module, whereas GitHub is the place to contribute to the module, that is, a place to create pull requests.

Note

You can find the Puppet Forge at https://forge.puppetlabs.com/.

The following screenshot shows the home page of Puppet Forge:

Now that we have been introduced to the Puppet Forge, let's use it to find our Docker module that we will be using to build our environment.

Note

We are going to use the garethr/docker Docker module, which you can find at https://forge.puppetlabs.com/garethr/docker.

Now that we have selected our module, we can move on to setting up our puppetfile:

Creating our puppetfile

In the previous topic, we cloned our Vagrant template using Git. In that repo, there is also a puppetfile. A puppetfile is used as a control file for our modules. It will list all the modules that we need (in this instance, just to install Docker). r10k will then reference the puppetfile and pull the modules from the Puppet Forge into our environment's directory.

As modules have dependencies, we need to make sure that we capture them in our puppetfile. For the Docker module, we have three dependencies: puppetlabs/stdlib (>= 4.1.0), puppetlabs/apt (>= 1.8.0 <= 3.0.0), and stahnma/epel (>= 0.0.6), as shown in the following screenshot.

Now, we know all the modules that we need to build a Docker environment. We just need to add them to our puppetfile.

The following screenshot is an example of what the puppetfile should look like:

Now, when we run vagrant up, r10k will pull the modules from the Puppet Forge. We invoke r10k on line 13 of servers.yaml with the r10k puppetfile install—verbose command. The following screenshot shows the output of this command:

If we are successful, the terminal will provide the following output:

Now that we have our puppetfile set up, we can install Docker.