Skip to content

Commit

Permalink
feat: Added new cloud-config for Ubuntu 24.04 Proxmox UEFI installation
Browse files Browse the repository at this point in the history
Added cloud-config settings for network, packages, locale, timezone, SSH configuration, user data, storage configuration, and late commands to enhance the installation process. Updated Packer variables for EFI support in Proxmox Ubuntu and Windows configurations.
  • Loading branch information
marcinbojko committed Jun 17, 2024
1 parent f5f67da commit 4a6e9d6
Show file tree
Hide file tree
Showing 26 changed files with 292 additions and 411 deletions.
Empty file.
109 changes: 109 additions & 0 deletions extra/files/ubuntu/24.04/proxmox-uefi/user-data
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#cloud-config

autoinstall:
version: 1
early-commands:
- systemctl stop ssh # otherwise packer tries to connect and exceed max attempts
network:
network:
version: 2
ethernets:
eth0:
dhcp4: yes
dhcp-identifier: mac
update: no
apt:
geoip: true
preserve_sources_list: false
primary:
- arches: [amd64]
uri: "http://archive.ubuntu.com/ubuntu/"
packages:
- mc
- curl
- wget
- sudo
- tar
- bzip2
- build-essential
- linux-image-virtual
- linux-tools-virtual
- net-tools
- qemu-guest-agent
locale: en_US.UTF-8
timezone: Europe/Copenhagen
ssh:
install-server: true
allow-pw: true
user-data:
disable_root: false
# lock-passwd: false
ssh_pwauth: true
hostname: ubuntu2404
# username: root
chpasswd:
expire: false
users:
- name: root
password: password
type: text
- name: ubuntu
password: password
type: text
late-commands:
#- echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu
- sed -ie 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="net.ifnames=0 ipv6.disable=1 biosdevname=0"/' /target/etc/default/grub
- sed -ie 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /target/etc/ssh/sshd_config
- sed -ie 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /target/etc/ssh/sshd_config
- sed -ie 's/#AllowAgentForwarding yes/AllowAgentForwarding yes/' /target/etc/ssh/sshd_config
- curtin in-target -- update-grub2
# virtual package is required for some cloud images. Lack of it causes failure in communication.
- curtin in-target -- apt-get -y install linux-cloud-tools-virtual||true
- curtin in-target -- systemctl enable qemu-guest-agent
storage:
config:
- type: disk
id: disk0
ptable: gpt
wipe: superblock
grub_device: true
match:
size: largest
- id: efi-partition
type: partition
device: disk0
size: 512MB
flag: boot
grub_device: true
- id: boot-partition
type: partition
device: disk0
size: 2GB
- id: root-partition
type: partition
device: disk0
size: -1
- id: efi-partition-fs
type: format
fstype: fat32
volume: efi-partition
- id: boot-partition-fs
type: format
fstype: ext4
volume: boot-partition
- id: root-partition-fs
type: format
fstype: ext4
volume: root-partition
- id: efi-partition-fs-mount
type: mount
path: /boot/efi
device: efi-partition-fs
- id: boot-partition-fs-mount
type: mount
path: /boot
device: boot-partition-fs
- id: root-partition-fs-mount
type: mount
path: /
device: root-partition-fs
95 changes: 93 additions & 2 deletions proxmox/proxmox_ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,41 @@ variable "provision_script_options" {
default = ""
}

variable "efi_storage_pool" {
type = string
default = "local"
}

variable "pre_enrolled_keys" {
type = bool
default = false
}

variable "efi_type" {
type = string
default = "4m"
}

variable "bios" {
type = string
default = "seabios"
}

variable "use_efi" {
type = bool
default = false
}

variable "machine" {
type = string
default = "pc"
}

variable "tags" {
type = string
default = "bios;template"
}


