Creating Packer templates for Azure VMs with scripts
As mentioned in the introduction, to create a VM image, Packer is based on a file (template) that is written in JSON format or in HashiCorp Configuration Language (HCL), which was introduced in Packer from version 1.5.0 (read the following blog post for more information: https://www.packer.io/guides/hcl). We will first see the structure and composition of this template, and then we will put into practice how to create a template that will create a VM image in Azure.
The structure of the Packer template
The Packer template is composed of several main sections, such as builders
, provisioners
, and variables
. The JSON format of the template is as follows:
{ "variables": { // list of variables ... }, "builders": [ ...