hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.04k stars 3.32k forks source link

HCL2 - Inspec provisioner error #8789

Closed mechastorm closed 4 years ago

mechastorm commented 4 years ago

Overview of the Issue

Looks to be Inspec provisioner errors when used in HCL2.

The example code in the blog post mentions that

All provisioners and post-processors have a 1:1 correspondence to their current layout.

I assume this means the inpec provisioner is also meant to be working "as-is" ? I am aware that HCL2 is still a beta feature, so just want to get a clear understanding of what to expect.

Reproduction Steps

# A build starts sources and runs provisioning steps on those sources.
build {
  sources = [
    # there can be multiple sources per build
    "source.amazon-ebs.ubuntu"
  ]

  # Inspec Tests
  provisioner "inspec" {
    profile = "https://github.com/dev-sec/linux-baseline"
  }
}

The error I get is

Error: Failed preparing provisioner-block "inspec" ""

  on build.pkr.hcl line 52, in build:
  52:   provisioner "inspec" {

1 error occurred:
        * unknown configuration key: "sub_command"; raws is []interface
{}{map[string]interface {}{"attributes":interface {}(nil),
"attributes_directory":interface {}(nil), "backend":interface {}(nil),
"command":interface {}(nil), "extra_arguments":interface {}(nil),
"host":interface {}(nil), "inspec_env_vars":interface {}(nil),
"local_port":interface {}(nil), "packer_build_name":interface {}(nil),
"packer_builder_type":interface {}(nil), "packer_debug":interface {}(nil),
"packer_force":interface {}(nil), "packer_on_error":interface {}(nil),
"packer_sensitive_variables":interface {}(nil),
"packer_user_variables":interface {}(nil),
"profile":"https://github.com/dev-sec/linux-baseline",
"ssh_authorized_key_file":interface {}(nil), "ssh_host_key_file":interface
{}(nil), "sub_command":interface {}(nil), "user":interface {}(nil)}} 

 and ctx data is map[interface {}]interface {}{"ConnType":"Build_Type. To set
this dynamically in the Packer template, you must use the `build` function",
"Host":"Build_Host. To set this dynamically in the Packer template, you must use
the `build` function", "ID":"Build_ID. To set this dynamically in the Packer
template, you must use the `build` function",
"PackerHTTPAddr":"Build_PackerHTTPAddr. To set this dynamically in the Packer
template, you must use the `build` function",
"PackerRunUUID":"Build_PackerRunUUID. To set this dynamically in the Packer
template, you must use the `build` function", "Password":"Build_Password. To set
this dynamically in the Packer template, you must use the `build` function",
"Port":"Build_Port. To set this dynamically in the Packer template, you must use
the `build` function", "SSHPrivateKey":"Build_SSHPrivateKey. To set this
dynamically in the Packer template, you must use the `build` function",
"SSHPublicKey":"Build_SSHPublicKey. To set this dynamically in the Packer
template, you must use the `build` function",
"SourceAMIName":"Build_SourceAMIName. To set this dynamically in the Packer
template, you must use the `build` function", "User":"Build_User. To set this
dynamically in the Packer template, you must use the `build` function",
"WinRMPassword":"{{.WinRMPassword}}"}

Packer version

Packer 1.5.4

sylviamoss commented 4 years ago

Hey there! thanks for reaching out! This is a known error similar to https://github.com/hashicorp/packer/issues/8775. We will be fixing this soon 👍

SwampDragons commented 4 years ago

We think we have a PR that will fix this issue, linked above -- can you test the binary in https://circleci.com/gh/hashicorp/packer/35967#artifacts/containers/0 and let us know if it solves your issue?

ghost commented 4 years ago

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.