Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Puppet for Containerization
Puppet for Containerization

Puppet for Containerization: Manage, orchestrate, and deploy containers with Puppet

By Scott Coulton
€28.99 €19.99
Book May 2016 222 pages 1st Edition
eBook
€28.99 €19.99
Print
€37.99
Subscription
€14.99 Monthly
eBook
€28.99 €19.99
Print
€37.99
Subscription
€14.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : May 16, 2016
Length 222 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781785883286
Vendor :
Docker
Table of content icon View table of contents Preview book icon Preview Book

Puppet for Containerization

Chapter 1. Installing Docker with Puppet

In this chapter, we will be setting up our development environment so that we can develop our first container application. To do this, we will use Vagrant. In our first topic, we will look at how to install Vagrant. We will look at how a Vagrantfile is constructed using Puppet as the provisioner. We will also look at how to get Puppet modules from the Puppet Forge using a puppetfile and r10k. In the last topic, we will install Docker on a Centos 7 box with Puppet. The following are the topics that we will cover in this chapter:

  • Installing Vagrant

  • An introduction to Puppet Forge

  • Installing Docker

Installing Vagrant


You may ask, why are we using Vagrant for our development environment?

Vagrant is a must-have for Puppet development. The idea that you can spin up environments for development locally in minutes was a revolution in Vagrant's early releases. The product has now grown in leaps and bounds, with multiple provisioners such as Chef and Salt. Paired with multiple virtualization backends such as VirtualBox, VMware Workstation/Fusion, KVM, and we are going to use VirtualBox and Puppet as your provisioner.

The installation

Let's install Vagrant. Firstly, we will need our virtualization backend, so let's download and install VirtualBox. At the time of writing, we use VirtualBox 5.0.10 r104061. If that's outdated by the time you read this book, just grab the latest version.

You can download VirtualBox from https://www.virtualbox.org/wiki/Downloads. Choose the version for your OS, as shown in the following screenshot:

Once the package is downloaded, follow the given installation process for your OS.

VirtualBox

Follow these steps to install Vagrant on Mac OSX:

  1. Go to your Downloads folder and double-click on VirtualBox.xxx.xxx.dmg. The following installation box will pop up:

  2. Then, click on VirtualBox.pkg. Move on to the next step, as shown in the following screenshot:

    The installer will then check whether the software is compatible with the Mac OSX version.

  3. After this, click on Continue. Once the check is successful, we can move on to the next step:

  4. We then choose the default location for the installation and click on Install.

  5. Then, enter your admin password and click on Install Software:

The installation is now complete. The following screenshot shows what the screen looks like after completing the installation:

Now that we have the virtualization backend, we can install Vagrant:

Note

At the time of writing this book, we are going to use Vagrant 1.7.4; if that is no longer the latest version, please grab the latest one. You can find this version of Vagrant at https://www.vagrantup.com/downloads.html. Again, download the installation package for your OS.

Vagrant

Here, we are just going to complete a standard installation. Follow these steps to do so:

  1. Go to the folder in which you downloaded vagrant.1.7.4.dmg and double-click on the installer. You will then get the following pop up:

  2. Double-click on vagrant.pkg.

  3. Then, in the next dialogue box, click on Continue:

  4. Then, click on the Install button:

  5. Enter your admin password in the given field:

  6. Once the installation is complete, open your terminal application. In the command prompt, type vagrant. After this, you should see the following screenshot:

Vagrantfile

Now that we have a fully working Vagrant environment, we can start with and look at how Vagrant works and how we are going to provision our machines. As this book is not about Vagrant, we won't be writing a Vagrantfile from scratch. Instead, I have created a Vagrantfile that we will be using throughout the book:

Note

You can download or Git pull the repo from https://github.com/scotty-c/vagrant-template.

Let's look at the Vagrantfile construct:

As you can see from the preceding screenshot, the Vagrantfile is actually a Ruby file. As it is Ruby, it opens up a world of opportunities for us to make our code elegant and efficient. So, in this Vagrantfile, we have extracted all the low-level configurations and replaced them with a few parameters. Why are we doing this? The reason is to split up our logic from our configuration and also iterate our configuration in order to stop replication of our code. So, where is all the configuration stored? The answer is in the servers.yaml file. This is where we set the vagrant box that we want to deploy, the number of CPUs for the box, the internal network's IP, the hostname, the forwarded ports between the guest and host, and the RAM and shell provider for bash commands that we need to get the environment ready for Puppet to run, for example, downloading modules and their dependencies from the Puppet Forge:

The benefit of this approach is also that any developer using a Vagrantfile does not need to actually modify the logic in the Vagrantfile. They only need to update the configuration in servers.yaml. As we go through the book, we will work with the other files in the repository, such as Puppetfile, hieradata, and manifests. Now that we have set up our Vagrant environment, let's look at how to get our Puppet modules from the Puppet Forge.

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.

Installing Docker


In this topic, we will put together all the configuration from our Vagrant repo and knowledge of the Puppet Forge to create the Docker environment.

Setting our manifests

The first thing that we need to do to install Docker is set our manifest to include the Docker class on our node. To do this, let's go to our Vagrant repo. In the repo, there is a file in the manifests directory called default.pp. We need to edit the file to include the Docker class node 'node-01' { include docker}. We can now save the file, and we are ready to run our environment.

The first step is to open our terminal and change to root of the Vagrant repo. Then, we need to enter the vagrant up command:

This will now provide us with our CentOS 7 box. Install r10k and then run Puppet and apply the Docker class. This will take about 4 minutes depending on your laptop and network connection. If the box was provisioned successfully, you will see the following output:

We can also verify that the Docker installation was successful by logging in to the box via SSH. We will do that with the vagrant ssh command. Once we are in, we will sudo up to root (sudo -i). Now, let's just check whether Docker is installed with the docker command.

You will see the following output on the terminal:

Summary


In this chapter, we covered how to create a development environment with Docker using Puppet. We looked at how to install Vagrant and VirtualBox. Then, we looked at the Puppet Forge, how to search for modules and their dependencies. We then took the dependencies and mapped them to a puppetfile. We briefly touched on r10k, which is our transport mechanism from the Puppet Forge to our environment. Then, we built our environment with Puppet.

In the next chapter, we'll take a look at how to access Docker Hub and pull public images.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • This is the first book that focuses specifically on the combination of containerization and configuration management tools as the landscape for system administration changes
  • It demonstrates to administrators how to seamlessly integrate containerization without disrupting their entire system
  • It provides a canny way for you to grow your tool kit and embrace new tech such as Docker while building on your existing skill set

Description

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.

What you will learn

[*]Write Puppet modules to build Docker [*]Create Docker Compose templates with .erb files [*]Get to know the architecture of Docker schedulers [*]Create a Docker network and service discovery framework [*]Build a fully functional Docker scheduler with Puppet [*]Make Docker production ready with Puppet

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : May 16, 2016
Length 222 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781785883286
Vendor :
Docker

Table of Contents

16 Chapters
Puppet for Containerization Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
About the Reviewer Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
Installing Docker with Puppet Chevron down icon Chevron up icon
Working with Docker Hub Chevron down icon Chevron up icon
Building a Single Container Application Chevron down icon Chevron up icon
Building Multicontainer Applications Chevron down icon Chevron up icon
Configuring Service Discovery and Docker Networking Chevron down icon Chevron up icon
Multinode Applications Chevron down icon Chevron up icon
Container Schedulers Chevron down icon Chevron up icon
Logging, Monitoring, and Recovery Techniques Chevron down icon Chevron up icon
Best Practices for the Real World Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.