Templates are JSON files that configure the various components of Packer in order to create one or more virtual machine images.
JSON files both human readable and computers readable. A template is a JSON object that has a set of keys configuring various components of Packer.
- builders (required): It is an array of one or more objects that defines the builders that will be used to create machine images for this template, and configures each of those builders.
- description (optional) : It is a string providing a description for the template.
- provisioners (optional) : It is an array of one or more objects that defines the provisioners that will be used to install and configure software for the machines created by each of the builders.
- post-processors (optional) : It is an array of one or more objects that defines the various post-processing steps to take with the built images.
- variables (optional): It is an object of one or more key/value strings that defines user variables contained in the template.
Example Template
{ "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-02e680c4", "instance_type": "t2.micro", "ssh_username": "ubuntu", "ami_name": "packer {{timestamp}}" } ], "provisioners": [ { "type": "shell", "script": "script.sh" } ] }