首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Packer HCL2配置文件支持

Packer HCL2配置文件支持
EN

Stack Overflow用户
提问于 2020-04-04 05:03:56
回答 1查看 1.7K关注 0票数 0

https://packer.io/guides/hcl/from-json-v1/中,它说

注意:从1.5.0版本开始,封隔器可以读取HCL2文件。

我的封隔器是packer_1.5.5_linux_amd64.zip,它应该能够读取HCL2文件。然而,当我尝试时,我得到了

代码语言:javascript
复制
$ packer build -only=docker hcl-example
Failed to parse template: Error parsing JSON: invalid character '#' looking for beginning of value
At line 1, column 1 (offset 1):
    1: #
      ^

==> Builds finished but no artifacts were created.

$ packer build -h 
Usage: packer build [options] TEMPLATE

  Will execute multiple builds in parallel as defined in the template.
  The various artifacts created by the template will be outputted.

Options:

  -color=false                  Disable color output. (Default: color)
  -debug                        Debug mode enabled for builds.
  -except=foo,bar,baz           Run all builds and post-procesors other than these.
  -only=foo,bar,baz             Build only the specified builds.
  -force                        Force a build to continue if artifacts exist, deletes existing artifacts.
  -machine-readable             Produce machine-readable output.
  -on-error=[cleanup|abort|ask] If the build fails do: clean up (default), abort, or ask.
  -parallel=false               Disable parallelization. (Default: true)
  -parallel-builds=1            Number of builds to run in parallel. 0 means no limit (Default: 0)
  -timestamp-ui                 Enable prefixing of each ui output with an RFC3339 timestamp.
  -var 'key=value'              Variable for templates, can be used multiple times.
  -var-file=path                JSON file containing user variables. [ Note that even in HCL mode this expects file to contain JSON, a fix is comming soon ]

我没有看到任何从上面切换到HCL2模式的开关。

我在这里错过了什么?

代码语言:javascript
复制
$ packer version
Packer v1.5.5

$ cat hcl-example
# the source block is what was defined in the builders section and represents a
# reusable way to start a machine. You build your images from that source.source

"amazon-ebs" "example" {
    ami_name = "packer-test"
    region = "us-east-1"
    instance_type = "t2.micro"
}

更新:

为了解决Matt的评论/关注,我将hcl-示例的内容更改为https://packer.io/guides/hcl/from-json-v1/中的整个列表,并且

代码语言:javascript
复制
mv hcl-example hcl-example.hcl

$ packer validate hcl-example.hcl
Failed to parse template: Error parsing JSON: invalid character '#' looking for beginning of value
At line 1, column 1 (offset 1):
    1: #
      ^
EN

回答 1

Stack Overflow用户

发布于 2020-04-05 00:23:09

.pkr.hcl扩展命名它解决了这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61024002

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档