Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create separate file for virtualbox as libvirt did not work
Browse files Browse the repository at this point in the history
Stephen Andary committed Oct 16, 2023
1 parent 0a38d68 commit 36ff995
Showing 5 changed files with 71 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ packer_cache
\#*\#
.#*
*.*.swp
*.box
*.gz
*.xz
*.iso
10 changes: 8 additions & 2 deletions ubuntu/Makefile
Original file line number Diff line number Diff line change
@@ -26,6 +26,9 @@ seeds-lvm.iso: user-data-lvm meta-data
seeds-flat.iso: user-data-flat meta-data
cloud-localds $@ $^

seeds-virtbox.iso: user-data-virtbox meta-data
cloud-localds $@ $^

OVMF_VARS.fd: /usr/share/OVMF/OVMF_VARS.fd
cp -v $< $@

@@ -39,9 +42,12 @@ custom-ubuntu.tar.gz: check-deps clean seeds-flat.iso OVMF_VARS.fd \
custom-ubuntu-lvm.dd.gz: check-deps clean seeds-lvm.iso OVMF_VARS.fd
${PACKER} init . && ${PACKER} build -only=qemu.lvm .

custom-ubuntu-virtbox.box: check-deps clean seeds-virtbox.iso OVMF_VARS.fd
${PACKER} init . && ${PACKER} build -only=virtualbox-iso.lvm .

clean:
${RM} -rf output-* custom-*.gz \
seeds-flat.iso seeds-lvm.iso seeds-cloudimg.iso \
seeds-flat.iso seeds-lvm.iso seeds-virtbox.iso seeds-cloudimg.iso \
OVMF_VARS.fd

CUSTOM_PKGS:=${wildcard packages/*.deb}
@@ -54,4 +60,4 @@ else
endif

.INTERMEDIATE: OVMF_VARS.fd packages/custom-packages.tar.gz \
seeds-flat.iso seeds-lvm.iso seeds-cloudimg.iso
seeds-flat.iso seeds-lvm.iso seeds-virtbox.iso seeds-cloudimg.iso
4 changes: 0 additions & 4 deletions ubuntu/ubuntu-lvm.pkr.hcl
Original file line number Diff line number Diff line change
@@ -47,8 +47,4 @@ build {
post-processor "compress" {
output = "custom-ubuntu-lvm.dd.gz"
}

post-processor "vagrant" {
output = "custom-ubuntu-lvm.box"
}
}
39 changes: 39 additions & 0 deletions ubuntu/ubuntu-virtualbox.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
source "virtualbox-iso" "lvm" {
boot_command = ["<wait>e<wait5>", "<down><wait><down><wait><down><wait2><end><wait5>", "<bs><bs><bs><bs><wait>autoinstall ---<wait><f10>"]
boot_wait = "2s"
cpus = 2
disk_size = 8192
guest_os_type = "Ubuntu_64"
headless = var.headless
http_directory = var.http_directory
iso_checksum = "file:http://releases.ubuntu.com/jammy/SHA256SUMS"
iso_url = "https://releases.ubuntu.com/jammy/ubuntu-22.04.3-live-server-amd64.iso"
memory = 2048
shutdown_command = "sudo -S shutdown -P now"
ssh_handshake_attempts = 500
ssh_password = var.ssh_ubuntu_password
ssh_timeout = "45m"
ssh_username = "ubuntu"
ssh_wait_timeout = "45m"
vm_name = "packer-lvm"
}

build {
sources = ["source.virtualbox-iso.lvm"]

provisioner "file" {
destination = "/tmp/curtin-hooks"
source = "${path.root}/scripts/curtin-hooks"
}

provisioner "shell" {
environment_vars = ["HOME_DIR=/home/ubuntu", "http_proxy=${var.http_proxy}", "https_proxy=${var.https_proxy}", "no_proxy=${var.no_proxy}"]
execute_command = "echo 'ubuntu' | {{ .Vars }} sudo -S -E sh -eux '{{ .Path }}'"
expect_disconnect = true
scripts = ["${path.root}/scripts/curtin.sh", "${path.root}/scripts/networking.sh", "${path.root}/scripts/cleanup.sh"]
}

post-processor "vagrant" {
output = "custom-ubuntu-virtbox.box"
}
}
23 changes: 23 additions & 0 deletions ubuntu/user-data-virtbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#cloud-config
autoinstall:
version: 1
identity:
hostname: ubuntu
username: ubuntu
password: "$6$canonical.$0zWaW71A9ke9ASsaOcFTdQ2tx1gSmLxMPrsH0rF0Yb.2AEKNPV1lrF94n6YuPJmnUy2K2/JSDtxuiBDey6Lpa/"
keyboard:
layout: us
variant: ''
ssh:
install-server: true
storage:
grub:
update_nvram: true
swap:
size: 0
layout:
name: lvm
late-commands:
- echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu
package_update: true
package_upgrade: true

0 comments on commit 36ff995

Please sign in to comment.