hashicorp / packer

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

Can't use qemuargs with HCL #8602

Closed adarobin closed 4 years ago

adarobin commented 4 years ago

I can't seem to figure out how to use qemuargs with the new HCL2 syntax.

If I put

    qemuargs = [
      [ "-m", "2048M" ],
      [ "-global", "virtio-pci.disable-modern=on" ]
    ]

I get the error

rhel-7-kickstart-test adarobin$ packer build rhel-7-kickstart-test.pkr.hcl 
Error: Unsupported argument

  on rhel-7-kickstart-test.pkr.hcl line 17, in source "qemu" "rhel7":
  17:     qemuargs = [

An argument named "qemuargs" is not expected here. Did you mean to define a
block of type "qemuargs"?

==> Builds finished but no artifacts were created.

If I switch to

    qemuargs {
      [ "-m", "2048M" ],
      [ "-global", "virtio-pci.disable-modern=on" ]
    }

I get

rhel-7-kickstart-test adarobin$ packer build rhel-7-kickstart-test.pkr.hcl 
Error: Argument or block definition required

  on rhel-7-kickstart-test.pkr.hcl line 18, in source "qemu" "rhel7":
  18:       [ "-m", "2048M" ],

An argument or block definition is required here.

==> Builds finished but no artifacts were created.
nywilken commented 4 years ago

hi @adarobin thanks for reaching out. Does the build work if you try something like?

qemuargs {
      qemuargs = ["-m", "2048M"]
 }

 qemuargs {
      qemuargs = [ "-global", "virtio-pci.disable-modern=on" ]
}
nywilken commented 4 years ago

hi @adarobin thanks again for reaching out. The code generation for this particular attribute is doing something wrong and not generating the expected schema. I've label this as a bug and will try to see about getting a fix into the next release.

Once fixed the expected configuration should like your first example

   qemuargs = [
      [ "-m", "2048M" ],
      [ "-global", "virtio-pci.disable-modern=on" ]
    ]
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.