github.com/aspring/packer@v0.8.1-0.20150629211158-9db281ac0f89/website/source/docs/templates/builders.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Templates: Builders"
     4  description: |-
     5    Within the template, the builders section contains an array of all the builders that Packer should use to generate a machine images for the template.
     6  ---
     7  
     8  # Templates: Builders
     9  
    10  Within the template, the builders section contains an array of all the
    11  builders that Packer should use to generate a machine images for the template.
    12  
    13  Builders are responsible for creating machines and generating images from
    14  them for various platforms. For example, there are separate builders for
    15  EC2, VMware, VirtualBox, etc. Packer comes with many builders by default,
    16  and can also be extended to add new builders.
    17  
    18  This documentation page will cover how to configure a builder in a template.
    19  The specific configuration options available for each builder, however,
    20  must be referenced from the documentation for that specific builder.
    21  
    22  Within a template, a section of builder definitions looks like this:
    23  
    24  ```javascript
    25  {
    26    "builders": [
    27      // ... one or more builder definitions here
    28    ]
    29  }
    30  ```
    31  
    32  ## Builder Definition
    33  
    34  A single builder definition maps to exactly one [build](/docs/basics/terminology.html#term-build).
    35  A builder definition is a JSON object that requires at least a `type` key. The
    36  `type` is the name of the builder that will be used to create a machine image
    37  for the build.
    38  
    39  In addition to the `type`, other keys configure the builder itself. For
    40  example, the AWS builder requires an `access_key`, `secret_key`, and
    41  some other settings. These are placed directly within the builder definition.
    42  
    43  An example builder definition is shown below, in this case configuring
    44  the AWS builder:
    45  
    46  ```javascript
    47  {
    48    "type": "amazon-ebs",
    49    "access_key": "...",
    50    "secret_key": "..."
    51  }
    52  ```
    53  
    54  ## Named Builds
    55  
    56  Each build in Packer has a name. By default, the name is just the name
    57  of the builder being used. In general, this is good enough. Names only serve
    58  as an indicator in the output of what is happening. If you want, however,
    59  you can specify a custom name using the `name` key within the builder definition.
    60  
    61  This is particularly useful if you have multiple builds defined that use
    62  the same underlying builder. In this case, you must specify a name for at least
    63  one of them since the names must be unique.
    64  
    65  ## Communicators
    66  
    67  Every build is associated with a single
    68  [communicator](/docs/templates/communicator.html). Communicators are
    69  used to establish a connection for provisioning a remote machine (such
    70  as an AWS instance or local virtual machine).
    71  
    72  All the examples for the various builders show some communicator (usually
    73  SSH), but the communicators are highly customizable so we recommend
    74  reading the
    75  [communicator documentation](/docs/templates/communicator.html).