Cademy logoCademy Marketplace

Course Images

Automating Image Creation with HashiCorp Packer for DevOps

Automating Image Creation with HashiCorp Packer for DevOps

🔥 Limited Time Offer 🔥

Get a 10% discount on your first order when you use this promo code at checkout: MAY24BAN3X

  • 30 Day Money Back Guarantee
  • Completion Certificate
  • 24/7 Technical Support

Highlights

  • On-Demand course

  • 7 hours 11 minutes

  • All levels

Description

This is a comprehensive course for using HashiCorp Packer in your organization. The course teaches you about using HCL2 to create your Packer templates, the new standard moving forward. Explore the core HashiCorp Packer components and access hands-on labs you can perform in your environment.

HashiCorp Packer is an open-source tool for creating identical machine images for multiple platforms from a single source configuration. Packer is lightweight, runs on every major operating system, and is highly performant, creating parallel machine images for various platforms. The course begins with a detailed introduction to HashiCorp Packer and the problems it solves. It illustrates use cases and examples. We will then explore writing Packer templates using HCL2 (the new standard for Packer 1.7+). You will learn about different builders, using variables, provisioners, post-processors, and code organization. We will integrate automation pipelines, secret management, and terraform. We will advance to integrate HashiCorp Packer with other automation tools, such as HashiCorp Terraform, HashiCorp Vault, and GitLab CI/CD. Using Packer, we will build images on multiple public cloud platforms and VMware images. Upon completing the course, you can use HashiCorp Packer in your organization independently. You will use HCL2 to create your Packer templates and automate your machine images across multiple platforms-a critical skill to enabling automation in your environments. All resources are available at: https://github.com/PacktPublishing/Automating-Image-Creation-with-HashiCorp-Packer-for-DevOps

What You Will Learn

Understand the core components and functions of HashiCorp Packer
Learn to automate the creation of machine images
Create real-world solutions with HashiCorp Packer using HCL2
Gain hands-on experience with Packer with demonstration labs
integrate Packer with Terraform, HashiCorp Vault, and GitLab CI/CD
Write Packer templates using HCL2 (the new standard for Packer 1.7+)

Audience

This course is designed for DevOps engineers looking to simplify the management of images in one or more platforms, automation engineers who want to create an image factory, engineers who want to easily manage one or many golden images for their workloads, and system administrators responsible for image and operating system maintenance and patching. The prerequisites include no Packer experience necessary and a basic understanding of one or more infrastructure platforms (AWS, Azure, VMware, OpenStack). Linux or Windows OS scripting is desirable but not required.

Approach

This course includes in-depth lectures on all of the core HashiCorp Packer components and included labs. You get access to hands-on labs that you can perform in your environment, taking a hands-on approach, the best way to learn. Each lesson includes a mind map of the topics and multiple labs to demonstrate the topics at hand.

Key Features

Explore Packer, an open-source tool to create machine images for multiple platforms from a single source * Understand the core components and functions of Packer and create real-world solutions with HCL2 * Build images on multiple public cloud platforms and build VMware images using HashiCorp Packer

Github Repo

https://github.com/PacktPublishing/Automating-Image-Creation-with-HashiCorp-Packer-for-DevOps

About the Author

Bryan Krausen

Bryan Krausen is an IT consultant with over 20 years of experience in enterprise IT. He specializes in Amazon Web Services and HashiCorp tools. Bryan focuses on cloud design and facilitates customer workshops that define business and technical requirements to allow businesses to deliver applications on the AWS cloud platform. He was the first individual to earn the HashiCorp Vault Expert partner certification. Bryan has deployed and assisted with adopting the HashiCorp Vault into many Fortune 1000 companies. He delivers lectures at community events, such as HashiConf (2019 to 2022), HashiTalks (2019 to 2020), and many HashiCorp user groups across the mid-west and eastern US.

Course Outline

1. Course Introduction

This section introduces the course and covers a few general concepts about HashiCorp Packer. It also takes us through an outline of the concepts covered in the course and what you will learn.

1. Introduction

This video outlines the content of the course and provides an introduction to the HashiCorp Packer, its features, pros and cons, and the concepts covered through the course. You will also learn about the other HashiCorp products that we will work with.


2. Introduction to HashiCorp Packer

This section focuses on providing a detailed overview of HashiCorp Packer. We will understand what Packer is and its primary use cases. You will learn to install Packer and understand the core components of the software. We will interact with Packer and understand the workflow.

1. Introduction to Packer - Section Overview

In this video, we will thoroughly understand Packer and its uses. You will learn about installing and using Packer and its primary uses. We will also examine the core components and Packer workflow.

2. Why Use Packer?

In this video, we will understand Packer and why we use Packer, why businesses use Packer and learn about the evolving architecture of Packer, organizations moving over to cloud services, the use of containers, Kubernetes, and the development of Packer.

3. Hello, Packer!

This overviews the entire HashiCorp suite of tools and describes products such as Terraform, Vault, Consul, Nomad, Waypoint, Boundary, Packer, and Vagrant. It then provides a detailed introduction to the features of Packer.

4. Core Components of Packer

In this video, you will learn more about the core components that make up the Packer solutions tool, which builds images using templates created using JSON or HCL2.

5. Installing Packer

After understanding Packer and its core components and use features, we will examine the installation process of HashiCorp Packer and any configuration/settings required to begin using the tool.

6. Demo - Installing Packer

In this lab demonstration video, we will focus on installing Packer. The video provides the details on where to obtain the installation package. The video takes you through how to install, validate, and enable autocompletion for Packer CLI.

7. The Packer Command Line

After installing Packer on our local machine, you will learn to interact with Packer, which uses the primary and only way, the command line interface (CLI), as Packer does not have a user interface or an API we can interact with.

8. Hands-On Lab - The Packer Command Line

In this demonstration lab, we will explore the Packer command line. We will explore the Packer CLI and the Packer version, enable autocompletion for Packer CLI, explore subcommands and flags, and the Packer format.

9. The Packer Workflow

In this lecture, we will examine the Packer workflow. We will explore an example workflow built on AWS to understand the process, including building a HCL2 template, a Packer, a provision instance, running provisioners, creating and registering an AMI, and destroying a model.

10. Demo - The Packer Workflow

In this lab demonstration video, we will walk through the Packer workflow, building an example. We will work on creating a workflow using AWS. We will create a Packer builder on AWS and a security group. You will learn to create an instance and an AMI for your workflow.

11. Introduction to Packer - Section Recap

This video recapitulates the Packer introduction, features, advantages, use case scenario, the Packer core components, installing and configuring Packer, and creating a Packer workflow.

12. Installing Packer on Windows

You will learn to install Packer on Windows in this lab demonstration video. We will download the resources from the public repository on GitHub from the link provided by the instructor.

13. Installing Packer on Mac

In this lab demonstration, you will learn to install Packer on MacOS. We will first establish the Homebrew package manager to install Packer on the MacOS machine.


3. Writing Packer Templates

This section focuses on writing Packer templates. You will learn to use HCL syntax and convert JSON templates to HCL. We will work with Packer's core components with HCL and write a few templates.

1. Writing Packer Templates

In this video, you will learn about the Packer template, which consists of declarations and commands, such as what plugins to use, configuring the plugins, and the order in which to run the plugins.

2. HCL Syntax

In this lesson, you will learn about writing templates using the HCL syntax, which is in the form of blocks. We will define the components of the league and let Packer know the references in our blocks, and use single or multiple Packer templates.

3. Hands-On Lab - Converting JSON Templates to HCL

This lab demonstration video will walk us through migrating a JSON template to HCL2 format. We will begin with creating a JSON template, then run through creating an HCL2 command and convert it to a pkr.hcl template.

4. Working with Packer's Core Components in HCL

After learning to write specific HCL syntax for the Packer templates, we will work with the core components of Packer and how the core components fit in with the HCL format, including the source, provisioner, builder, postprocessors, communicators, and variables.

5. Hands-On Lab - Writing Packer Templates

In this lab demonstration, we will create our first Packer template. We will create a source block, validate the Packer template, create a building block, and build a new image using Packer.


4. Builders

This section focuses on builders used in Packer. We will understand AWS builders, Azure machine images with Packer, Google Compute machine images with Packer, VM templates, and finally, build images in multiple clouds.

1. Introduction to Builders

In this video, we will understand the concept of a Packer builder responsible for creating machines and generating images. More than one builder can be specified in a template. We will compare the different builder models available.

2. Demo - Building AWS AMIs with Packer

In this lab demonstration, we will walk through building the AWS AMI with Packer. Based on our use case, we will create an EBS-backed AMI and an instance store on AMI.

3. AWS Builders

In this video, we will go over the various AWS builders. We will explore four different builders and see how Packer builds on each of these platforms and the differences in the processes involved.

4. Demo - Building Azure Machine Images with Packer

