mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-18 00:48:10 +01:00
test: improve vm generation.
This commit is contained in:
parent
d224aa4e6a
commit
38d310c62a
6 changed files with 54 additions and 26 deletions
|
@ -20,6 +20,12 @@ boxes:
|
|||
ram: '6144'
|
||||
cpu: '6'
|
||||
|
||||
- name: debian-server
|
||||
box: aa-debian-server
|
||||
uefi: true
|
||||
ram: '6144'
|
||||
cpu: '6'
|
||||
|
||||
- name: opensuse-kde
|
||||
box: aa-opensuse-kde
|
||||
uefi: true
|
||||
|
|
|
@ -20,9 +20,9 @@ source "qemu" "archlinux-gnome" {
|
|||
disk_detect_zeroes = "unmap"
|
||||
disk_discard = "unmap"
|
||||
output_directory = "${var.output}"
|
||||
vm_name = "${var.prefix}-${source.name}.qcow2"
|
||||
vm_name = "${var.prefix}${source.name}.qcow2"
|
||||
boot_wait = "10s"
|
||||
shutdown_command = "echo ${var.password} | sudo shutdown -hP now"
|
||||
shutdown_command = "echo ${var.password} | sudo -S shutdown -hP now"
|
||||
cd_label = "cidata"
|
||||
cd_content = {
|
||||
"meta-data" = ""
|
||||
|
@ -31,7 +31,7 @@ source "qemu" "archlinux-gnome" {
|
|||
username = "${var.username}"
|
||||
password = "${var.password}"
|
||||
ssh_key = file("${var.ssh_publickey}")
|
||||
hostname = "${var.prefix}-${source.name}"
|
||||
hostname = "${var.prefix}${source.name}"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -55,9 +55,9 @@ source "qemu" "archlinux-kde" {
|
|||
disk_detect_zeroes = "unmap"
|
||||
disk_discard = "unmap"
|
||||
output_directory = "${var.output}"
|
||||
vm_name = "${var.prefix}-${source.name}.qcow2"
|
||||
vm_name = "${var.prefix}${source.name}.qcow2"
|
||||
boot_wait = "10s"
|
||||
shutdown_command = "echo ${var.password} | sudo shutdown -hP now"
|
||||
shutdown_command = "echo ${var.password} | sudo -S shutdown -hP now"
|
||||
cd_label = "cidata"
|
||||
cd_content = {
|
||||
"meta-data" = ""
|
||||
|
@ -66,7 +66,7 @@ source "qemu" "archlinux-kde" {
|
|||
username = "${var.username}"
|
||||
password = "${var.password}"
|
||||
ssh_key = file("${var.ssh_publickey}")
|
||||
hostname = "${var.prefix}-${source.name}"
|
||||
hostname = "${var.prefix}${source.name}"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -32,22 +32,26 @@ build {
|
|||
inline = [
|
||||
"while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for Cloud-Init...'; sleep 20; done",
|
||||
"cloud-init clean", # Remove logs and artifacts so cloud-init can re-run
|
||||
"sh /tmp/src/init.sh"
|
||||
]
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
script = "${path.cwd}/packer/init/init.sh"
|
||||
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
||||
}
|
||||
|
||||
provisioner "shell" {
|
||||
script = "${path.cwd}/packer/init/clean.sh"
|
||||
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
||||
}
|
||||
|
||||
post-processor "vagrant" {
|
||||
output = "${var.iso_dir}/packer_${var.prefix}-${source.name}.box"
|
||||
output = "${var.base_dir}/packer_${var.prefix}${source.name}.box"
|
||||
}
|
||||
|
||||
post-processor "shell-local" {
|
||||
inline = [
|
||||
"vagrant box add --force --name ${var.prefix}-${source.name} ${var.iso_dir}/packer_${var.prefix}-${source.name}.box"
|
||||
"vagrant box add --force --name ${var.prefix}${source.name} ${var.base_dir}/packer_${var.prefix}${source.name}.box"
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
source "qemu" "ubuntu-server" {
|
||||
disk_image = true
|
||||
iso_url = "https://cloud-images.ubuntu.com/${var.release.ubuntu}/current/${var.release.ubuntu}-server-cloudimg-amd64.img"
|
||||
iso_checksum = "file:https://cloud-images.ubuntu.com/${var.release.ubuntu}/current/SHA256SUMS"
|
||||
iso_target_path = "${var.iso_dir}/${source.name}-cloudimg-amd64.img"
|
||||
iso_url = "https://cloud-images.ubuntu.com/${var.release.ubuntu.codename}/current/${var.release.ubuntu.codename}-server-cloudimg-amd64.img"
|
||||
iso_checksum = "file:https://cloud-images.ubuntu.com/${var.release.ubuntu.codename}/current/SHA256SUMS"
|
||||
iso_target_path = "${var.iso_dir}/ubuntu-cloudimg-amd64.img"
|
||||
cpus = 4
|
||||
memory = 2048
|
||||
disk_size = "${var.disk_size}"
|
||||
|
@ -20,7 +20,7 @@ source "qemu" "ubuntu-server" {
|
|||
disk_detect_zeroes = "unmap"
|
||||
disk_discard = "unmap"
|
||||
output_directory = "${var.output}/"
|
||||
vm_name = "${var.prefix}-${source.name}.qcow2"
|
||||
vm_name = "${var.prefix}${source.name}.qcow2"
|
||||
boot_wait = "10s"
|
||||
firmware = "/usr/share/edk2-ovmf/x64/OVMF_CODE.fd"
|
||||
shutdown_command = "echo ${var.password} | sudo -S /sbin/shutdown -hP now"
|
||||
|
@ -32,7 +32,7 @@ source "qemu" "ubuntu-server" {
|
|||
username = "${var.username}"
|
||||
password = "${var.password}"
|
||||
ssh_key = file("${var.ssh_publickey}")
|
||||
hostname = "${var.prefix}-${source.name}"
|
||||
hostname = "${var.prefix}${source.name}"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -40,6 +40,12 @@ variable "iso_dir" {
|
|||
default = "/var/lib/libvirt/images"
|
||||
}
|
||||
|
||||
variable "base_dir" {
|
||||
description = "Final packer image output directory"
|
||||
type = string
|
||||
default = "/var/lib/libvirt/images"
|
||||
}
|
||||
|
||||
variable "output" {
|
||||
description = "Output build directory"
|
||||
type = string
|
||||
|
@ -49,7 +55,7 @@ variable "output" {
|
|||
variable "prefix" {
|
||||
description = "Image name prefix"
|
||||
type = string
|
||||
default = "aa"
|
||||
default = "aa-"
|
||||
}
|
||||
|
||||
variable "version" {
|
||||
|
@ -58,18 +64,30 @@ variable "version" {
|
|||
default = "0.001"
|
||||
}
|
||||
|
||||
variable "release" {
|
||||
description = "Distribution release to use"
|
||||
type = map(string)
|
||||
default = {
|
||||
"ubuntu" : "jammy", # 22.04 LTS
|
||||
"debian" : "bullseye", # 11
|
||||
"opensuse" : "9",
|
||||
}
|
||||
}
|
||||
|
||||
variable "flavor" {
|
||||
description = "Distribution flavor to use (-desktop, -gnome, -kde...)"
|
||||
description = "Distribution flavor to use (server, desktop, gnome, kde...)"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "release" {
|
||||
description = "Distribution metadata to use"
|
||||
type = map(object({
|
||||
codename = string
|
||||
version = string
|
||||
}))
|
||||
default = {
|
||||
"ubuntu" : {
|
||||
codename = "jammy",
|
||||
version = "22.04.2",
|
||||
},
|
||||
"debian" : {
|
||||
codename = "bullseye",
|
||||
version = "11",
|
||||
}
|
||||
"opensuse" : {
|
||||
codename = "tumbleweed",
|
||||
version = "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue