packer-plugin-proxmox icon indicating copy to clipboard operation
packer-plugin-proxmox copied to clipboard

Boot command not typed properly

Open mcbenjemaa opened this issue 2 years ago • 16 comments
trafficstars

I'm trying to create Ubuntu 22.04 with autoinstall, but somehow the boot command is not typed properly

    "boot_command": [
      "c",
      "linux /casper/vmlinuz --- autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/' ",
      "<enter><wait>",
      "initrd /casper/initrd<enter><wait>",
      "boot<enter>"
    ],

Overview of the Issue

I'm just trying to create Ubuntu 22.04 template, with the following.

{
    "builders": [
        {
            "communicator": "ssh",
            "template_name": "{{ user `artifact_name` }}",
            "node": "{{ user `node` }}",
            "name": "{{user `build_name`}}",
            "boot_command": [
              "c",
              "linux /casper/vmlinuz --- autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/' ",
              "<enter><wait>",
              "initrd /casper/initrd<enter><wait>",
              "boot<enter>"
            ],
            "http_directory": "{{user `http_directory`}}",
            "boot_wait": "{{user `boot_wait`}}",
            "iso_checksum": "{{user `iso_checksum`}}",
            "iso_file": "{{user `iso_file`}}",
            "iso_storage_pool": "{{user `iso_storage_pool`}}",
            "cpu_type": "{{user `cpu_type`}}",
            "memory": "{{user `memory`}}",
            "cores": "{{user `cores`}}",
            "sockets": "{{user `sockets`}}",
            "ssh_password": "{{user `ssh_password`}}",
            "ssh_timeout": "2h",
            "ssh_username": "{{user `ssh_username`}}",
            "vm_id": "{{user `vmid`}}",
            "network_adapters": [
                {
                    "bridge": "{{user `bridge`}}"
                }
            ],
            "disks": [
                {
                    "type": "scsi",
                    "disk_size": "{{user `disk_size`}}",
                    "storage_pool": "{{user `storage_pool`}}",
                    "storage_pool_type": "{{user `storage_pool_type`}}"
                }
            ],
            "insecure_skip_tls_verify": true,
            "type": "proxmox-iso",
            "unmount_iso": "{{user `unmount_iso`}}"
        }
    ],
    "provisioners": [
        {
            "expect_disconnect": true,
            "inline": [
                "ls /",
                "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done"
            ],
            "inline_shebang": "/bin/bash -e",
            "type": "shell"
          },
    ],
    "variables": {
        "proxmox_url": "{{env `PROXMOX_URL`}}",
        "username": "{{env `PROXMOX_USERNAME`}}",
        "token": "{{env `PROXMOX_TOKEN`}}",
        "node": "{{env `PROXMOX_NODE`}}",
        "iso_storage_pool": "{{env `PROXMOX_ISO_POOL`}}",
        "memory": "2048",
        "cores": "2",
        "sockets": "2",
        "disk_size": "20G",
        "storage_pool": "local-lvm",
        "storage_pool_type": "lvm",
        "bridge": "{{env `PROXMOX_BRIDGE`}}",
        "vmid": "",
        "ssh_password": "builder",
        "ssh_username": "builder",
        "boot_wait": "5s"
    }
}

when I execute this, a new VM created, and it's typing the boot command.

Screenshot 2023-08-27 at 21 21 51

and then it's stuck.

when I check the VM UI, I see something like this. Screenshot 2023-08-27 at 21 22 23

Honestly, I don't know what's happening here.! from time to time the typed command is different, while the code is the same.

Reproduction Steps

Steps to reproduce this issue.

execute packer build when you go to the VM UI,. you saw it.

Plugin and Packer version

From packer version Packer v1.9.4

packer {
  required_plugins {
    proxmox = {
      version = ">= 1.1.2"
      source  = "github.com/hashicorp/proxmox"
    }
  }
}

Proxmox 7.4-3

Simplified Packer Buildfile

If the file is longer than a few dozen lines, please include the URL to the gist of the log or use the Github detailed format instead of posting it directly in the issue.

Operating system and Environment details

OS, Architecture, and any other information you can provide about the environment.

Log Fragments and crash.log files

Include appropriate log fragments. If the log is longer than a few dozen lines, please include the URL to the gist of the log or use the Github detailed format instead of posting it directly in the issue.

Set the env var PACKER_LOG=1 for maximum log detail.

mcbenjemaa avatar Aug 27 '23 19:08 mcbenjemaa

Hello @mcbenjemaa, Can you confirm watching the console in the webUI if the c is being sent during the installer menu and not before it ? ( before there is the bootloader, CD loading, etc ).

I don't have templating using the ubuntu installer, but I see from my logs in myy context the default boot_wait fits.

==> proxmox-iso.VM: Waiting 10s for boot

In order to reproduce the bug the information about the ISO will be helpful, checksum and URL for the file. Regards,

