- Love Packer?
- Frustrated by the lack of support for YAML?
- Even though the process of converting YAML to JSON is, well, simple?
Well, now there’s yacker!
yacker is an open-source Python YAML interpreter for HashiCorp’s Packer.
It wraps Packer in a converting wrapper that allows you to drive
it with YAML files.
Now you can craft your Packer files in YAML rather than JSON. Then,
instead of running
packer on JSON files, you run
yacker on your
yacker build template.yml
yacker does is translate YAML to JSON on the fly (a super-trivial
act in Python), calling on Packer to do the rest.
Now you can benefit from the more pleasant environment that YAML provides and still use a pretty cool tool.
- searches the command-line for
.yaml) files (specifically looking for the template and any
- converts the files (if found) to JSON files
- reconstructs the command line (using the remaining options)
- passes control to
- removes the JSON files it created
- passes control (and Packer’s exit code) back to you
Packer’s output and any errors are simply presented to you as if you’d run Packer using JSON.
yacker also translates any YAML-based variable files you may have.
If you name a YAML file in any
temporarily convert that file for you before passing it to Packer and
then removing it:
yacker build -var-file=v1.yml -var-file=v2.yml template.yml
yacker expects to find
packer on the system
If you don’t have Packer on the system path, or want to use a different Packer,
you can provide a path to it by using the
YACKER_PACKER_PATH=~/bin yacker version
export YACKER_PACKER_PATH=~/bin yacker version yacker build template.yml