How to install and configure Packer on MacOS

Mayank Jain
3 min readMar 21, 2024

--

Hello Folks, In this blog we will learn how to install and configure packer on macOS.

Packer is a powerful tool from HashiCorp that simplifies building identical machine images for various platforms. Whether you’re deploying to the cloud or on-prem, Packer streamlines the image creation process, saving you time and effort. In this blog, we’ll walk you through installing and configuring Packer on macOS.

Prerequisites:

Brew should be installed. To install brew you can refer here.

Installation:

There are two main ways to install Packer on macOS:

Homebrew: This is the recommended approach for most users. Homebrew is a popular package manager for macOS that simplifies installing and managing software.

Pre-compiled Binaries: You can download pre-built binaries directly from the HashiCorp website. This method offers more flexibility but requires manual configuration.

Using Homebrew (Recommended):

  1. Install homebrew: If homebrew is not installed you can go here and follow the instructions to install it.
  2. Install Packer: Once Homebrew is set up, open your terminal and run the following command:
~ brew install hashicorp/tap/packer

The above command installs the official Packer from the HashiCorp tap, a repository containing all their Homebrew packages. This ensures you get a signed binary and automatic updates with new releases.

Using Pre-compiled Binaries:

  1. Download Packer: Visit the Packer downloads page https://developer.hashicorp.com/packer/install and download the latest macOS binary for 64-bit architecture.
  2. Extract the archive: Unzip the downloaded file.
  3. Configure PATH (Optional): By default, the system might not recognize Packer commands. To fix this, you can add the directory containing the unpacked binary to your PATH environment variable. This allows you to run Packer commands from any location in your terminal.

How to add the directory to your PATH:

  1. Open your .zshrc or .bashrc file (depending on your shell) using a text editor.
  2. Add the following line, replacing with /path/to/packer the actual directory where you unpacked the binary:
~ export PATH="/path/to/packer:$PATH"

3. Save the file and reload your shell configuration using below command:

~ source ~/.zshrc  # or source ~/.bashrc

Verification:

Once you’ve installed Packer using either method, open your terminal and run the below mentioned command:

~ packer --version

The above command should display the installed Packer version, confirming successful installation.

Congratulations! you just learned how to install and configure Packer on MacOS. You’re now ready to start using Packer to build machine images on your macOS system. In next blog, we’ll explore creating Packer templates to build custom images.

Learn how to execute shell script within Jenkins Pipeline on MacOS here.

Learn how to install and configure Jenkins on MacOS here.

Learn how to set up the Puppet Master and Agent in a virtual box environment here.

Learn RHEL8 custom AMI creation using RHEL Image Builder here.

Learn how to remove the old Linux kernel from RHEL8/CentOS8 here.

Learn how to log commands of all users runs in Linux here.

--

--

Mayank Jain

Skilled DevOps Engineer with 7.5+ years of hands-on experience supporting, automating, & optimizing mission critical deployments in cloud.