Provisioning a Packer Image with Puppet Server

30 minutes
  • 2 Learning Objectives

About this Hands-on Lab

Packer lets us create machine images for a variety of platforms through code. Part of the image creation process involves provisioning the machine, which can be done with a variety of provisioners, including Puppet. Packer is even able to connect to an existing Puppet Server and use the modules there to provision the resulting image. In this lab, we’ll do just that to set up a web server image that hosts our company’s website.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Add the Provisioner
  1. Move to packer/bookapp.
  2. Open the provided packer.json file.
  3. To begin, we want to update the existing shell provisioner — the puppet-server provisioner does not install the Puppet agent, so we’ll need to do this here. We’ll also want to ensure our remote can talk to the Puppet Server by updating /etc/hosts.
  4. Next, add the needed file provisioner block.
  5. Finally, add the puppet-server provisioner itself.
Test the Build
  1. Update the file with the provided access key, secret key, and subnet ID.
  2. Save and exit the file.
  3. Test the build.

Additional Resources

You have been tasked with building a Packer template for a new project. The resulting image build needs to provision an image that will host a website on an Ubuntu 20.04 server. Since your existing website is provisioned through Puppet via a Puppet Server, you wish to leverage that Puppet Server to provision your remote instance.

A basic template that can provision an Ubuntu 20.04 server on AWS has been provided in the /home/cloud_user/packer/bookapp directory.

The Puppet Server is located at for use; it is set to auto-sign any server with a hostname ending in .ec2.internal.

Additionally, note the defined Puppet modules for this build will only configure Apache; the provided website directory should be uploaded to /var/www/html/bookapp on the remote prior to using the Puppet Server provisioner.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?