Skip to main content

Packer

packer

Repository for studying Packer

Official Documentation Official Packer Repository

What is Packer?​

Packer is an open-source tool that allows you to create identical machine images for multiple platforms from a single source code template. Packer can create golden images to use in image pipelines.

  • Lightweight binary
  • High performance
  • Written in Go
  • Simple and effective
  • Runs on all major operating systems
  • Creates machine images for multiple platforms in parallel

Packer does not replace configuration management like Ansible, but works alongside it.

Packer Diagram

What is an Image?​

A machine image is a single static unit that contains a pre-configured operating system and installed software that is used to quickly create new running machines. Machine image formats change for each platform. Some examples include AMIs for EC2, VMDK/VMX files for VMware, OVF exports for VirtualBox, etc.

Packer Installation​

As mentioned earlier, Packer is nothing more than a binary and has its own CLI. It needs to be in the system path to be found via terminal, so you must move the binary to a folder that is in the system path or add the installation location to the path.

Packer Installation Documentation

For example, an installation on Ubuntu:

wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install packer

Or you can download the binary directly from the repository.

Study Guide​

1 - Commands
2 - Template
4 - Project
4 - HCP Registry
5 - Variables.md
6 - Locals and Functions
7 - Plugins
8 - Build
9 - AWS Example
10 - Azure Example