Best way to override variables

Hello!

I’m getting back into Packer. Last time I used it was a few years ago when all the templates were JSON. :slight_smile:

I’m working with Chef’s Bento repository. GitHub - chef/bento: Packer templates for building minimal Vagrant baseboxes for multiple platforms

So, this file defines the scripts that run for a given OS: bento/pkr-builder.pkr.hcl at main · chef/bento · GitHub

That’s all well and good, but for some boxes I build, I want to modify what scripts are run for that box.

I’m invoking package like so:

packer build -only=qemu.vm -var-file=os_pkrvars/freebsd/freebsd-13-x86_64.pkrvars.hcl ./packer_templates

I would like to change the scripts which run, but don’t want to have to modify the large tree in the above file. Adding a scripts entry to freebsd-13-x86_64.pkrvars.hcl isn’t effecting any change, but not throwing an error either.

What is the best way to override a local variable later in a var file? I’d rather like to avoid restructuring that whole pkr-builder.pkr.hcl file. :slight_smile:

Thank you for any ideas!