In this lab demonstration video, we will look at a demonstration of how to use Packer to build images in the Packer cloud. We will be working on the Azure-Arm builder as the use case for the lesson.

5. Demo - Building Google Compute Machine Images with Packer

This demonstration lab will demonstrate how to utilize Packer to build machine images in the Google cloud platform. We will use the Google Compute Engine to build the images for this demo.

6. Demo - Building VMware Templates with Packer

In this demonstration lab, we will understand VMware and showcase how to utilize HashiCorp Packer to build images within a VMware environment. You will learn to create templates using VMware.

7. Hands-On Lab - Building Images in Multiple Regions

In this hands-on demonstration lab, we will build upon some of the concepts we have been learning to extend our Packer-built images into multiple regions within the same cloud environment.

8. Hands-On Lab - Building Images for Different Operating Systems

After learning to build images in Linux using Packer, we will explore the same image-building concepts on the Windows OS. We will update the Packer template to support multiple operating systems builds, validate the Packer template, and build images for different OS.

9. Hands-On Lab - Building Images in Multiple Clouds

After learning how to create images using Packer in multiple regions and operating systems, we will explore how Packer can build images in multiple cloud environments. We will update the Packer template to support multiple clouds, specify cloud-specific attributes, validate the Packer template, and build images across Azure and AWS.

10. Demo - Target Clouds and Build Types Using Packer

After learning to create images using Packer in multiple regions, OS, and clouds within a single Packer template, you will learn to perform updates to a subset of the different variations.


5. Variables

This section focuses on Packer variables, declaring Packer variables, using variables in templates, understanding environment variables and using them in the template, and creating Packer variables.

1. Introduction to Variables

In this video, we will look at an overview of variables in Packer, which can be used to define defaults and values during a build. They allow you to remove hard-coded values and pass parameters to the configuration.

2. Declaring Packer Variables

Before we discuss values in Packer, we will first understand the concept of declaring variables, which can be declared and defined in a ".pkrsvars.hcl" file. Or an "auto.pkrsvars.hcl" file or any other file name referenced when executing the build.

3. Using Variables in Packer Templates

After understanding variables and how to declare or define them in a template, you will learn about using the variables in a Packer template, including a general referral in Packer or an interpolation within a string.

4. Using Environment Variables

This video will explore environmental variables and how to use them in a template. Environment variables are a great solution to setting credentials or variables that often change.

5. Hands-On Lab - Packer Variables

In this hands-on lab demonstration video, we will work with Packer variables. We will add a variable and local block and update the Packer template to use variables. We will build an image with variables and a variable file. We will variabilize the entire Packer configuration.


6. Provisioners

This section focuses on provisioners and their features and uses. We will explore different examples of provisioners and understand third-party integrations, including files and other shell options.

1. Introduction to Provisioners

In this lesson, we will understand provisioners, which use built-in, third-party integrations to install packages and configure the machine image, which integrates with shell options and different files.

2. Examples of Different Provisioners

In this video, we will explore examples of different provisioners, including how to upload a single file and multiple files in a local directory. We will explore executing a script and running commands on the machine.

3. Useful Features of Provisioners

Here, we will examine the useful features of provisioners that run on specific builds and use "only" and "except" to run the provisioner with specific builds. We will also delve into build-specific overrides. We will look at the timeouts feature.

4. Hands-On Lab - Provisioners

In this lab demonstration, we will look at a showcase of adding provisioners to our Packer template. We will add a Packer provisioner to install updates and the nginx device. We will validate the Packer template and build a new image with Packer. We will also install the web application.


7. Post-Processors

This section focuses on post-processors as plugins that perform additional processing on the machine image generated by Packer after the build is complete. Built-in post-processors such as amazon-import and docker-import are available. Custom post-processors can also be developed and used to perform custom tasks on the generated image.

1. Introduction to Post-Processors

This video provides an overview of post-processors in HashiCorp Packer, explaining what they are and how they can be used to perform additional processing on the generated machine image. The video also covers some of the built-in post-processors available in Packer.

2. Examples of Post-Processors

In this video, several examples of post-processors are discussed, including the docker-import post-processor, which imports the machine image into Docker, and the vagrant post-processor, which exports the image as a Vagrant box. The video also covers how custom post-processors can be developed and used.

3. Hands-On Lab - Post-Processors

This video provides a hands-on lab that walks through the process of using a post-processor in Packer. The lab covers using the amazon-import post-processor to upload the machine image to an S3 bucket and register it as an AMI in Amazon EC2.


8. Code Organization

This section focuses on code organization, discussed as an important aspect of managing Packer configurations. The section covers best practices for structuring Packer templates and related configuration files to improve readability, maintainability, and scalability.

1. Code Organization

In this video, the importance of code organization in Packer is discussed, and several best practices are presented for structuring Packer templates and related configuration files. The video also covers how to use variables and modules in Packer to improve the maintainability and scalability of the configuration.

2. Hands-On Lab - Code Organization

This video provides a hands-on lab that walks through the process of using modules in Packer to organize and reuse common configuration blocks. The lab covers how to create a module, pass variables to the module, and use the module in a Packer template.

3. Hands-On Lab - Targeting Cloud Builds

In this video, a hands-on lab demonstrates how to use variables and conditional logic in Packer to target different cloud providers. The lab covers how to use the "only" and "except" variables to target specific builds, and how to use the required_components variable to ensure that required components are installed for each build.

4. Hands-On Lab - Convert JSON to HCL

This video provides a hands-on lab covering converting a Packer template from JSON to HCL format. The lab covers how to use the Packer init command to convert the template and how to modify the resulting HCL file to update the configuration.


9. Troubleshooting Your Packer Builds

In this section, troubleshooting Packer builds are discussed as an essential part of the build process. The section covers some common issues that can arise during a build, as well as strategies for diagnosing and resolving these issues.

1. Hands-On Lab - Packer Debug

In this video, a hands-on lab demonstrates how to use Packer's debug feature to diagnose issues in a build process. The lab covers how to enable debug logging, view the log output, and use the output to identify where in the build process an error has occurred.

2. Hands-On Lab - Packer Breakpoints

This video provides a hands-on lab that covers how to use breakpoints in Packer to pause the build process at specific points in the configuration. The lab covers how to add breakpoints to a Packer template, use the debug flag to enable breakpoints, and use the breakpoint to pause the build process and inspect the environment.


10. Packer Integrations

This section focuses on Packer integrations, how Packer can be used with other tools to create a complete build pipeline, and various integrations, such as using Packer with Ansible to automate VM images, or using Packer with Terraform to automate the creation of infrastructure.

1. Course Review

In this video, the course is reviewed, summarizing the main topics covered throughout the course. The video covers the fundamentals of Packer, including the basics of virtualization, the various builders available in Packer, and the role of provisioners and post-processors in the build process.

2. Hands-On Lab - Integrating Packer with Red Hat Ansible

This video provides a hands-on lab that covers how to use Packer with Red Hat Ansible to automate the configuration of virtual machine images.

3. Hands-On Lab - Integrating Packer with HashiCorp Terraform

This video provides a hands-on lab that covers how to use Packer with HashiCorp Terraform to automate the creation of infrastructure.

4. Demo - Integrating Packer with HashiCorp Vault's KV v2 Secrets Engine

This video demonstrates how to use Packer with HashiCorp Vault's KV v2 Secrets Engine to securely manage secrets during the build process.

5. Demo - Integrating Packer with HashiCorp Vault Using the AWS Secrets Engine

This video demonstrates how to use Packer with HashiCorp Vault's AWS Secrets Engine to securely manage secrets during the build process.

6. Demo - Integrating Packer with GitLab CI/CD

This video demonstrates how to use Packer with GitLab CI/CD to automate the build process and ensure that images are continuously updated with the latest changes.

6. Demo - Integrating Packer with GitLab CI/CD

This video demonstrates how to use Packer with GitLab CI/CD to automate the build process and ensure that images are continuously updated with the latest changes.

6. Demo - Integrating Packer with GitLab CI/CD

This video demonstrates how to use Packer with GitLab CI/CD to automate the build process and ensure that images are continuously updated with the latest changes.

6. Demo - Integrating Packer with GitLab CI/CD

This video demonstrates how to use Packer with GitLab CI/CD to automate the build process and ensure that images are continuously updated with the latest changes.

6. Demo - Integrating Packer with GitLab CI/CD

This video demonstrates how to use Packer with GitLab CI/CD to automate the build process and ensure that images are continuously updated with the latest changes.

Course Content

  1. Automating Image Creation with HashiCorp Packer for DevOps

About The Provider

Packt
Packt
Birmingham
Founded in 2004 in Birmingham, UK, Packt’s mission is to help the world put software to work in new ways, through the delivery of effective learning and i...
Read more about Packt

Tags

Reviews