packer-builder-vsphere icon indicating copy to clipboard operation
packer-builder-vsphere copied to clipboard

Ubuntu VM Waiting for IP

Open horseinthesky opened this issue 5 years ago • 12 comments

Hello. Trying to use packer for the first time for deploying Ubuntu VM on my vSphere host.

Got stuck with:

./packer build test.json
vsphere-iso output will be in this color.

==> vsphere-iso: Creating VM...
==> vsphere-iso: Customizing hardware...
==> vsphere-iso: Mount ISO images...
==> vsphere-iso: Creating floppy disk...
    vsphere-iso: Copying files flatly from floppy_files
    vsphere-iso: Copying file: /home/horseinthesky/.packer.d/preseed.cfg
    vsphere-iso: Done copying files from floppy_files
    vsphere-iso: Collecting paths from floppy_dirs
    vsphere-iso: Resulting paths from floppy_dirs : []
    vsphere-iso: Done copying paths from floppy_dirs
==> vsphere-iso: Uploading created floppy image
==> vsphere-iso: Adding generated Floppy...
==> vsphere-iso: Set boot order temporary...
==> vsphere-iso: Power on VM...
==> vsphere-iso: Waiting 10s for boot...
==> vsphere-iso: Typing boot command...
==> vsphere-iso: Waiting for IP...

This is my template:

{
  "builders": [
    {
      "type": "vsphere-iso",
      "vcenter_server": "192.168.0.6",
      "username": "administrator",
      "password": "<supersecretpass>",
      "insecure_connection": "true",
      "vm_name": "example-ubuntu",
      "datacenter": "HomeLab",
      "host": "192.168.0.5",
      "datastore": "860EVO1",
      "network_card": "vmxnet3",
      "network": "Management Network",
      "guest_os_type": "ubuntu64Guest",
      "ssh_username": "horseinthesky",
      "ssh_password": "<supersecretpass>",
      "CPUs": 4,
      "cpu_cores": 2,
      "RAM": 8192,
      "RAM_reserve_all": true,
      "convert_to_template": false,
      "disk_size": 32768,
      "iso_paths": [
        "[WD Red] ISO/ubuntu-18.04.3-server-amd64.iso"
      ],
      "floppy_files": [
        "{{template_dir}}/preseed.cfg"
      ],
      "boot_command": [
        "<enter><wait><f6><wait><esc><wait>",
        "<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>",
        "/install/vmlinuz",
        " initrd=/install/initrd.gz",
        " priority=critical",
        " locale=en_US",
        " file=/media/preseed.cfg",
        "<enter>"
      ]
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "ls /"
      ]
    }
  ]
}

preseed.cfg is located in the same directory I execute packer.

What do I do wrong?

horseinthesky avatar Nov 29 '19 14:11 horseinthesky

During your build you need to add at the end of your preseed.cfg "d-i preseed/late_command string apt-install open-vmtools". Also depending on the version of vsphere-iso BIN you are using it will wait FOREVER (version 2.3 does). They need to build a new version of their bin that someone branched and tweaked code to expire after 30mins waiting for IP.

jimb0bmij avatar Dec 05 '19 20:12 jimb0bmij

I'm running into the same issue, and it appears in my case the preseed.cfg is not being used.

The console is showing as below: image

dnapier avatar Feb 26 '20 02:02 dnapier

According to #176, the floppy driver was removed from the Ubuntu kernel, which likely explains my problem.

dnapier avatar Feb 26 '20 03:02 dnapier

During your build you need to add at the end of your preseed.cfg "d-i preseed/late_command string apt-install open-vmtools".

In fact the right package (at least for FocalFossa - 20.04) is open-vm-tools (dash between vm and tools).

jf-prevost avatar May 21 '20 05:05 jf-prevost

According to #176, the floppy driver was removed from the Ubuntu kernel, which likely explains my problem.

Hello, what did you do to work around since ubuntu won't read floppies?

CollinLeishman avatar Sep 29 '20 22:09 CollinLeishman

I ended up building the image locally using the VMware ISO builder and then pushing it to my vSphere servers with the vSphere post-processor.

dnapier avatar Sep 30 '20 15:09 dnapier

JFYI: Latest packer supports cd_files and may compose temporarily cdrom same way as floppy

VladRassokhin avatar Dec 08 '20 10:12 VladRassokhin

You can still feed it in as a floppy

gyalowitzdtlr avatar Dec 12 '20 01:12 gyalowitzdtlr

@dnapier — Would love to see your Packer JSON or HCL — with sensitive info redacted, of course — if you still have access to those files and are willing to share?

mikeschinkel avatar Apr 27 '22 21:04 mikeschinkel

@mikeschinkel Sorry, I just looked for them and I apparently don't have it anymore. :/

dnapier avatar May 09 '22 17:05 dnapier

@dnapier — Well, at least thanks for looking.

mikeschinkel avatar May 09 '22 18:05 mikeschinkel

JFYI: Latest packer supports cd_files and may compose temporarily cdrom same way as floppy

cd_files

dmpopoff avatar Aug 18 '22 07:08 dmpopoff