Best way to override variables


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

I鈥檓 working with Chef鈥檚 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鈥檚 all well and good, but for some boxes I build, I want to modify what scripts are run for that box.

I鈥檓 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鈥檛 want to have to modify the large tree in the above file. Adding a scripts entry to freebsd-13-x86_64.pkrvars.hcl isn鈥檛 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鈥檇 rather like to avoid restructuring that whole pkr-builder.pkr.hcl file. :slight_smile:

Thank you for any ideas!