tylert / packer-build

Packer Automated VM Image and Vagrant Box Builds

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors in building packer

LaiWeiQuan opened this issue · comments

roar-alpha@localhost:~/packer-build/source/ubuntu/22.04_jammy$ packer build base.pkr.hcl 
Error: Error in function call

  on base.pkr.hcl line 305:
  (source code not available)

with var as object with 52 attributes,
     var.user_data_location as "user-data".

Call to function "templatefile" failed: user-data:119,20-29: Unsupported
attribute; This object does not have an attribute named "username"., and 1 other
diagnostic(s).

Error: Error in function call

  on base.pkr.hcl line 364:
  (source code not available)

with var as object with 52 attributes,
     var.user_data_location as "user-data".

Call to function "templatefile" failed: user-data:119,20-29: Unsupported
attribute; This object does not have an attribute named "username"., and 1 other
diagnostic(s).

22.04 packer template fails to build may I know how should I debug this?

Sorry you ran into a bug but it seems like you're willing to help fix them (thanks). I confess that I don't really use these templates anymore but I'm certainly willing to merge fixes since there might still be folks out there using these (so maybe I'm not quite ready to "archive" this repo).

First off, I'm not too sure which version of HashiCorp Packer you are using, nor what kind of a system you're trying to run this on (in case this issue turns out to be related to that). Second, you should probably confirm what version of VirtualBox or QEMU/libvirt you're trying to use too.

I have neglected to update the https://github.com/tylert/packer-build#using-packer-templates section of the README the last time I tried to finish the conversion from my old YAML-based templates and the instructions for doing this using the HCL2-based templates were quite a bit different. As I said, I'm not really using this repo these days but I'm willing to merge in pull-requests to help improve the README.

You might also try passing in the -only=qemu or -only=vbox options to packer build if you're aiming to work with only one of the builders.

As for debugging things, you should definitely start out by having a peek at the extra options for the packer build command at https://developer.hashicorp.com/packer/docs/commands/build . There's also some additional notes at https://developer.hashicorp.com/packer/docs/debugging which might help reveal some additional information about the debugging process and other things like the PACKER_LOG=1 environment variable and so on.

I hope these instructions help set you back on the path to a solution quickly. I'm going to leave this issue open until someone has a chance to put up a pull-request or you can confirm things work better with a newer version of Packer.