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

Cannot load HCL vars files with -var-file argument #8781

Closed
mechastorm opened this issue Feb 21, 2020 · 6 comments · Fixed by #8882
Closed

Cannot load HCL vars files with -var-file argument #8781

mechastorm opened this issue Feb 21, 2020 · 6 comments · Fixed by #8882

Comments

@mechastorm
Copy link

Overview of the Issue

Can't seem to load .pkrvars.hcl files with the -var-file argument. I am not sure if it a bug with packer or the way I am using packer.

Reproduction Steps

I run the command

packer build -var-file=env/networking.pkrvars.hcl .

The contents of env/networking.pkrvars.hcl

ssh_username = "ubuntu"

I get the following error instead

invalid value "env/networking.pkrvars.hcl" for flag -var-file: Error reading variables in 'env/networking.pkrvars.hcl': invalid character 's' looking for beginning of value

Packer version

1.5.4

Operating system and Environment details

mac OS X 10.13.6

@azr
Copy link
Contributor

azr commented Feb 21, 2020

Hello @mechastorm, thanks for opening, this is not supported yet. Currently to use var files you need to put them in the same folder as the build files you are using and to run packer build folder/, packer will detect var files.

Currently passing the var-file option is making packer use JSON variables which is not exactly what we need.

@jasonberanek
Copy link
Collaborator

@azr I see in #8540 you mentioned that the documentation gets updated once per release, which may be why the current documentation is misleading; however is there a way to update docs to make the level of HCL support clearer? The current documentation gives the impression the build is fully supported for existing features, which is not the case.

I'd think for users, something like "we are implementing" or similar would make it clearer that this is a work in progress, and help people who are less edge adopters to avoid getting frustrated with Packer during the transition.

@drakedevel
Copy link

Yeah, the documentation at https://packer.io/docs/configuration/from-1.5/variables.html#variable-definitions-pkrvars-hcl-files doesn't really line up with the behavior right now.

In addition to not supporting HCL variable files as was already mentioned, JSON variable files suffer from #8748 (you have to double-quote strings to work around), so the example JSON file in the docs doesn't work, either.

@SwampDragons
Copy link
Contributor

Thanks for the notes -- I'll try to get a docs fix in this week so that current behavior is properly reflected on the website.

@SwampDragons SwampDragons added this to the 1.5.5 milestone Mar 9, 2020
@azr
Copy link
Contributor

azr commented Mar 11, 2020

Hey here, I've been re-reading the docs and sorry, the docs are a bit ahead of the features and should not have been mentioning the -var-file option. I'm working on making this feature/fix happen right now.

@ghost
Copy link

ghost commented Apr 13, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants