Day 29–101 Days of DevOps — Introduction to Packer — Part 1

Prashant Lakhera
2 min readAug 6, 2021

--

Welcome to Day 29 of 101 Days of DevOps. The topic for today is Introduction to Packer — Part 1.

To view the complete course, please check the below url.

For more info, register via the below link

YouTube Channel link

What is Packer?

Packer is easy to use and automates the creation of any machine image.

  • It integrates natively with a bunch of configuration management systems, e.g., Ansible, Puppet.
  • Packer is cross-platform(Linux/Window)
  • Packer uses a JSON template file and lets you define immutable infrastructure.
  • It’s written in the GO language.

Installing Packer on Ubuntu

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"sudo apt-get update && sudo apt-get install packer
  • Some Packer Options
packer
Usage: packer [--version] [--help] <command> [<args>]
Available commands are:
build build image(s) from template
console creates a console for testing variable interpolation
fix fixes templates from old versions of packer
fmt Rewrites HCL2 config files to canonical format
hcl2_upgrade transform a JSON template into an HCL2 configuration
init Install missing plugins or upgrade plugins
inspect see components of a template
validate check that a template is valid
version Prints the Packer version

Packer Template

  • Divided into three parts, each of them is a json array, so you can have as many as you want in each section.

Builders

  • Use to generate an image, and it’s provider-specific. E.g., if you create an image for AWS, your builder will tell the packer which AMI to start with and what region to create that AMI.

Provisioners

  • It let you customize your images.
  • These can be scripts(bash or PowerShell)or your existing configuration management system(e.g., chef, puppet, salt stack, and Ansible) or files where you can upload a file to the running instance for capturing things, e.g., config files, binaries, etc.

Post-Processors

  • Let’s integrate with other services like Docker. E.g., it will let you upload an image to dockerhub.

If you like to dig deeper into the AWS concept, please feel free to check my book.

Looking forward to you guys joining this journey and spend a minimum of an hour every day for the next 101 days on DevOps work and post your progress using any of the below mediums.

--

--

Prashant Lakhera
Prashant Lakhera

Written by Prashant Lakhera

AWS Community Builder, Ex-Redhat, Author, Blogger, YouTuber, RHCA, RHCDS, RHCE, Docker Certified,4XAWS, CCNA, MCP, Certified Jenkins, Terraform Certified, 1XGCP

No responses yet