Autoinstall ubuntu 20.04.1 with packer v1.6.6 / vsphere-iso builder / vCenter Server 7.0.0.10300

Hi, not sure if the following problem is related to packer or more an ubuntu question. Well, I start here.
I try to autoinstall ubuntu live-server 20.04.1 on a esxi host using vcenter server v7.0 with packer using its http server to serve the user-data and meta-data file for cloud init. All is working but the ubuntu installer stops at:

[ OK ] Reached target Host and Network Name Lookups

  • Any ideas why the ubuntu installer stop/hangs there?
  • How can I check if the cloud init file ‘user-data’ is picked up from the packer http server from the ubuntu installer?

Thanks and best
Roland

Some more details:
I have a packer *.pkr.hcl file using the vsphere-iso bilder.
The boot_command stanza looks like this and it is working:

boot_command = [
    "<enter><enter>",
    "<f6><esc>",
    "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
    "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
    "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
    "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
    "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
    "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
    "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
    "<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
    "<bs><bs><bs>",
    "/casper/vmlinuz ",
    "initrd=/casper/initrd ",
    "autoinstall ",
    "ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/",
    "<enter>"  ]

The output of packer looks like this:

==> vsphere-iso.buildserver: Creating VM...
==> vsphere-iso.buildserver: Customizing hardware...
==> vsphere-iso.buildserver: Mounting ISO images...
==> vsphere-iso.buildserver: Adding configuration parameters...
==> vsphere-iso.buildserver: Starting HTTP server on port 8929
==> vsphere-iso.buildserver: Set boot order temporary...
==> vsphere-iso.buildserver: Power on VM...
==> vsphere-iso.buildserver: Waiting 5s for boot...
==> vsphere-iso.buildserver: HTTP server is working at http://192.168.178.180:8929/
==> vsphere-iso.buildserver: Typing boot command...
==> vsphere-iso.buildserver: Waiting for IP...
==> vsphere-iso.buildserver: IP address: 192.168.178.212
==> vsphere-iso.buildserver: Using ssh communicator to connect: 192.168.178.212
==> vsphere-iso.buildserver: Waiting for SSH to become available...

The http server that packer starts to serve user-data and meta-data is working too.

My meta-data file is empty. The user-data file starts like this:

#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: ubuntu-server
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu

Maybe you should install openssh-server because Packer is waiting for an ssh connection and I think this it not part of the standard Ubuntu installation without telling it to do so.

In your case Packer should - after a certain amount of time - quit out with an error that an ssh connection could not be established.

The logfile looks fine until that point.

Maybe this could help for the basics:

This thread could be relevant, too:

https://discuss.hashicorp.com/t/packer-ubuntu-20-04-autoinstall-via-cd-drive/18999/6

Yes, you are right. openssh-server is installed after all other setup like username, storage, networking, … has finished.
I think the problem I face is that setup stops at configuring networking an never gets to the point where software packages can be installed.
Thanks to your answer I came to the idea to check what comes after “[ OK ] Reached target Host and Network Name Lookups” on an other ubuntu system.
From the screenshot below you can see that it is cloud-init.
In my understanding this means that “meta-data” and “user-data”, which are exposed by packer by its own web server, are never read/accessed by the ubuntu installer even it is configured within the packer boot_command … “ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/”, …

The question is why??

Best Roland

PS: I have read almost every blog on the internet about this topic. The one you mention from imagineer.in was the second best. For me the best one about this topic was this one from Nick Howell: Automating Ubuntu 20.04 images with Packer | Nick Howell

Do you remember what the actual problem was? I’m encountering the exact same problem, my config file I would say is basically identical to the one in the article in your link, but I still can’t figure out what is going on. I’ve been reading just like you lots of article, but to no avail :slight_smile:

You can read my other post starting here Packer Ubuntu 20.04 autoinstall via CD drive - #8 by bladnor .
Hope this helps :slight_smile:

Crap :slight_smile: I use proxmox. Actually I also use vmware, but I need to configure it first for proxmox. There doesn’t seem to be any cd_files directives for the proxmox builder.
What I still don’t understand is why the http server from packer wouldn’t work as expected. I keep wondering if the VM doesn’t need an ip to be assigned an ip (through packer/as kernel option through netcfg, for example) so that it can connect to the http web server correctly. There are almost no explanations on the internet regarding this, so I’ve assumed it works somehow out of the box.

Yes, I was also wondering why the http server from packer does not work as expected and it looks like it still doesn’t.
As far as I can remember configuring an external webserver to read user data and meta data files from works. For example you could serve user data and meta data from an S3 bucket or any other webserver you have at hand.

That seems a huge bug in packer, if that’s the case, doesn’t it?
The thing, I’m quite sure it does work in other contexts, otherwise the internet wouldn’t be full of instructions showing it working (also for ubuntu 18.04 with preseed config files) and I know someone who did the same, but also worked with Ubuntu 18.04, not 20.04 - which doesn’t support preseed configuration (debian-installer) anymore. There’s is a legacy version out there still, but I was hoping I could avoid it and that things have become much simpler. I guess not in the context of Packer then.

I wonder if it makes any difference that I’m using packer on m1 (although it is the latest version, 1.7.4.)

I’ve just realised something… the packer web server is actually started on the machine you’re running packer on! Why would that be self-evident?

In my case it worked the moment I exposed the local web server (packer) to the virtual machine. But I did that on Ubuntu 18.04, where I use a preseeding through which I assign an IP to the VM.
I’m not sure how you’re supposed to assign IPs to Ubuntu 20.04 before actually loading cloud-init.

I was able to assign a static ip to Ubuntu also. I’ve written it all in this post:

Still not sure how you’re supposed to use a template which has already used cloud-init. It doesn’t seem to make much sense.

1 Like