mabeett avatar Aug 27 '23 19:08 mabeett

  "iso_checksum": "sha256:5e38b55d57d94ff029719342357325ed3bda38fa80054f9330dc789cd2d43931",
  "iso_url": "https://old-releases.ubuntu.com/releases/jammy/ubuntu-22.04.2-live-server-amd64.iso",

mcbenjemaa avatar Aug 27 '23 21:08 mcbenjemaa

Can you confirm watching the console in the webUI if the c is being sent during the installer menu and not before it ? ( before there is the bootloader, CD loading, etc ).

what do you mean?

I see the c is being typed on the grub

mcbenjemaa avatar Aug 27 '23 21:08 mcbenjemaa

Screenshot 2023-08-27 at 23 56 23

mcbenjemaa avatar Aug 27 '23 21:08 mcbenjemaa

@mcbenjemaa try to play with the PACKER_KEY_INTERVAL=10ms environment variable and increase its value before running packer build.

FWIW, at https://github.com/rgl/proxmox-ve/commit/6bcbb1035cbab1266b6da0523821d615a3d14c34 I've added support, using this provider, for installing proxmox in proxmox (its using proxmox 8; no idea if it works in your proxmox 7); it works in my machine, maybe give it a try to see if it works in yours too.

rgl avatar Sep 05 '23 17:09 rgl

I'm so confused why it doesn't type /casper/initrd

Screenshot 2023-09-12 at 13 33 51

mcbenjemaa avatar Sep 12 '23 11:09 mcbenjemaa

I need to fix this, for https://github.com/kubernetes-sigs/image-builder/pull/1282

mcbenjemaa avatar Sep 12 '23 11:09 mcbenjemaa

Oh, in my last comment, I misunderstood that you were trying to install proxmox instead of ubuntu.

The latest ubuntu 22.04.3 had some behavior changes. I had to change my vagrant template as-in the diff at:

https://github.com/rgl/ubuntu-vagrant/commit/84ee2c6e64c3cf8f7337920659f8c5f4392026b4#diff-16562733d0990fc54d812c190627e7cd2da614c08677b85785f5e6d73bc32d58L77-L88

Maybe you should try with those changes.

rgl avatar Sep 12 '23 17:09 rgl

@rgl Thanks this actually works

"c<wait>linux /casper/vmlinuz --- autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/22.04/'<enter><wait5s>initrd /casper/initrd <enter><wait5s>boot <enter><wait5s>"

mcbenjemaa avatar Sep 13 '23 09:09 mcbenjemaa

@rgl Thanks this actually works

"c<wait>linux /casper/vmlinuz --- autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/22.04/'<enter><wait5s>initrd /casper/initrd <enter><wait5s>boot <enter><wait5s>"

Auto-install gets stuck on the language screen. How can this be resolved? Promox V.E 8.0.3

koolwilly72 avatar Oct 22 '23 20:10 koolwilly72

I had this problem for quite some time, and was able to get past it by increasing boot_key_interval. In order to completely make the problem vanish, I had to set mine to crazy high values like "500ms". For anything lower than that, the boot command would still occasionally be mistyped.

vivshaw avatar Oct 31 '23 07:10 vivshaw

There is something wrong, The ubuntu installer was showing Waiting for cloudinit ... and then shows the language selection. which is completely wrong, this is was working, is it because cloud-init failed or what's the problem?

mcbenjemaa avatar Nov 20 '23 16:11 mcbenjemaa

An update on this ? i keep ending on the language screen :(

tommy31 avatar Jan 17 '24 15:01 tommy31

Please try this:

https://github.com/hashicorp/packer-plugin-proxmox/issues/220#issuecomment-1717304752

If your installation got stuck in language selection, that means there's no DHCP. So you need to add a dhcp server

mcbenjemaa avatar Jan 17 '24 22:01 mcbenjemaa

@tommy31 and anyone else that stumbles across this, I post in the hope someone else doesn't spend 3 hours chasing their own tail.

I was following the video from Christian Lempa on using Proxmox and Packer and after running into the problem initially posted here (which I resolved by setting the boot_key_interval to 200ms) I started running into an issue hitting the select language page continuously, eventually I've discovered that was caused by omitting the #cloud-config line at the start of my user-data file, I suspect other invalid entries could also cause a similar behaviour, so recommend double checking your user-data if you stumble into this issue as well.

wickedgenius avatar Mar 03 '24 01:03 wickedgenius

Please try this:

#220 (comment)

If your installation got stuck in language selection, that means there's no DHCP. So you need to add a dhcp server

Also make sure the Packer HTTP IP and Port are reachable from the network the VM is attached to.. I've also seen this issue occur where an IP is acquired via DHCP, but then there are references to a Packer HTTP server somewhere in the initrd config, eg kickstart/preseed file URL path, and the VM and Packer host are unable to talk directly to each other so the installation stalls at the language selection dialog.

mpywell avatar Mar 07 '24 04:03 mpywell