Skip to content

Commit

Permalink
add latest test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanis committed May 7, 2024
1 parent f400aae commit 7a584a8
Show file tree
Hide file tree
Showing 16 changed files with 329 additions and 175 deletions.
41 changes: 28 additions & 13 deletions cableos/build.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@

{
"builders": [
{
"type": "qemu",
"iso_url": "http://releases.ubuntu.com/20.04/ubuntu-20.04-live-server-amd64.iso",
"iso_checksum": "sha256:12345abcdef...",
"disk_size": "10240",
"http_url": "http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
"http_directory": "http",
"iso_url": "http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-xx.x.x-amd64-netinst.iso",
"iso_checksum": "auto",
"boot_command": [
"<esc><wait>",
"linux /casper/vmlinuz boot=casper initrd=/casper/initrd quiet -- <enter>",
"initrd /casper/initrd<enter>",
"boot<enter>"
"install <wait>",
"auto=true <wait>",
"priority=critical <wait>",
"locale=en_US <wait>",
"keyboard-configuration/xkb-keymap=us <wait>",
"netcfg/get_hostname=debian <wait>",
"netcfg/get_domain=vm <wait>",
"fb=false <wait>",
"debconf/frontend=noninteractive <wait>",
"console-setup/ask_detect=false <wait>",
"interface=auto <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg <enter>"
],
"ssh_username": "ubuntu",
"ssh_password": "ubuntu",
"ssh_wait_timeout": "10000s"
"http_directory": "http",
"disk_size": 10240,
"http_port_min": 8000,
"http_port_max": 9000,
"ssh_username": "admin",
"ssh_password": "admin",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'shutdown -P now' > shutdown.sh; chmod +x shutdown.sh; sudo ./shutdown.sh",
"format": "raw",
"vm_name": "debian-minimal"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sudo apt-get update",
"sudo apt-get upgrade -y",
"sudo apt-get install -y nginx"
"sudo apt-get install -y openssh-server",
"sudo apt-get clean"
]
}
]
Expand Down
114 changes: 86 additions & 28 deletions cableos/cableos.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,46 +1,104 @@


locals {
qemu_arch = {
"amd64" = "x86_64"
"arm64" = "aarch64"
}
uefi_imp = {
"amd64" = "OVMF"
"arm64" = "AAVMF"
}
qemu_machine = {
"amd64" = "accel=kvm"
"arm64" = "virt"
}
qemu_cpu = {
"amd64" = "host"
"arm64" = "cortex-a57"
}

}
source "null" "dependencies" {
communicator = "none"
}

source "qemu" "cableos" {

vm_name = "debirf-live"
boot_wait = "2s"
cpus = 2
disk_image = true
format = qcow2
disk_size = "10G"
type = "qemu"
headless = var.headless
http_directory = var.http_directory
http_url = "http://{{ .HTTPIP }}:{{ .HTTPPort }}/"
iso_checksum = "none"
iso_url = var.image_path/var.debirf_live_bullseye_amd64_iso
memory = 2048
qemu_binary = "qemu-system-${lookup(local.qemu_arch, var.architecture, "")}"
qemuargs = [
["-machine", "${lookup(local.qemu_machine, var.architecture, "")}"],
["-cpu", "${lookup(local.qemu_cpu, var.architecture, "")}"],
["-device", "virtio-gpu-pci"]
]
qemu_img_args = [
create = ["-F", "qcow2"]
]
boot_command = [
["<esc><wait>"],
["linux", "/install.amd/vmlinuz", "initrd=/install.amd/initrd.gz", "debirf.boot=live", "fetch=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debirf.cgz<enter>"]
]
shutdown_command = "sudo -S shutdown -P now"
ssh_handshake_attempts = 50
ssh_password = "install"
ssh_timeout = var.timeout
ssh_username = "root"
ssh_wait_timeout = var.timeout
use_backing_file = true
}

