github.com/askholme/packer@v0.7.2-0.20140924152349-70d9566a6852/website/source/docs/templates/introduction.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Templates"
     4  ---
     5  
     6  # Templates
     7  
     8  Templates are JSON files that configure the various components of Packer
     9  in order to create one or more machine images. Templates are portable, static,
    10  and readable and writable by both humans and computers. This has the added
    11  benefit of being able to not only create and modify templates by hand, but
    12  also write scripts to dynamically create or modify templates.
    13  
    14  Templates are given to commands such as `packer build`, which will
    15  take the template and actually run the builds within it, producing
    16  any resulting machine images.
    17  
    18  ## Template Structure
    19  
    20  A template is a JSON object that has a set of keys configuring various
    21  components of Packer. The available keys within a template are listed below.
    22  Along with each key, it is noted whether it is required or not.
    23  
    24  * `builders` (_required_) is an array of one or more objects that defines
    25    the builders that will be used to create machine images for this template,
    26    and configures each of those builders. For more information on how to define
    27    and configure a builder, read the sub-section on
    28    [configuring builders in templates](/docs/templates/builders.html).
    29  
    30  * `description` (optional) is a string providing a description of what
    31    the template does. This output is used only in the
    32    [inspect command](/docs/command-line/inspect.html).
    33  
    34  * `min_packer_version` (optional) is a string that has a minimum Packer
    35    version that is required to parse the template. This can be used to
    36    ensure that proper versions of Packer are used with the template. A
    37    max version can't be specified because Packer retains backwards
    38    compatibility with `packer fix`.
    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. If not specified,
    42    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  * `provisioners` (optional) is an array of one or more objects that defines
    47    the provisioners that will be used to install and configure software for
    48    the machines created by each of the builders. If it is not specified,
    49    then no provisioners will be run. For more
    50    information on how to define and configure a provisioner, read the
    51    sub-section on [configuring provisioners in templates](/docs/templates/provisioners.html).
    52  
    53  * `variables` (optional) is an array of one or more key/value strings that defines
    54    user variables contained in the template.
    55    If it is not specified, then no variables are defined.
    56    For more information on how to define and use user variables, read the
    57    sub-section on [user variables in templates](/docs/templates/user-variables.html).
    58  
    59  ## Example Template
    60  
    61  Below is an example of a basic template that is nearly fully functional. It is just
    62  missing valid AWS access keys. Otherwise, it would work properly with
    63  `packer build`.
    64  
    65  <pre class="prettyprint">
    66  {
    67    "builders": [
    68      {
    69        "type": "amazon-ebs",
    70        "access_key": "...",
    71        "secret_key": "...",
    72        "region": "us-east-1",
    73        "source_ami": "ami-de0d9eb7",
    74        "instance_type": "t1.micro",
    75        "ssh_username": "ubuntu",
    76        "ami_name": "packer {{timestamp}}"
    77      }
    78    ],
    79  
    80    "provisioners": [
    81      {
    82        "type": "shell",
    83        "script": "setup_things.sh"
    84      }
    85    ]
    86  }
    87  </pre>