Installation of Packer

Nidhi
2 min readAug 31, 2018

Please visit my website and subscribe to my youtube channel for more articles

https://devops4solutions.com/

In this blog, we will do the Installation of Packer

Please follow the below steps

  1. Download the packer from here

INSTALLING PACKER ON MICROSOFT WINDOWS

  1. Create a directory like C:\packer and copy the executable file here.
  2. Add the packer path in your system path
  3. Open the powershell window and run the below command

Packer is successfully installed on your system.

Packer Components

Packer calls the process of creating an image a build.

Artifacts are the output from builds. One of the more useful aspects of Packer is that you can run multiple builds to produce multiple artifacts.

A build is fed from a template. The template is a JSON document that describes the image we want to build — both where we want to build it and what the build needs to contain.

To determine what sort of image to build, Packer uses components called builders. A builder produces an image of a specific format — for example, an AMI builder or a Docker image builder. Packer ships with a number of builders and you can also add your own builder in the form of plugins.

Running Packer

Create a Json file to create an image

  1. Create a file ami.json
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "ami-a025aeb6",
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-example {{timestamp | clean_ami_name}}"
}]
}

2. Run the below command to validate the packer

$ packer validate ami.json
Template validated successfully.

3. Build the image

$  packer build ami.json

You’ve now created your first Packer image successfully.

--

--