github.com/ratanraj/packer@v1.3.2/website/source/intro/getting-started/vagrant.html.md (about) 1 --- 2 layout: intro 3 sidebar_current: intro-getting-started-vagrant 4 page_title: Vagrant Boxes - Getting Started 5 description: |- 6 Packer also has the ability to take the results of a builder (such as an AMI 7 or plain VMware image) and turn it into a Vagrant box. 8 --- 9 10 # Vagrant Boxes 11 12 Packer also has the ability to take the results of a builder (such as an AMI or 13 plain VMware image) and turn it into a [Vagrant](https://www.vagrantup.com) box. 14 15 This is done using [post-processors](/docs/templates/post-processors.html). 16 These take an artifact created by a previous builder or post-processor and 17 transforms it into a new one. In the case of the Vagrant post-processor, it 18 takes an artifact from a builder and transforms it into a Vagrant box file. 19 20 Post-processors are a generally very useful concept. While the example on this 21 getting-started page will be creating Vagrant images, post-processors have many 22 interesting use cases. For example, you can write a post-processor to compress 23 artifacts, upload them, test them, etc. 24 25 Let's modify our template to use the Vagrant post-processor to turn our AWS AMI 26 into a Vagrant box usable with the [vagrant-aws 27 plugin](https://github.com/mitchellh/vagrant-aws). If you followed along in the 28 previous page and setup DigitalOcean, Packer can't currently make Vagrant boxes 29 for DigitalOcean, but will be able to soon. 30 31 ## Enabling the Post-Processor 32 33 Post-processors are added in the `post-processors` section of a template, which 34 we haven't created yet. Modify your `example.json` template and add the section. 35 Your template should look like the following: 36 37 ```json 38 { 39 "builders": ["..."], 40 "provisioners": ["..."], 41 "post-processors": ["vagrant"] 42 } 43 ``` 44 45 In this case, we're enabling a single post-processor named "vagrant". This 46 post-processor is built-in to Packer and will create Vagrant boxes. You can 47 always create [new post-processors](/docs/extending/custom-post-processors.html), however. 48 The details on configuring post-processors is covered in the 49 [post-processors](/docs/templates/post-processors.html) documentation. 50 51 Validate the configuration using `packer validate`. 52 53 ## Using the Post-Processor 54 55 Just run a normal `packer build` and it will now use the post-processor. Since 56 Packer can't currently make a Vagrant box for DigitalOcean anyway, I recommend 57 passing the `-only=amazon-ebs` flag to `packer build` so it only builds the AMI. 58 The command should look like the following: 59 60 ```text 61 $ packer build -only=amazon-ebs example.json 62 ``` 63 64 As you watch the output, you'll notice at the end in the artifact listing that a 65 Vagrant box was made (by default at `packer_aws.box` in the current directory). 66 Success! 67 68 But where did the Amazon EBS builder artifact go? When using post-processors, 69 Vagrant removes intermediary artifacts since they're usually not wanted. Only 70 the final artifact is preserved. This behavior can be changed, of course. 71 Changing this behavior is covered [in the 72 documentation](/docs/templates/post-processors.html). 73 74 Typically when removing intermediary artifacts, the actual underlying files or 75 resources of the artifact are also removed. For example, when building a VMware 76 image, if you turn it into a Vagrant box, the files of the VMware image will be 77 deleted since they were compressed into the Vagrant box. With creating AWS 78 images, however, the AMI is kept around, since Vagrant needs it to function.