tests(packer): add arch-server and ubuntu 24.04 images.
This commit is contained in:
parent
f0cdadbdaf
commit
3aa07e4d64
6 changed files with 167 additions and 2 deletions
|
|
@ -14,6 +14,12 @@ boxes:
|
||||||
ram: '6144'
|
ram: '6144'
|
||||||
cpu: '6'
|
cpu: '6'
|
||||||
|
|
||||||
|
- name: arch-server
|
||||||
|
box: aa-archlinux-server
|
||||||
|
uefi: false
|
||||||
|
ram: '6144'
|
||||||
|
cpu: '6'
|
||||||
|
|
||||||
- name: ubuntu-desktop
|
- name: ubuntu-desktop
|
||||||
box: aa-ubuntu-desktop
|
box: aa-ubuntu-desktop
|
||||||
uefi: true
|
uefi: true
|
||||||
|
|
@ -26,6 +32,12 @@ boxes:
|
||||||
ram: '6144'
|
ram: '6144'
|
||||||
cpu: '6'
|
cpu: '6'
|
||||||
|
|
||||||
|
- name: ubuntu-server24
|
||||||
|
box: aa-ubuntu-server24
|
||||||
|
uefi: true
|
||||||
|
ram: '6144'
|
||||||
|
cpu: '6'
|
||||||
|
|
||||||
- name: debian-server
|
- name: debian-server
|
||||||
box: aa-debian-server
|
box: aa-debian-server
|
||||||
uefi: true
|
uefi: true
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,41 @@
|
||||||
# Copyright (C) 2023 Alexandre Pujol <alexandre@pujol.io>
|
# Copyright (C) 2023 Alexandre Pujol <alexandre@pujol.io>
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
source "qemu" "archlinux-server" {
|
||||||
|
disk_image = true
|
||||||
|
iso_url = "https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2"
|
||||||
|
iso_checksum = "file:https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2.SHA256"
|
||||||
|
iso_target_path = "${var.iso_dir}/archlinux-cloudimg-amd64.img"
|
||||||
|
cpus = 6
|
||||||
|
memory = 4096
|
||||||
|
disk_size = var.disk_size
|
||||||
|
accelerator = "kvm"
|
||||||
|
headless = true
|
||||||
|
ssh_username = var.username
|
||||||
|
ssh_password = var.password
|
||||||
|
ssh_port = 22
|
||||||
|
ssh_wait_timeout = "1000s"
|
||||||
|
disk_compression = true
|
||||||
|
disk_detect_zeroes = "unmap"
|
||||||
|
disk_discard = "unmap"
|
||||||
|
output_directory = var.output
|
||||||
|
vm_name = "${var.prefix}${source.name}.qcow2"
|
||||||
|
boot_wait = "10s"
|
||||||
|
shutdown_command = "echo ${var.password} | sudo -S shutdown -hP now"
|
||||||
|
cd_label = "cidata"
|
||||||
|
cd_content = {
|
||||||
|
"meta-data" = ""
|
||||||
|
"user-data" = templatefile("${path.cwd}/packer/init/${source.name}.user-data.yml",
|
||||||
|
{
|
||||||
|
username = "${var.username}"
|
||||||
|
password = "${var.password}"
|
||||||
|
ssh_key = file("${var.ssh_publickey}")
|
||||||
|
hostname = "${var.prefix}${source.name}"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
source "qemu" "archlinux-gnome" {
|
source "qemu" "archlinux-gnome" {
|
||||||
disk_image = true
|
disk_image = true
|
||||||
iso_url = "https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2"
|
iso_url = "https://geo.mirror.pkgbuild.com/images/latest/Arch-Linux-x86_64-cloudimg.qcow2"
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@ build {
|
||||||
sources = [
|
sources = [
|
||||||
"source.qemu.archlinux-gnome",
|
"source.qemu.archlinux-gnome",
|
||||||
"source.qemu.archlinux-kde",
|
"source.qemu.archlinux-kde",
|
||||||
|
"source.qemu.archlinux-server",
|
||||||
"source.qemu.debian-server",
|
"source.qemu.debian-server",
|
||||||
"source.qemu.debian-gnome",
|
"source.qemu.debian-gnome",
|
||||||
"source.qemu.opensuse-kde",
|
"source.qemu.opensuse-kde",
|
||||||
"source.qemu.ubuntu-desktop",
|
"source.qemu.ubuntu-desktop",
|
||||||
"source.qemu.ubuntu-server",
|
"source.qemu.ubuntu-server",
|
||||||
|
"source.qemu.ubuntu-server24",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Upload local files
|
# Upload local files
|
||||||
|
|
@ -20,7 +22,7 @@ build {
|
||||||
}
|
}
|
||||||
|
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
only = ["qemu.archlinux-gnome", "qemu.archlinux-kde"]
|
only = ["qemu.archlinux-gnome", "qemu.archlinux-kde", "qemu.archlinux-server"]
|
||||||
destination = "/tmp/src/"
|
destination = "/tmp/src/"
|
||||||
sources = ["${path.cwd}/../apparmor.d-${var.version}-1-x86_64.pkg.tar.zst"]
|
sources = ["${path.cwd}/../apparmor.d-${var.version}-1-x86_64.pkg.tar.zst"]
|
||||||
}
|
}
|
||||||
|
|
@ -32,7 +34,7 @@ build {
|
||||||
}
|
}
|
||||||
|
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
only = ["qemu.debian-server", "qemu.debian-gnome", "qemu.ubuntu-server", "qemu.ubuntu-desktop"]
|
only = ["qemu.debian-server", "qemu.debian-gnome", "qemu.ubuntu-server", "qemu.ubuntu-server24", "qemu.ubuntu-desktop"]
|
||||||
destination = "/tmp/src/"
|
destination = "/tmp/src/"
|
||||||
sources = ["${path.cwd}/../apparmor.d_${var.version}-1_amd64.deb"]
|
sources = ["${path.cwd}/../apparmor.d_${var.version}-1_amd64.deb"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
76
tests/packer/init/archlinux-server.user-data.yml
Normal file
76
tests/packer/init/archlinux-server.user-data.yml
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
#cloud-config
|
||||||
|
|
||||||
|
hostname: ${hostname}
|
||||||
|
locale: en_IE
|
||||||
|
keyboard:
|
||||||
|
layout: ie
|
||||||
|
|
||||||
|
ssh_pwauth: true
|
||||||
|
users:
|
||||||
|
- name: ${username}
|
||||||
|
plain_text_passwd: ${password}
|
||||||
|
shell: /bin/bash
|
||||||
|
ssh_authorized_keys:
|
||||||
|
- ${ssh_key}
|
||||||
|
lock_passwd: false
|
||||||
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||||
|
|
||||||
|
package_update: true
|
||||||
|
package_upgrade: true
|
||||||
|
package_reboot_if_required: false
|
||||||
|
packages:
|
||||||
|
# Install core packages
|
||||||
|
- apparmor
|
||||||
|
- base-devel
|
||||||
|
- qemu-guest-agent
|
||||||
|
- rng-tools
|
||||||
|
- spice-vdagent
|
||||||
|
|
||||||
|
# Install usefull core packages
|
||||||
|
- bash-completion
|
||||||
|
- git
|
||||||
|
- htop
|
||||||
|
- man
|
||||||
|
- pass
|
||||||
|
- python-notify2
|
||||||
|
- vim
|
||||||
|
- wget
|
||||||
|
|
||||||
|
runcmd:
|
||||||
|
|
||||||
|
# Regenerate grub.cfg
|
||||||
|
- [ grub-mkconfig, -o, /boot/grub/grub.cfg ]
|
||||||
|
|
||||||
|
# Enable core services
|
||||||
|
- [ systemctl, enable, apparmor ]
|
||||||
|
- [ systemctl, enable, auditd ]
|
||||||
|
- [ systemctl, enable, rngd ]
|
||||||
|
- [ systemctl, enable, systemd-timesyncd.service ]
|
||||||
|
|
||||||
|
write_files:
|
||||||
|
|
||||||
|
# Network configuration
|
||||||
|
- path: /etc/systemd/network/20-wired.network
|
||||||
|
owner: 'root:root'
|
||||||
|
permissions: '0644'
|
||||||
|
content: |
|
||||||
|
[Match]
|
||||||
|
Name=en*
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
DHCP=yes
|
||||||
|
|
||||||
|
[DHCPv4]
|
||||||
|
RouteMetric=10
|
||||||
|
|
||||||
|
# Enable AppArmor in kernel parameters
|
||||||
|
- path: /etc/default/grub
|
||||||
|
append: true
|
||||||
|
content: |
|
||||||
|
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT lsm=landlock,lockdown,yama,integrity,apparmor,bpf"
|
||||||
|
|
||||||
|
# Set some bash aliases
|
||||||
|
- path: /etc/skel/.bashrc
|
||||||
|
append: true
|
||||||
|
content: |
|
||||||
|
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases
|
||||||
|
|
@ -38,6 +38,42 @@ source "qemu" "ubuntu-server" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source "qemu" "ubuntu-server24" {
|
||||||
|
disk_image = true
|
||||||
|
iso_url = "https://cloud-images.ubuntu.com/${var.release.ubuntu24.codename}/current/${var.release.ubuntu24.codename}-server-cloudimg-amd64.img"
|
||||||
|
iso_checksum = "file:https://cloud-images.ubuntu.com/${var.release.ubuntu24.codename}/current/SHA256SUMS"
|
||||||
|
iso_target_path = "${var.iso_dir}/ubuntu-${var.release.ubuntu24.codename}-cloudimg-amd64.img"
|
||||||
|
cpus = 4
|
||||||
|
memory = 2048
|
||||||
|
disk_size = var.disk_size
|
||||||
|
accelerator = "kvm"
|
||||||
|
headless = true
|
||||||
|
ssh_username = var.username
|
||||||
|
ssh_password = var.password
|
||||||
|
ssh_port = 22
|
||||||
|
ssh_wait_timeout = "1000s"
|
||||||
|
disk_compression = true
|
||||||
|
disk_detect_zeroes = "unmap"
|
||||||
|
disk_discard = "unmap"
|
||||||
|
output_directory = "${var.output}/"
|
||||||
|
vm_name = "${var.prefix}${source.name}.qcow2"
|
||||||
|
boot_wait = "10s"
|
||||||
|
firmware = var.firmware
|
||||||
|
shutdown_command = "echo ${var.password} | sudo -S /sbin/shutdown -hP now"
|
||||||
|
cd_label = "cidata"
|
||||||
|
cd_content = {
|
||||||
|
"meta-data" = ""
|
||||||
|
"user-data" = templatefile("${path.cwd}/packer/init/ubuntu-server.user-data.yml",
|
||||||
|
{
|
||||||
|
username = "${var.username}"
|
||||||
|
password = "${var.password}"
|
||||||
|
ssh_key = file("${var.ssh_publickey}")
|
||||||
|
hostname = "${var.prefix}${source.name}"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
source "qemu" "ubuntu-desktop" {
|
source "qemu" "ubuntu-desktop" {
|
||||||
disk_image = true
|
disk_image = true
|
||||||
iso_url = "https://cloud-images.ubuntu.com/${var.release.ubuntu.codename}/current/${var.release.ubuntu.codename}-server-cloudimg-amd64.img"
|
iso_url = "https://cloud-images.ubuntu.com/${var.release.ubuntu.codename}/current/${var.release.ubuntu.codename}-server-cloudimg-amd64.img"
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,10 @@ variable "release" {
|
||||||
codename = "jammy",
|
codename = "jammy",
|
||||||
version = "22.04.2",
|
version = "22.04.2",
|
||||||
},
|
},
|
||||||
|
"ubuntu24" : {
|
||||||
|
codename = "noble",
|
||||||
|
version = "24.04",
|
||||||
|
},
|
||||||
"debian" : {
|
"debian" : {
|
||||||
codename = "bookworm",
|
codename = "bookworm",
|
||||||
version = "12",
|
version = "12",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue