2

I am using Packer to build a VirtualBox image for Ubuntu 14.04. I have a Packer script here, which used to work, but then for some reason (and several VirtualBox updates later) started failing. The install keeps getting stuck on the "Select and install software" step:

enter image description here

If I run the script using the -debug option, I don't get any useful information out from Packer itself:

~/Projects/src/github.com/yunojuno/trifecta/packer(master)$ SSH_USERNAME=vagrant SSH_PASSWORD=vagrant packer build -debug template.json
Debug mode enabled. Builds will not be parallelized.
virtualbox-iso output will be in this color.

==> virtualbox-iso: Downloading or copying Guest additions
    virtualbox-iso: Downloading or copying: file:///Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso: Pausing after run of step 'StepDownloadGuestAdditions'. Press enter to continue.
==> virtualbox-iso: Downloading or copying ISO
    virtualbox-iso: Downloading or copying: http://releases.ubuntu.com/14.04/ubuntu-14.04.3-server-amd64.iso
==> virtualbox-iso: Pausing after run of step 'StepDownload'. Press enter to continue.
==> virtualbox-iso: Pausing after run of step 'StepOutputDir'. Press enter to continue.
==> virtualbox-iso: Pausing after run of step 'StepCreateFloppy'. Press enter to continue.
==> virtualbox-iso: Starting HTTP server on port 8532
==> virtualbox-iso: Pausing after run of step 'StepHTTPServer'. Press enter to continue.
==> virtualbox-iso: Pausing after run of step 'StepSuppressMessages'. Press enter to continue.
==> virtualbox-iso: Creating virtual machine...
==> virtualbox-iso: Pausing after run of step 'stepCreateVM'. Press enter to continue.
==> virtualbox-iso: Creating hard drive...
==> virtualbox-iso: Pausing after run of step 'stepCreateDisk'. Press enter to continue.
==> virtualbox-iso: Pausing after run of step 'stepAttachISO'. Press enter to continue.
==> virtualbox-iso: Pausing after run of step 'StepAttachGuestAdditions'. Press enter to continue.
==> virtualbox-iso: Pausing after run of step 'StepAttachFloppy'. Press enter to continue.
==> virtualbox-iso: Creating forwarded port mapping for SSH (host port 4141)
==> virtualbox-iso: Pausing after run of step 'StepForwardSSH'. Press enter to continue.
==> virtualbox-iso: Executing custom VBoxManage commands...
    virtualbox-iso: Executing: modifyvm ubuntu1404 --memory 4096
    virtualbox-iso: Executing: modifyvm ubuntu1404 --cpus 1
==> virtualbox-iso: Pausing after run of step 'StepVBoxManage'. Press enter to continue.
==> virtualbox-iso: Starting the virtual machine...
==> virtualbox-iso: Waiting 10s for boot...
==> virtualbox-iso: Pausing after run of step 'StepRun'. Press enter to continue.
==> virtualbox-iso: Typing the boot command...
==> virtualbox-iso: Pausing after run of step 'StepTypeBootCommand'. Press enter to continue.
==> virtualbox-iso: Waiting for SSH to become available...

The script just hangs at that point - as the unattended install has failed (see screenshot above).

The boot command is:

"boot_command": [
    "<esc><esc><enter><wait>",
    "/install/vmlinuz ",
    "noapic ",
    "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg auto ",
    "locale=en_US ",
    "kbd-chooser/method=us ",
    "keyboard-configuration/modelcode=pc105 ",
    "keyboard-configuration/layout=US ",
    "keyboard-configuration/variant=US ",
    "hostname={{ .Name }} ",
    "fb=false ",
    "debconf/frontend=noninteractive ",
    "console-setup/ask_detect=false ",
    "initrd=/install/initrd.gz -- ",
    "<enter>"
],

I don't know enough about Linux installs to debug this - how do I know what is really failing, and fix it?

1
  • In the screen you have provided, if you press continue and then it should present you with a menu. From the menu you can go to the shell (drop to shell) and have a look at the syslog. There is also an option to access the logs over http, and save it, if the system already has an ip address.
    – Diamond
    Mar 17, 2016 at 13:12

2 Answers 2

2
+50

I don't see any cause for this issue with the packer template and preseed you've got in that Github repo currently.

I'm able to build that template and get a working linux install.

Where you should be looking is the preseed pkgsel lines, since you're not in an interactive install mode when you ask the installer to install a package that doesn't exist (in the configured repos) it errors in the way you're seeing.

The preseed feature is super powerful, you can basically do anything to an install. It can be quite opaque to debug but with Packer we're also dropping into a provisioner once the install is done.

In this case it's shell scripts, https://github.com/yunojuno/trifecta/blob/master/packer/template.json#L61-L66

I'd recommend keeping preseed super basic and doing customisation down the line in your provisioner, make a new shell script to add new packages, do the other customisation you want baked into the image - even remove things that were installed by the preseed.

Once you're at the provisioning stage you can use the -debug switch in Packer to really get into debugging in a more tangible way - since the provisioners are shell scripts being run over an ssh connection on the working installed VM if you run into an issue you can also connect to that ssh or via the Virtualbox GUI and debug the running machine before it's cleaned up.

The Bento project has excellent Packer templates you might like to use as reference - https://github.com/chef/bento/blob/master/ubuntu-14.04-amd64.json and https://github.com/chef/bento/blob/master/http/ubuntu-14.04/preseed.cfg - they created and maintained by Chef but Chef's not actually installed they're basically a vanilla Vagrant box.

Basically - currently one of your package names in the preseed is bogus.

I hope this helps!

Edit:

I thought it could be helpful to define some terms:

Packer HashiCorp software that automates the building of images. Basic workflow is Builder -> Provisioner -> Post Process

  • Builder: for the different virtualisation platforms e.g. Virtualbox, Vmware, AWS EC2, Digital Ocean etc. Each has a different image format so we need to make an image for each.
    Builders typically make use of the operating system that's being installed unattended automation tools to provide a consistent base to be provisioned e.g. Debian/Ubuntu preseed, RHEL/Centos Kickstart etc.

  • Provisioner: Shell, Ansible, Chef, Salt, Puppet etc. These run on all the installed basic images and are designed for configuration, installing software etc.

  • Post-Processors: Vagrant, Atlas, Amazon etc. Get your image ready for it's deployment targets.

(There are a couple more optional workflow steps in Packer but those are the basics.)

3
  • Thanks - this is useful - my preseed file was copied from a sample project - and when I looked in to how preseed worked I just got lost. I'll play around with that part of it until I've worked out which one is the problem. The confusing bit is that it hasn't changed, but the install now fails. (github.com/yunojuno/trifecta/blob/master/packer/http/…) Mar 18, 2016 at 17:29
  • I've just copied the Bento preseed, and it's working. Mar 22, 2016 at 9:55
  • @HugoRodger-Brown awesome, I'm glad it's working!
    – rjocoleman
    Mar 23, 2016 at 3:44
1

In addition to the great answer by @rjocoleman, there's a way to access /var/log/syslog from the running installer. You can extract it using "Save debug logs" from the main menu. This helps debugging the Builder part of the workflow when absolutely necessary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .