Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's not clear how to set variables #90

Open
nedbat opened this issue Dec 2, 2016 · 2 comments
Open

It's not clear how to set variables #90

nedbat opened this issue Dec 2, 2016 · 2 comments

Comments

@nedbat
Copy link
Contributor

nedbat commented Dec 2, 2016

I love these templates. I was about to embark on creating my own templates, but these seem like just the thing I need.

But I need to override some of the defaults. The README says I can set variables, but it isn't clear how. Packer can support multiple var-files, but the bin/box scripts don't provide a way to supply one. Some of the other boxcutter repo README's suggest a Makefile.local file, but then the Makefile wants to build everything, I think?

Can you provide some specific instructions? I'll make a pull request adding them nicely to the README if you like.

@ferrarimarco
Copy link

This may help you, from Packer docs:

The -var-file flag can be specified multiple times and variables from multiple files will be read and applied. As you'd expect, variables read from files specified later override a variable set earlier if it has already been set.

And from boxcutter/ubuntu README:

We make use of JSON files containing user variables to build specific versions of Ubuntu. You tell packer to use a specific user variable file via the -var-file= command line option. This will override the default options on the core ubuntu.json packer template, which builds Ubuntu 16.04 by default.

So you can specify multiple var-files if building with Packer. I don't use bin/box scripts, so let's wait for someone who knows better.

@olberger
Copy link

olberger commented Aug 9, 2022

You may use a combination of -var-file and -var if you want to override more. I find it a bit confusing however the mix of uppercase/lowercase variables description in the README. It makes it read as though one might use shell env vars to override stuff, but that wouldn't work in my experiments.

I managed to adjust bits with something like this, when I needed to override the iso_path (aka "ISO_PATH" in the README):

packer build -only=virtualbox-iso -var-file=ubuntu2004-desktop.json -var 'iso_path=/home/olivier/isos/' ubuntu.json

Hope this helps,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants