mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-18 08:58:15 +01:00
refractor(tests): update packer structure.
This commit is contained in:
parent
c2bb733624
commit
fcdb9079ee
2 changed files with 81 additions and 59 deletions
70
tests/packer/builds.pkr.hcl
Normal file
70
tests/packer/builds.pkr.hcl
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
# apparmor.d - Full set of apparmor profiles
|
||||||
|
# Copyright (C) 2023 Alexandre Pujol <alexandre@pujol.io>
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
|
build {
|
||||||
|
sources = [
|
||||||
|
"source.qemu.archlinux-gnome",
|
||||||
|
"source.qemu.archlinux-kde",
|
||||||
|
"source.qemu.debian-server",
|
||||||
|
"source.qemu.opensuse-kde",
|
||||||
|
"source.qemu.ubuntu-desktop",
|
||||||
|
"source.qemu.ubuntu-server",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Upload local files
|
||||||
|
provisioner "file" {
|
||||||
|
destination = "/tmp"
|
||||||
|
sources = ["${path.cwd}/packer/src"]
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "file" {
|
||||||
|
only = ["qemu.archlinux-gnome", "qemu.archlinux-kde"]
|
||||||
|
destination = "/tmp/src/"
|
||||||
|
sources = ["${path.cwd}/../apparmor.d-${var.version}-x86_64.pkg.tar.zst"]
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "file" {
|
||||||
|
only = ["qemu.opensuse-*"]
|
||||||
|
destination = "/tmp/src/"
|
||||||
|
sources = ["${path.cwd}/../apparmor.d-${var.version}*.rpm"]
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "file" {
|
||||||
|
only = ["qemu.debian-server", "qemu.ubuntu-server", "qemu.ubuntu-desktop"]
|
||||||
|
destination = "/tmp/src/"
|
||||||
|
sources = ["${path.cwd}/../apparmor.d_${var.version}_all.deb"]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wait for cloud-init to finish
|
||||||
|
provisioner "shell" {
|
||||||
|
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
||||||
|
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
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install local files and config
|
||||||
|
provisioner "shell" {
|
||||||
|
script = "${path.cwd}/packer/init/init.sh"
|
||||||
|
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Minimize the image
|
||||||
|
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.base_dir}/packer_${var.prefix}${source.name}.box"
|
||||||
|
}
|
||||||
|
|
||||||
|
post-processor "shell-local" {
|
||||||
|
inline = [
|
||||||
|
"vagrant box add --force --name ${var.prefix}${source.name} ${var.base_dir}/packer_${var.prefix}${source.name}.box"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,63 +2,15 @@
|
||||||
# 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
|
||||||
|
|
||||||
build {
|
packer {
|
||||||
sources = [
|
required_plugins {
|
||||||
"source.qemu.archlinux-gnome",
|
ansible = {
|
||||||
"source.qemu.archlinux-kde",
|
source = "github.com/hashicorp/ansible"
|
||||||
"source.qemu.debian-server",
|
version = "~> 1"
|
||||||
"source.qemu.opensuse-kde",
|
}
|
||||||
"source.qemu.ubuntu-desktop",
|
qemu = {
|
||||||
"source.qemu.ubuntu-server",
|
source = "github.com/hashicorp/qemu"
|
||||||
]
|
version = "~> 1"
|
||||||
|
}
|
||||||
# Upload local files
|
|
||||||
provisioner "file" {
|
|
||||||
destination = "/tmp"
|
|
||||||
sources = ["${path.cwd}/packer/src"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
provisioner "file" {
|
|
||||||
only = ["qemu.archlinux-gnome", "qemu.archlinux-kde"]
|
|
||||||
destination = "/tmp/src/"
|
|
||||||
sources = ["${path.cwd}/../apparmor.d-${var.version}-x86_64.pkg.tar.zst"]
|
|
||||||
}
|
|
||||||
|
|
||||||
provisioner "file" {
|
|
||||||
only = ["qemu.debian-server", "qemu.ubuntu-server", "qemu.ubuntu-desktop"]
|
|
||||||
destination = "/tmp/src/"
|
|
||||||
sources = ["${path.cwd}/../apparmor.d_${var.version}_all.deb"]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Wait for cloud-init to finish
|
|
||||||
provisioner "shell" {
|
|
||||||
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
|
||||||
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
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Install local files and config
|
|
||||||
provisioner "shell" {
|
|
||||||
script = "${path.cwd}/packer/init/init.sh"
|
|
||||||
execute_command = "echo '${var.password}' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Minimize the image
|
|
||||||
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.base_dir}/packer_${var.prefix}${source.name}.box"
|
|
||||||
}
|
|
||||||
|
|
||||||
post-processor "shell-local" {
|
|
||||||
inline = [
|
|
||||||
"vagrant box add --force --name ${var.prefix}${source.name} ${var.base_dir}/packer_${var.prefix}${source.name}.box"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue