Skip to content

Commit

Permalink
update packer template for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanis committed May 20, 2024
1 parent b278cc9 commit 248f629
Showing 1 changed file with 35 additions and 68 deletions.
103 changes: 35 additions & 68 deletions cableos/cableos-installer.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ variable "customize_script" {

variable "headless" {
type = bool
default = false
default = true
description = "Whether VNC viewer should not be launched."
}

Expand Down Expand Up @@ -113,57 +113,30 @@ locals {
source "qemu" "cableos-installer" {
boot_wait = "2s"
cpus = 2
cpu_model = "${lookup(local.qemu_cpu, var.architecture, "")}"f
cpu_model = "${lookup(local.qemu_cpu, var.architecture, "")}"
disk_image = true
disk_size = "10G"
use_backing_file = true
disk_size = "5120M"
format = "qcow2"
efi_boot = false
headless = var.headless
http_directory = var.http_directory
iso_checksum = "md5:37f6ddeaf58b7dfa70bc3615047e4d09"
iso_url = "${path.root}/boot-images/${var.live_img}.qcow2"
memory = 2048
efi_boot = true
efi_firmware_code = "/usr/share/${lookup(local.uefi_imp, var.architecture, "")}/${lookup(local.uefi_imp, var.architecture, "")}_CODE.fd"
efi_firmware_vars = "${lookup(local.uefi_imp, var.architecture, "")}_VARS.fd"
qemu_binary = "qemu-system-${lookup(local.qemu_arch, var.architecture, "")}"
# qemu_img_args {
# create = ["-F", "qcow2"]
# }

# qemuargs = [
# ["-device", "virtio-gpu-pci"],
# ["-machine", "${lookup(local.qemu_machine, var.architecture, "")}"],
# ["-device", "virtio-blk-pci,drive=drive0,bootindex=0"],
# ["-device", "virtio-blk-pci,drive=cdrom0,bootindex=1"],
# ["-device", "virtio-blk-pci,drive=drive1,bootindex=2"],
# ["-drive", "if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd"],
# ["-drive", "if=pflash,format=raw,file=OVMF_VARS.fd"],
# ["-drive", "file=output-flat/packer-flat,if=none,id=drive0,cache=writeback,discard=ignore,format=raw"],
# ["-drive", "file=seeds-flat.iso,format=raw,cache=none,if=none,id=drive1,readonly=on"],
# ["-drive", "file=packer_cache/${var.ubuntu_series}.iso,if=none,id=cdrom0,media=cdrom"]
# ]
# qemuargs = [
# ["-machine", "${lookup(local.qemu_machine, var.architecture, "")}"],
# ["-cpu", "${lookup(local.qemu_cpu, var.architecture, "")}"],
# ["-device", "virtio-gpu-pci"],
# ["-device", "virtio-blk-pci,drive=cdrom0,bootindex=1"],
# # ["-drive", "if=pflash,format=raw,id=ovmf_code,readonly=on,file=/usr/share/${lookup(local.uefi_imp, var.architecture, "")}/${lookup(local.uefi_imp, var.architecture, "")}_CODE.fd"],
# # ["-drive", "if=pflash,format=raw,id=ovmf_vars,file=${lookup(local.uefi_imp, var.architecture, "")}_VARS.fd"]
# # ["-drive", "file=output-cableos-installer/packer-cableos-installer-img,format=qcow2"]
# # ["-drive", "file=${path.root}/buildfiles/${apollo_iso},if=none,id=cdrom0,media=cdrom"]
# ]
shutdown_command = "sudo -S shutdown -P now"
ssh_handshake_attempts = 50
ssh_password = var.ssh_password
ssh_timeout = "300s"
ssh_username = var.ssh_username
ssh_wait_timeout = "300s"
use_backing_file = true
ssh_file_transfer_method = "sftp"
ssh_keep_alive_interval = "3s"
pause_before_connecting = "300s"
ssh_read_write_timeout = "600s"
#skip_compaction = true
#disk_compression = false
memory = 5120
qemuargs = [["-serial", "stdio"]]
qemu_binary = "qemu-system-${lookup(local.qemu_arch, var.architecture, "")}"
shutdown_command = "echo 'packer' | shutdown -P now"
#ssh_handshake_attempts = 50
ssh_password = var.ssh_password
#ssh_timeout = "300s"
ssh_username = var.ssh_username
#ssh_wait_timeout = "300s"
use_backing_file = true
#ssh_file_transfer_method = "sftp"
#ssh_keep_alive_interval = "30s"
#ssh_read_write_timeout = "600s"
}


Expand All @@ -188,35 +161,29 @@ build {

provisioner "file" {
destination = "/data/"
source = "${path.root}/buildfiles/${var.apollo_iso}"
# timeout = "10m"
source = "${path.root}/buildfiles/${var.apollo_iso}"
timeout = "10m"
}

provisioner "file" {
destination = "/root/"
source = "${path.root}/buildfiles/cableos.sh"
}

provisioner "shell-local" {
inline = [
"echo 'CableOS-Installer 1-Shot System-D service file copied to '"
]
destination = "/opt/"
source = "${path.root}/buildfiles/cableos.sh"
}

// Post-processors to create new images and prepare for MAAS
// Create tar.gz file
post-processor "shell-local" {
inline = [
"IMG_FMT=qcow2",
"SOURCE=cableos",
"ROOT_PARTITION=3",
# "DETECT_BLS_BOOT=1",
"OUTPUT=${var.base_filename}.tar.gz",
"source ../scripts/fuse-nbd",
"source ../scripts/fuse-tar-root"
]
inline_shebang = "/bin/bash -e"
}
#post-processor "shell-local" {
# inline = [
# "IMG_FMT=qcow2",
## "SOURCE=cableos-installer",
# "ROOT_PARTITION=3",
# "DETECT_BLS_BOOT=1",
# "OUTPUT=${var.base_filename}.tar.gz",
# "source ../scripts/fuse-nbd",
# "source ../scripts/fuse-tar-root"
# ]
# inline_shebang = "/bin/bash -e"
#}

// Create manifest of packer objects
post-processor "manifest" {
Expand Down

0 comments on commit 248f629

Please sign in to comment.