- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
Adding Files to a Packer Build
Packer lets us create machine images for a variety of platforms through code. Part of this involves provisioning an initial machine to match our desired state. In this hands-on lab, we use both the `file` and `shell` provisioners to prepare a Packer template for a web instance.
Lab Info
Table of Contents
-
Challenge
Add the File Provisioner(s)
Please give the lab an extra three minutes before starting the lab activity. After that, log in to the provided Ubuntu Workstation server using the credentials provided.
Note: There are multiple ways to complete this lab. We'll be using two
fileprovisioner blocks objects. You could alternatively upload the entirefilesdirectory in one object and then move all files via script.Create an object to move the website files to
/var/www/html/bookapp. Place it between the twoshellprovisioners.Add a second
fileobject to move the Apache configuration to/tmp/. Since/etc/apache2requires elevated privileges, we'll need to move thebookapp.conffile from/tmp/via shell provisioner. -
Challenge
Update the Scripts
We'll need to update both the initial inline
shellprovisioner and thescriptsprovisioner that follows ourfileobjects.Update the
inlinelist to create the/var/www/htmldirectory and grantubuntutemporary ownership of it.Then, update the
webdeploy.shscript itself to move ourbookapp.confApache configuration. -
Challenge
Test the Build
Return to the
packer.jsonfile and update the variables for access key, secret key, and subnet ID. Save and exit, and then test the build.
About the author
Real skill practice before real-world application
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.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.