Packer to include boilerplate code?

27 views
Skip to first unread message

Steve Button

unread,
Sep 7, 2017, 6:18:08 AM9/7/17
to Packer
Hi,

I've been searching around for a while and asked a couple of colleagues and none of them know how to solve this. 

We've got a bunch of packer templates, which build AWS AMIs and they are all very similar. This means that when we make changes to one of them, we often have to remember to make the same change to all three. Ideally we'd like to "include" the common code which is shared with all three. Is there a way of doing this? Am I barking up the wrong tree? 

Thanks for your help!

Alexander Lehmann

unread,
Sep 7, 2017, 7:08:09 AM9/7/17
to Packer
Packer uses a single json file as config, but you could combine different files before using the packer command, e.g. with jq

Another possibility would be to create a base AMI with one packer command for the common parts and then create the specific images based on that (lets say the base image installs the necessary software and then the specific build steps create the config that is different between the machines)
Reply all
Reply to author
Forward
0 new messages