tylert / packer-build

Packer Automated VM Image and Vagrant Box Builds

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make templates more DRY

tylert opened this issue · comments

According to a hint found at hashicorp/packer#1047 (comment), packer templates can be made a lot simpler using "node anchors" in YAML to generate the large JSON blobs (DRY = Don't Repeat Yourself).

Ideally, rather than store the large, ugly JSON blobs, it may be preferable to store a smaller YAML blob instead and try to use some templating engine such as Jinja to work around the problem of packer not having a good way to nest user variables.

The link above seems to suggest that this feature requires a parser capable of handling YAML 1.2, however, YAML 1.1 seems to also have node anchors too (http://www.yaml.org/spec/1.1/#id899912).

Unfortunately, there are a lot more YAML 1.1 parsers out there.

It would appear that, if hashicorp/packer#2692 were to be merged, this might also remove some/all of the need to do this too.

Other background at hashicorp/packer#1942

hashicorp/packer#2101.

Perhaps touching the passwords in the vagrant template files and preseed files during the "pre-packer phase" of the build would be nice.

These changes will land at the same time that #4 does.