Packer
- Is an Opensource tool for creating virtual machine images for multiple platforms from a single configuration
- For the scenario below

- From one configuration file we can create multiple vm images in different cloud /virtual platforms

- Lets install packer.
- Windows:
- Download the installable and install Refer Here
- Use chocolatey to install packer
choco install packer

- Linux Machine: Download packer and add the executable to PATH
- Windows:
- Packer configurations are written in json files
- In Packer we write the template in Json Format. Refer Here for official docs
- Packer template has the following structure
{
"variables": {},
"builders": [],
"description": "",
"provisioners": [],
"post-processors" : []
}
-
Variable: This is input that can be passed by the user
-
builders:
- This is required object
- This is array of one or more objects
- Each builder gives information to packer on where to create machine image
- Refer Here for builders
-
provisioners:
- For configuring software we would be using provisioners
-
post-processors
- This is array of objects for post-processing
-
Manual Steps:
- Lets create an ami with nginx installed
- Create an ec2 instance
- Install the software by logging in
sudo apt update sudo apt install nginx -y- Create an amazon machine image

- Lets use packer to create nginx image
- For amazon-ebs builder Refer Here
- For Variables Refer Here
- For Provisioners Refer Here
- In this example we would be using shell provisioner
- Refer Here for the changes
- Execute packer build command and wait for the ami’s to be created

- Lets create an ami with nginx installed
-
Try to create nginx vm image on azure by following the documentation. Refer Here
