github.com/homburg/packer@v0.6.1-0.20140528012651-1dcaf1716848/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  * `description` (optional) is a string providing a description of what
    30    the template does. This output is used only in the
    31    [inspect command](/docs/command-line/inspect.html).
    32  
    33  * `min_packer_version` (optional) is a string that has a minimum Packer
    34    version that is required to parse the template. This can be used to
    35    ensure that proper versions of Packer are used with the template. A
    36    max version can't be specified because Packer retains backwards
    37    compatibility with `packer fix`.
    38  
    39  * `post-processors` (optional) is an array of one or more objects that defines the
    40    various post-processing steps to take with the built images. If not specified,
    41    then no post-processing will be done. For more
    42    information on what post-processors do and how they're defined, read the
    43    sub-section on [configuring post-processors in templates](/docs/templates/post-processors.html).
    44  
    45  * `provisioners` (optional) is an array of one or more objects that defines
    46    the provisioners that will be used to install and configure software for
    47    the machines created by each of the builders. If it is not specified,
    48    then no provisioners will be run. For more
    49    information on how to define and configure a provisioner, read the
    50    sub-section on [configuring provisioners in templates](/docs/templates/provisioners.html).
    51  
    52  * `variables` (optional) is an array of one or more key/value strings that defines
    53    user variables contained in the template.
    54    If it is not specified, then no variables are defined.
    55    For more information on how to define and use user variables, read the
    56    sub-section on [user variables in templates](/docs/templates/user-variables.html).
    57  
    58  ## Example Template
    59  
    60  Below is an example of a basic template that is nearly fully functional. It is just
    61  missing valid AWS access keys. Otherwise, it would work properly with
    62  `packer build`.
    63  
    64  <pre class="prettyprint">
    65  {
    66    "builders": [
    67      {
    68        "type": "amazon-ebs",
    69        "access_key": "...",
    70        "secret_key": "...",
    71        "region": "us-east-1",
    72        "source_ami": "ami-de0d9eb7",
    73        "instance_type": "t1.micro",
    74        "ssh_username": "ubuntu",
    75        "ami_name": "packer {{timestamp}}"
    76      }
    77    ],
    78  
    79    "provisioners": [
    80      {
    81        "type": "shell",
    82        "script": "setup_things.sh"
    83      }
    84    ]
    85  }
    86  </pre>