github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/enterprise/packer/artifacts/creating-vagrant-boxes.html.md (about)

     1  ---
     2  layout: "enterprise"
     3  page_title: "Creating Vagrant Boxes - Packer Artifacts - Terraform Enterprise"
     4  sidebar_current: "docs-enterprise-packerartifacts-vagrant"
     5  description: |-
     6    Creating Vagrant artifacts with Terraform Enterprise.
     7  ---
     8  
     9  # Creating Vagrant Boxes with Packer
    10  
    11  We recommend using Packer to create boxes, as is it is fully repeatable and
    12  keeps a strong history of changes within Terraform Enterprise.
    13  
    14  ## Getting Started
    15  
    16  Using Packer requires more up front effort, but the repeatable and automated
    17  builds will end any manual management of boxes. Additionally, all boxes will be
    18  stored and served from Terraform Enterprise, keeping a history along the way.
    19  
    20  ## Post-Processors
    21  
    22  Packer uses
    23  [post-processors](https://packer.io/docs/templates/post-processors.html) to
    24  define how to process images and artifacts after provisioning. Both the
    25  `vagrant` and `atlas` post-processors must be used in order to upload Vagrant
    26  Boxes to Terraform Enterprise via Packer.
    27  
    28  It's important that they are [sequenced](https://packer.io/docs/templates/post-processors.html)
    29  in the Packer template so they run in order. This is done by nesting arrays:
    30  
    31  ```javascript
    32  {
    33    "post-processors": [
    34      [
    35        {
    36          "type": "vagrant"
    37          // ...
    38        },
    39        {
    40          "type": "atlas"
    41          // ...
    42        }
    43      ]
    44    ]
    45  }
    46  ```
    47  
    48  Sequencing automatically passes the resulting artifact from one
    49  post-processor to the next – in this case, the `.box` file.
    50  
    51  ### Vagrant Post-Processor
    52  
    53  The [Vagrant post-processor](https://packer.io/docs/post-processors/vagrant.html) is required to package the image
    54  from the build (an `.ovf` file, for example) into a `.box` file before
    55  passing it to the `atlas` post-processor.
    56  
    57  ```json
    58  {
    59    "type": "vagrant",
    60    "keep_input_artifact": false
    61  }
    62  ```
    63  
    64  The input artifact (i.e and `.ovf` file) does not need to be kept when building Vagrant Boxes,
    65  as the resulting `.box` will contain it.
    66  
    67  ### Post-Processor
    68  
    69  The [post-processor](https://packer.io/docs/post-processors/atlas.html) takes the resulting `.box` file and uploads it adding metadata about the box version.
    70  
    71  ```json
    72  {
    73    "type": "atlas",
    74    "artifact": "my-username/dev-environment",
    75    "artifact_type": "vagrant.box",
    76    "metadata": {
    77      "provider": "vmware_desktop",
    78      "version": "0.0.1"
    79    }
    80  }
    81  ```
    82  
    83  #### Attributes Required
    84  
    85  These are all of the attributes for that post-processor
    86  required for uploading Vagrant Boxes. A complete example is shown below.
    87  
    88  - `artifact`: The username and box name (`username/name`) you're creating the version
    89  of the box under. If the box doesn't exist, it will be automatically
    90  created
    91  - `artifact_type`: This must be `vagrant.box`. Terraform Enterprise uses this to determine
    92  how to treat this artifact.
    93  
    94  For `vagrant.box` type artifacts, you can specify keys in the metadata block:
    95  
    96  - `provider`: The Vagrant provider for the box. Common providers are
    97  `virtualbox`, `vmware_desktop`, `aws` and so on _(required)_
    98  - `version`: This is the Vagrant box version and is constrained to the
    99  same formatting as in the web UI: `*.*.*` _(optional, but required for boxes
   100  with multiple providers). The version will increment on the minor version if left blank (e.g the initial version will be set to 0.1.0, the subsequent version will be set to 0.2.0)._
   101  - `description`: This is the description that will be shown with the
   102  version of the box. You can use Markdown for links and style. _(optional)_
   103  
   104  ## Example
   105  
   106  An example post-processor block for Terraform Enterprise and Vagrant is below. In this example,
   107  the build runs on both VMware and Virtualbox creating two
   108  different providers for the same box version (`0.0.1`).
   109  
   110  ```json
   111  {
   112    "post-processors": [
   113      [
   114        {
   115          "type": "vagrant",
   116          "keep_input_artifact": false
   117        },
   118        {
   119          "type": "atlas",
   120          "only": ["vmware-iso"],
   121          "artifact": "my-username/dev-environment",
   122          "artifact_type": "vagrant.box",
   123          "metadata": {
   124            "provider": "vmware_desktop",
   125            "version": "0.0.1"
   126          }
   127        },
   128        {
   129          "type": "atlas",
   130          "only": ["virtualbox-iso"],
   131          "artifact": "my-username/dev-environment",
   132          "artifact_type": "vagrant.box",
   133          "metadata": {
   134            "provider": "virtualbox",
   135            "version": "0.0.1"
   136          }
   137        }
   138      ]
   139    ]
   140  }
   141  ```