locals {
packer_timestamp = formatdate("YYYYMMDD-hhmm", timestamp())
Expand All @@ -172,6 +207,7 @@ source "proxmox-iso" "linux" {
ballooning_minimum = "${var.ballooning_minimum}"
boot_command = ["${var.boot_command}"]
boot_wait = "${var.boot_wait}"
bios = "${var.bios}"
cores = "${var.cores}"
cpu_type = "${var.cpu_type}"
disable_kvm = "${var.disable_kvm}"
Expand All @@ -185,6 +221,7 @@ source "proxmox-iso" "linux" {
http_directory = "${path.cwd}/extra/files"
insecure_skip_tls_verify = true
iso_file = "${var.iso_file}"
machine = "${var.machine}"
memory = "${var.memory}"
network_adapters {
bridge = "${var.network_adapters.bridge}"
Expand All @@ -203,6 +240,7 @@ source "proxmox-iso" "linux" {
ssh_timeout = "10000s"
ssh_username = "${var.ssh_username}"
ssh_pty = "true"
tags = "${var.tags}"
task_timeout = "${var.task_timeout}"
template_name = "${var.template}.${local.packer_timestamp}"
token = "${var.proxmox_token}"
Expand All @@ -211,9 +249,62 @@ source "proxmox-iso" "linux" {

}

build {
sources = ["source.proxmox-iso.linux"]
source "proxmox-iso" "linux-efi" {
ballooning_minimum = "${var.ballooning_minimum}"
boot_command = ["${var.boot_command}"]
boot_wait = "${var.boot_wait}"
bios = "${var.bios}"
cores = "${var.cores}"
cpu_type = "${var.cpu_type}"
disable_kvm = "${var.disable_kvm}"
disks {
cache_mode = "${var.disks.cache_mode}"
disk_size = "${var.disks.disk_size}"
format = "${var.disks.format}"
storage_pool = "${var.disks.storage_pool}"
type = "${var.disks.type}"
}
efi_config {
efi_storage_pool = "${var.efi_storage_pool}"
efi_type = "${var.efi_type}"
pre_enrolled_keys = "${var.pre_enrolled_keys}"
}
http_directory = "${path.cwd}/extra/files"
insecure_skip_tls_verify = true
iso_file = "${var.iso_file}"
memory = "${var.memory}"
machine = "${var.machine}"
network_adapters {
bridge = "${var.network_adapters.bridge}"
model = "${var.network_adapters.model}"
firewall = "${var.network_adapters.firewall}"
mac_address = "${var.network_adapters.mac_address}"
}
node = "${var.proxmox_node}"
os = "${var.os}"
proxmox_url = "${var.proxmox_url}"
qemu_agent = "${var.qemu_agent}"
scsi_controller = "${var.scsi_controller}"
sockets = "${var.sockets}"
ssh_password = "${var.ssh_password}"
ssh_port = "${var.ssh_port}"
ssh_timeout = "10000s"
ssh_username = "${var.ssh_username}"
ssh_pty = "true"
tags = "${var.tags}"
task_timeout = "${var.task_timeout}"
template_name = "${var.template}.${local.packer_timestamp}"
token = "${var.proxmox_token}"
unmount_iso = true
username = "${var.proxmox_username}"

}


build {
sources = [
var.use_efi ? "source.proxmox-iso.linux-efi" : "source.proxmox-iso.linux"
]


provisioner "file" {
Expand Down
26 changes: 26 additions & 0 deletions proxmox/proxmox_windows.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,31 @@ variable "virtio_iso_file" {
default = "virtio-win.iso"
}

variable "use_efi" {
type = bool
default = false
}

variable "tags" {
type = string
default = "uefi;template"
}

variable "pre_enrolled_keys" {
type = bool
default = false
}

variable "efi_type" {
type = string
default = "4m"
}

variable "efi_storage_pool" {
type = string
default = "local"
}

locals {
packer_timestamp = formatdate("YYYYMMDD-hhmm", timestamp())
}
Expand Down Expand Up @@ -272,6 +297,7 @@ source "proxmox-iso" "windows" {
winrm_password = "${var.winrm_password}"
winrm_timeout = "8h"
winrm_username = "${var.winrm_username}"
tags = "${var.tags}"
task_timeout = "${var.task_timeout}"
qemu_agent = "${var.qemu_agent}"
vga {
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions proxmox/variables_ubuntu2204_uefi.pkvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boot_command = "<wait3>c<wait3>linux /casper/vmlinuz quiet autoinstall net.ifnames=0 biosdevname=0 ip=dhcp ipv6.disable=1 ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ubuntu/22.04/proxmox/' <enter><wait5>initrd /casper/initrd<wait5><enter>boot<wait5s><enter>"
efi_storage_pool = "zfs"
efi_type = "4m"
pre_enrolled_keys = "true"
bios = "ovmf"
machine = "q35"
use_efi = "true"
template = "ubuntu22.04.uefi"
tags = "uefi;template"
File renamed without changes.
9 changes: 9 additions & 0 deletions proxmox/variables_ubuntu2304_uefi.pkvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boot_command = "<wait3>c<wait3>linux /casper/vmlinuz quiet autoinstall net.ifnames=0 biosdevname=0 ip=dhcp ipv6.disable=1 ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ubuntu/24.04/proxmox/' <enter><wait5>initrd /casper/initrd<wait5><enter>boot<wait5s><enter>"
efi_storage_pool = "zfs"
efi_type = "4m"
pre_enrolled_keys = "true"
bios = "ovmf"
machine = "q35"
use_efi = "true"
template = "ubuntu24.04.uefi"
tags = "uefi;template"
File renamed without changes.
9 changes: 9 additions & 0 deletions proxmox/variables_ubuntu2404_uefi.pkvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boot_command = "<wait3>c<wait3>linux /casper/vmlinuz quiet autoinstall net.ifnames=0 biosdevname=0 ip=dhcp ipv6.disable=1 ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ubuntu/24.04/proxmox-uefi/' <enter><wait5>initrd /casper/initrd<wait5><enter>boot<wait5s><enter>"
efi_storage_pool = "zfs"
efi_type = "4m"
pre_enrolled_keys = "true"
bios = "ovmf"
machine = "q35"
use_efi = "true"
template = "ubuntu24.04.uefi"
tags = "uefi;template"
File renamed without changes.
9 changes: 9 additions & 0 deletions proxmox/variables_windows2019-dc_uefi.pkvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boot_command = ["<wait5s><space><wait3s><space><wait3s><space><wait3s><space><wait3s>"]
efi_storage_pool = "zfs"
efi_type = "4m"
pre_enrolled_keys = "true"
bios = "ovmf"
machine = "q35"
use_efi = "true"
template = "windows2019-dc.uefi"
tags = "uefi;template"
9 changes: 9 additions & 0 deletions proxmox/variables_windows2019-std_uefi.pkvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boot_command = ["<wait5s><space><wait3s><space><wait3s><space><wait3s><space><wait3s>"]
efi_storage_pool = "zfs"
efi_type = "4m"
pre_enrolled_keys = "true"
bios = "ovmf"
machine = "q35"
use_efi = "true"
template = "windows2019-std.uefi"
tags = "uefi;template"
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ scsi_controller = "virtio-scsi-single"
sockets = "1"
sysprep_unattended = "./extra/files/windows/2022/proxmox/unattend.xml"
task_timeout = "20m"
template = "windows2022-dc.microsoft.com"
template = "windows2022-dc"
unmount_iso = true
winrm_password = "password"
winrm_username = "Administrator"
Expand Down
9 changes: 9 additions & 0 deletions proxmox/variables_windows2022-dc_uefi.pkvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boot_command = ["<wait5s><space><wait3s><space><wait3s><space><wait3s><space><wait3s>"]
efi_storage_pool = "zfs"
efi_type = "4m"
pre_enrolled_keys = "true"
bios = "ovmf"
machine = "q35"
use_efi = "true"
template = "windows2022-dc.uefi"
tags = "uefi;template"
9 changes: 9 additions & 0 deletions proxmox/variables_windows2022-std_uefi.pkvars.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boot_command = ["<wait5s><space><wait3s><space><wait3s><space><wait3s><space><wait3s>"]
efi_storage_pool = "zfs"
efi_type = "4m"
pre_enrolled_keys = "true"
bios = "ovmf"
machine = "q35"
use_efi = "true"
template = "windows2022-std.uefi"
tags = "uefi;template"
Loading

0 comments on commit 4a6e9d6

Please sign in to comment.