source "qemu" "debirf" {
boot_command = {
"<esc><wait>",
"linux /casper/vmlinuz boot=casper initrd=/casper/initrd quiet -- <enter>",
"initrd /casper/initrd<enter>",
"boot<enter>"
], boot_wait = "3s"
communicator = "none"
disk_size = "4G"
headless = var.headless
iso_checksum = "none"
iso_url = "${var.cableos_iso_url}"
memory = 2048
qemuargs = [["-serial", "stdio"], ["-cpu", "host"]]
shutdown_timeout = var.timeout
ssh_username = "ubuntu"
ssh_password = "ubuntu"
ssh_wait_timeout = "10000s"
http_content = {
"/cableos.ks" = templatefile("${var.http_path}/cableos.ks.pkrtpl.hcl",
{
KS_PROXY = local.ks_proxy
}
)



build {
name = "cableos.deps"
sources = ["source.null.dependencies"]

provisioner "shell-local" {
inline = [
"cp ${var.source_iso_directory}/${var.debirf_live_bullseye_amd64_iso} ${var.image_path}/"
# "sudo mount -o loop ${var.image_path}/${var.debirf_live_bullseye_amd64_iso} ${var.debirf_tmp_path}"
"cp ${var.debirf_tmp_path}/${var.debirf_initrd_filename} ${var.image_path}/"
# "cp ${var.source_iso_directory}/${var.apollo_iso} ${var.http_path}/"
# "sudo umount -lf ${var.debirf_tmp_path}"
]
inline_shebang = "/bin/bash -e"
}
}


build {
sources = ["source.qemu.cableos"]
name = "debirf.image"
sources = ["source.qemu.debirf"]

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
expect_disconnect = true
scripts = ["${var.scripts_directory}/apollo_install.sh"]
}

post-processor "shell-local" {
inline = [
"SOURCE=sles15",
"ROOT_PARTITION=2",
"IMG_FMT=qcow2",
"SOURCE=debirf",
"ROOT_PARTITION=1",
"OUTPUT=${var.filename}",
"source ../scripts/fuse-nbd",
"source ../scripts/fuse-tar-root"
]
inline_shebang = "/bin/bash -e"
}
}
q
33 changes: 25 additions & 8 deletions cableos/cableosvariables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,25 @@ variable "http_directory" {
default = "http"
description = "HTTP directory accessible to images during build"
}

variable "apollo_iso_src_path" {
variable "scripts_directory" {
type = string
default = "scripts"
description "Build script directory"
}
variable "apollo_iso" {
type = string
default = "/opt/APOLLO_PLATFORM-release-3.21.3.0-7+auto15.iso"
default = "APOLLO_PLATFORM-release-3.21.3.0-7+auto15.iso"
description = "Apollo PLatform iso location"
}

variable "debirf_build_path" {
variable "source_iso_directory" {
type = string
default = "/opt"
description = "Location of source Debirf and Apollo ISO files"
}


variable "debirf_tmp_path" {
type = string
default = "debirf"
description = "Debian LiveImage build directory"
Expand All @@ -42,14 +53,20 @@ variable "image_path" {
default = "images"
description = "Boot image directory"
}
variable "debirf_live_bullseye_amd64_iso_src_path" {
variable "debirf_live_bullseye_amd64_iso" {
type = string
default = "/opt/debirf-live_bullseye_amd64.iso"
default = "debirf-live_bullseye_amd64.iso"
description = "Pre-Existing Debirf-Liveimage path"
}
variable "debirf_src_filename" {

variable "deb_netinst_url" {
type = string
default = "https://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/amd64/iso-cd/debian-testing-amd64-netinst.iso"
description = "debian netinstall iso url"
}
variable "debirf_initrd_filename" {
type = string
default = "minimal.tgz"
default = "live_bullseye_6.0.0-0.deb11.6-amd64.cgz"
description = "Name of the 'debirf' creation sourcefiles"
}

Expand Down
107 changes: 91 additions & 16 deletions cableos/debirf.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,71 @@ source "null" "dependencies" {

source "qemu" "debirf" {

vm_name = "debirf-live"
boot_wait = "2s"
cpus = 2
disk_image = true
disk_size = "4G"
format = qcow2
disk_size = "10G"
type = "qemu"
format = "qcow2"
headless = var.headless
http_directory = var.http_directory
http_url = "http://{{ .HTTPIP }}:{{ .HTTPPort }}/"
iso_checksum = "none"
iso_url = var.debirf_iso_path
iso_url = var.image_path/var.debirf_live_bullseye_amd64_iso
memory = 2048
qemu_binary = "qemu-system-${lookup(local.qemu_arch, var.architecture, "")}"
qemu_img_args {
create = ["-F", "qcow2"]
}
qemuargs = [
["-machine", "${lookup(local.qemu_machine, var.architecture, "")}"],
["-cpu", "${lookup(local.qemu_cpu, var.architecture, "")}"],
["-device", "virtio-gpu-pci"]
]
qemu_img_args = [
create = ["-F", "qcow2"]
]
boot_command = [
["<esc><wait>"],
["linux", "/install.amd/vmlinuz", "initrd=/install.amd/initrd.gz", "debirf.boot=live", "fetch=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debirf.cgz<enter>"]
]
shutdown_command = "sudo -S shutdown -P now"
ssh_handshake_attempts = 50
ssh_password = var.ssh_password
ssh_password = "install"
ssh_timeout = var.timeout
ssh_username = var.ssh_username
ssh_username = "root"
ssh_wait_timeout = var.timeout
use_backing_file = true
}


source "qemu" "cableos" {
iso_url = var.deb_netinst_url
iso_checksum = "auto"
boot_command = [
"<esc><wait>",
"install <wait>",
"auto=true <wait>",
"priority=critical <wait>",
"locale=en_US <wait>",
"keyboard-configuration/xkb-keymap=us <wait>",
"netcfg/get_hostname=debian <wait>",
"netcfg/get_domain=vm <wait>",
"fb=false <wait>",
"debconf/frontend=noninteractive <wait>",
"console-setup/ask_detect=false <wait>",
"interface=auto <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg <enter>"
]
http_directory = "http"
disk_size = 10240
http_port_min = 8000
http_port_max = 9000
ssh_username = "admin"
ssh_password = "admin"
ssh_port = 22
ssh_wait_timeout = "10000s"
shutdown_command = "echo 'shutdown -P now' > shutdown.sh; chmod +x shutdown.sh; sudo ./shutdown.sh"
format = "raw"
vm_name = "debian-minimal"
}


build {
Expand All @@ -63,12 +98,11 @@ build {

provisioner "shell-local" {
inline = [
"cd ${var.debirf_build_path}"
"tar -zxvf ${debirf_src_filename}"
"debirf makeiso minimal"
"cd ${path.root}"
"mv ${var.debirf_livecreator_path} ${var.image_path}/"
"mv ${var.apollo_iso_src_path} ${var.http_path}/"
"cp ${var.source_iso_directory}/${var.debirf_live_bullseye_amd64_iso} ${var.image_path}/"
"sudo mount -o loop ${var.image_path}/${var.debirf_live_bullseye_amd64_iso} ${var.debirf_tmp_path}"
"cp ${var.debirf_tmp_path}/${var.debirf_initrd_filename} ${var.image_path}/"
"cp ${var.source_iso_directory}/${var.apollo_iso} ${var.http_path}/"
"sudo umount -lf ${var.debirf_tmp_path}"
]
inline_shebang = "/bin/bash -e"
}
Expand All @@ -82,7 +116,48 @@ build {
provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
expect_disconnect = true
scripts = ["${path.root}/scripts/apollo_install.sh"]
scripts = ["${var.scripts_directory}/apollo_install.sh"]
}

post-processor "shell-local" {
inline = [
"IMG_FMT=qcow2",
"SOURCE=cloudimg",
"ROOT_PARTITION=1",
"OUTPUT=${var.filename}",
"source ../scripts/fuse-nbd",
"source ../scripts/fuse-tar-root"
]
inline_shebang = "/bin/bash -e"
}
}



build {
sources = [
"source.qemu.cableos"
]

provisioner "shell" {
inline = [
"sudo apt-get update",
"sudo apt-get install -y openssh-server",
"sudo apt-get clean"
]
}
}



build {
name = "cableos.image"
sources = ["source.qemu.debirf"]

provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
expect_disconnect = true
scripts = ["${var.scripts_directory}/apollo_install.sh"]
}

post-processor "shell-local" {
Expand Down
Binary file modified cableos/debirf/minimal.tgz
Binary file not shown.
Loading

0 comments on commit 7a584a8

Please sign in to comment.