Packer OVA
Recently I have started using Packer to build AMI images. It works like a champ, but then I tried to make VMWare images and it produced machine images, not machine exports. This makes the exports nearly useless. However, with a little post-processing magic this can be fixed.
There is a GoLang based ovftool post processor that already does this, but it needs to be compiled and put into the packer plugins dir. Nothing that the plugin does requires GoLang, so I whipped up a quick bash version that I could include with the packer script.
VMWare comes bundled with a tool called ovftool
which will convert a machine image into a OVA file. It has a lot of useful options so I recommend you reading the manual page. Basically it take a vmx
file and its associated files and makes a OVA: ovftool sourc.vmx dest.ova
.
I turned this into a script that can be called as a post processor from packer. There are a number of protections, but the important items are:
- line 5: Ensures
ovftool
is on the path - line 19: This avoids an interesting behavior (read bug) of Packer where the the inline script is called multiple times; once per file in the output directory.
- line 33: Removes the floppy which is used to install some VMWare drivers.
- line 37: Removes the CD-Room that is also used to install some VMWare drivers.
- line 42: Uses
ovftool
to create an OVA.
|
|
Add this script to the packer JSON files.
|
|