Closed deepbrook closed 4 years ago
Oh right.
Renaming the template to template.pkr.hcl
works as expected. That's picky.
Updated the issue accordingly.
Hey @deepbrook, thanks for opening. Yup, that's the behaviour, because the schema/layout of an HCL file is tool dependant -- the schema for a Terraform file != the schema for a Packer file -- Packer HCL2 ignores non *.pkr.hcl
files because it does not and will not know about other schemas from other tools. Because it might be a Terraform file, a Nomad file or something else Packer is 'blind to it'.
Currently the default main maintained format is the JSON format and because no HCL file is found, this falls back to reading files with the JSON parser, which will open anything.
Note that in the (most likely far) future when the current JSON layout is going to be deprecated; Packer is still going to be blind to files that are not suffixed with *.pkr.hcl
.
This has a lot of benefits, like allowing developer tools to differentiate between a TF files and a PKR file; which will make the ecosystem better etc. etc.
Cheers !
This has a lot of benefits, like allowing developer tools to differentiate between a TF files and a PKR file; which will make the ecosystem better etc. etc.
i'd expect the tool to just eat the file and validate it, but I'm also not a big fan of hand-holding. Additionally, wouldn't it make more sense to have a hashbang-esque header line in the file to declare the tool the file is used for? But I was also under the impression that HCL is tool agnostic, so never you mind me. I'm sure you've had plenty of discussions on this. :) Thanks for the quick reply.
Sure no worries, :D yes HCL2 is tool specific ! That's why it's so nice because you can bend it to your will a bit more, read things a bit later with a context, etc. But then coming from JSON it can be a bit confusing.
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.
When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.
Overview of the Issue
Running the
validate
command against my HCL file does not validate the file as expected after https://github.com/hashicorp/packer/pull/9346 was merged and released with1.6.0
, if the template's suffix is not.pkr.hcl
.Reproduction Steps
Vaidating a template named
template.hcl
withpacker validate
throws the following:Renaming the file to
template.pkr.hcl
solves the issue.Packer version
Operating system and Environment details
Ubuntu 18.04