github.com/phobos182/packer@v0.2.3-0.20130819023704-c84d2aeffc68/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  * `builders` (_required_) is an array of one or more objects that defines
    24    the builders that will be used to create machine images for this template,
    25    and configures each of those builders. For more information on how to define
    26    and configure a builder, read the sub-section on
    27    [configuring builders in templates](/docs/templates/builders.html).
    28  
    29  * `provisioners` (optional) is an array of one or more objects that defines
    30    the provisioners that will be used to install and configure software for
    31    the machines created by each of the builders. This is an optional field.
    32    If it is not specified, then no provisioners will be run. For more
    33    information on how to define and configure a provisioner, read the
    34    sub-section on [configuring provisioners in templates](/docs/templates/provisioners.html).
    35  
    36  * `post-processors` (optional) is an array of one or more objects that defines the
    37    various post-processing steps to take with the built images. This is an optional
    38    field. If not specified, then no post-processing will be done. For more
    39    information on what post-processors do and how they're defined, read the
    40    sub-section on [configuring post-processors in templates](/docs/templates/post-processors.html).
    41  
    42  ## Example Template
    43  
    44  Below is an example of a basic template that is nearly fully functional. It is just
    45  missing valid AWS access keys. Otherwise, it would work properly with
    46  `packer build`.
    47  
    48  <pre class="prettyprint">
    49  {
    50    "builders": [
    51      {
    52        "type": "amazon-ebs",
    53        "access_key": "...",
    54        "secret_key": "...",
    55        "region": "us-east-1",
    56        "source_ami": "ami-de0d9eb7",
    57        "instance_type": "t1.micro",
    58        "ssh_username": "ubuntu",
    59        "ami_name": "packer {{timestamp}}"
    60      }
    61    ],
    62  
    63    "provisioners": [
    64      {
    65        "type": "shell",
    66        "script": "setup_things.sh"
    67      }
    68    ]
    69  }
    70  </pre>