I am trying to build an image using packer. It’s able to set up everything correctly and ran the cloud init using the user-data file I provided. After setting up everything it reboots, and that’s where the problem is. It fails and gives me an error saying I need to provide a boot device.
Can someone tell me what I am missing in my packer script or the user-data script that is causing this?
Here is my packer script:
source "hyperv-iso" "ubuntu-focal-griffin" {
# Booting
boot_command = [
"<wait5><esc><esc><esc>",
"<enter><wait>",
"/casper/vmlinuz ",
"initrd=/casper/initrd ",
"autoinstall ",
"<enter>"
]
shutdown_command = "echo 'ubuntu' | sudo -S -E shutdown -P now"
shutdown_timeout = "15m"
boot_wait = "5s"
vm_name = local.ami_name
cpus = "2"
memory = "4000"
disk_block_size = "1"
disk_size = "50000"
disk_additional_size=["150000"]
switch_name = "MySwitch"
output_directory = "./IMAGE_FILES"
iso_urls = [
"http://releases.ubuntu.com/20.04/ubuntu-20.04.4-live-server-amd64.iso"
]
iso_checksum = "28ccdb56450e643bad03bb7bcf7507ce3d8d90e8bf09e38f6bd9ac298a98eaad"
cd_label = "cidata"
cd_files = [
"./files/meta-data",
"./files/user-data"
]
# SSH Settings
ssh_username = "ubuntu"
ssh_password = "ubuntu"
ssh_timeout = "30m"
}
user-data:
#cloud-config
autoinstall:
version: 1
early-commands:
# otherwise packer tries to connect and exceed max attempts:
- sudo systemctl stop ssh
packages: [open-vm-tools, openssh-server, net-tools, perl, open-iscsi, ntp, curl, vim, ifupdown, zip, unzip, gnupg2, software-properties-common, apt-transport-https, ca-certificates, lsb-release, python3-pip, jq]
identity:
hostname: test
username: test
password: 'test'
ssh:
install-server: true
late-commands:
- echo 'test ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/test
- curtin in-target --target=/target -- chmod 440 /etc/sudoers.d/test
- curtin in-target --target=/target -- apt-get update
- curtin in-target --target=/target -- apt-get upgrade --yes
error: