github.com/kaixiang/packer@v0.5.2-0.20140114230416-1f5786b0d7f1/website/source/docs/templates/introduction.html.markdown (about) 1 --- 2 layout: "docs" 3 --- 4 5 # Templates 6 7 Templates are JSON files that configure the various components of Packer 8 in order to create one or more machine images. Templates are portable, static, 9 and readable and writable by both humans and computers. This has the added 10 benefit of being able to not only create and modify templates by hand, but 11 also write scripts to dynamically create or modify templates. 12 13 Templates are given to commands such as `packer build`, which will 14 take the template and actually run the builds within it, producing 15 any resulting machine images. 16 17 ## Template Structure 18 19 A template is a JSON object that has a set of keys configuring various 20 components of Packer. The available keys within a template are listed below. 21 Along with each key, it is noted whether it is required or not. 22 23 * `description` (optional) is a string providing a description of what 24 the template does. This output is used only in the 25 [inspect command](/docs/command-line/inspect.html). 26 27 * `builders` (_required_) is an array of one or more objects that defines 28 the builders that will be used to create machine images for this template, 29 and configures each of those builders. For more information on how to define 30 and configure a builder, read the sub-section on 31 [configuring builders in templates](/docs/templates/builders.html). 32 33 * `provisioners` (optional) is an array of one or more objects that defines 34 the provisioners that will be used to install and configure software for 35 the machines created by each of the builders. This is an optional field. 36 If it is not specified, then no provisioners will be run. For more 37 information on how to define and configure a provisioner, read the 38 sub-section on [configuring provisioners in templates](/docs/templates/provisioners.html). 39 40 * `post-processors` (optional) is an array of one or more objects that defines the 41 various post-processing steps to take with the built images. This is an optional 42 field. If not specified, then no post-processing will be done. For more 43 information on what post-processors do and how they're defined, read the 44 sub-section on [configuring post-processors in templates](/docs/templates/post-processors.html). 45 46 ## Example Template 47 48 Below is an example of a basic template that is nearly fully functional. It is just 49 missing valid AWS access keys. Otherwise, it would work properly with 50 `packer build`. 51 52 <pre class="prettyprint"> 53 { 54 "builders": [ 55 { 56 "type": "amazon-ebs", 57 "access_key": "...", 58 "secret_key": "...", 59 "region": "us-east-1", 60 "source_ami": "ami-de0d9eb7", 61 "instance_type": "t1.micro", 62 "ssh_username": "ubuntu", 63 "ami_name": "packer {{timestamp}}" 64 } 65 ], 66 67 "provisioners": [ 68 { 69 "type": "shell", 70 "script": "setup_things.sh" 71 } 72 ] 73 } 74 </pre>