From c46b459a85a19582a09a237da480763122d76abe Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 11 Aug 2023 09:55:32 -0500 Subject: [PATCH] Now with Ubuntu support --- {http => attic/http}/ubuntu/14.04/preseed.cfg | 0 {http => attic/http}/ubuntu/16.04/preseed.cfg | 0 distros/ubuntu/18.04/build.xsh | 14 +++++ .../18.04/ubuntu-18.04-x86_64.pkrvars.hcl | 18 ------ .../ubuntu/18.04/x86_64.pkrvars.hcl | 24 ++++++- .../20.04/ubuntu-20.04-x86_64.pkrvars.hcl | 17 ----- distros/ubuntu/20.04/x86_64.pkrvars.hcl | 62 +++++++++++++++++++ .../22.04/ubuntu-22.04-x86_64.pkrvars.hcl | 15 ----- distros/ubuntu/22.04/x86_64.pkrvars.hcl | 62 +++++++++++++++++++ distros/ubuntu/supports.yml | 15 +++++ sources/virtualbox-iso.pkr.hcl | 3 +- 11 files changed, 178 insertions(+), 52 deletions(-) rename {http => attic/http}/ubuntu/14.04/preseed.cfg (100%) rename {http => attic/http}/ubuntu/16.04/preseed.cfg (100%) create mode 100755 distros/ubuntu/18.04/build.xsh delete mode 100644 distros/ubuntu/18.04/ubuntu-18.04-x86_64.pkrvars.hcl rename http/ubuntu/18.04/preseed.cfg => distros/ubuntu/18.04/x86_64.pkrvars.hcl (79%) delete mode 100644 distros/ubuntu/20.04/ubuntu-20.04-x86_64.pkrvars.hcl create mode 100644 distros/ubuntu/20.04/x86_64.pkrvars.hcl delete mode 100644 distros/ubuntu/22.04/ubuntu-22.04-x86_64.pkrvars.hcl create mode 100644 distros/ubuntu/22.04/x86_64.pkrvars.hcl create mode 100644 distros/ubuntu/supports.yml diff --git a/http/ubuntu/14.04/preseed.cfg b/attic/http/ubuntu/14.04/preseed.cfg similarity index 100% rename from http/ubuntu/14.04/preseed.cfg rename to attic/http/ubuntu/14.04/preseed.cfg diff --git a/http/ubuntu/16.04/preseed.cfg b/attic/http/ubuntu/16.04/preseed.cfg similarity index 100% rename from http/ubuntu/16.04/preseed.cfg rename to attic/http/ubuntu/16.04/preseed.cfg diff --git a/distros/ubuntu/18.04/build.xsh b/distros/ubuntu/18.04/build.xsh new file mode 100755 index 0000000..c4058ed --- /dev/null +++ b/distros/ubuntu/18.04/build.xsh @@ -0,0 +1,14 @@ +#!/usr/bin/env xonsh +$RAISE_SUBPROC_ERROR = True +from pathlib import Path +import sys +self = Path(__file__).absolute() +base = self.parent.parent.parent.parent +source @(base / "test.xsh") + + +opts = get_parser(sys.argv[1:]) + +cd @(str(base)) +for provider in opts["providers"]: + packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources") diff --git a/distros/ubuntu/18.04/ubuntu-18.04-x86_64.pkrvars.hcl b/distros/ubuntu/18.04/ubuntu-18.04-x86_64.pkrvars.hcl deleted file mode 100644 index d87335a..0000000 --- a/distros/ubuntu/18.04/ubuntu-18.04-x86_64.pkrvars.hcl +++ /dev/null @@ -1,18 +0,0 @@ -distro = "ubuntu" -version = "18.04" -iso = { - url = "http://cdimage.ubuntu.com/ubuntu/releases/18.04/release/ubuntu-18.04.6-server-amd64.iso" - checksum = "f5cbb8104348f0097a8e513b10173a07dbc6684595e331cb06f93f385d0aecf6" -} -boot_command = [ - "", - "", - "auto=true priority=critical ", - "locale=en_US.UTF-8 ", - "DEBIAN_FRONTEND=text ", - "preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/18.04/preseed.cfg ", - "fsck.mode=skip ", - "console=ttyS0 ", - "console=tty0 ", - "" -] diff --git a/http/ubuntu/18.04/preseed.cfg b/distros/ubuntu/18.04/x86_64.pkrvars.hcl similarity index 79% rename from http/ubuntu/18.04/preseed.cfg rename to distros/ubuntu/18.04/x86_64.pkrvars.hcl index d98614e..363744d 100644 --- a/http/ubuntu/18.04/preseed.cfg +++ b/distros/ubuntu/18.04/x86_64.pkrvars.hcl @@ -1,3 +1,23 @@ +distro = "ubuntu" +version = "18.04" +iso = { + url = "http://cdimage.ubuntu.com/ubuntu/releases/18.04/release/ubuntu-18.04.6-server-amd64.iso" + checksum = "f5cbb8104348f0097a8e513b10173a07dbc6684595e331cb06f93f385d0aecf6" +} +boot_command = [ + "", + "", + "auto=true priority=critical ", + "locale=en_US.UTF-8 ", + "DEBIAN_FRONTEND=text ", + "preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/preseed.cfg ", + "fsck.mode=skip ", + "console=tty0 ", + "--- net.ifnames=0 biosdevnames=0 ", + "" +] +http_files = { + "/preseed.cfg" = <> /target/etc/sudoers.d/vagrant; \ chmod 440 /target/etc/sudoers.d/vagrant; \ in-target update-initramfs -u +HEREDOC +} diff --git a/distros/ubuntu/20.04/ubuntu-20.04-x86_64.pkrvars.hcl b/distros/ubuntu/20.04/ubuntu-20.04-x86_64.pkrvars.hcl deleted file mode 100644 index 3788cc4..0000000 --- a/distros/ubuntu/20.04/ubuntu-20.04-x86_64.pkrvars.hcl +++ /dev/null @@ -1,17 +0,0 @@ -distro = "ubuntu" -version = "20.04" -iso = { - url = "https://releases.ubuntu.com/20.04/ubuntu-20.04.6-live-server-amd64.iso" - checksum = "b8f31413336b9393ad5d8ef0282717b2ab19f007df2e9ed5196c13d8f9153c8b" -} -boot_wait = "3s" -boot_command = [ - "", - "console=ttyS0 ", - "console=tty0 ", - "fsck.mode=skip ", - "locale=en_US ", - "auto=true ", - "priority=critical ", - "autoinstall ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/20.04/" -] diff --git a/distros/ubuntu/20.04/x86_64.pkrvars.hcl b/distros/ubuntu/20.04/x86_64.pkrvars.hcl new file mode 100644 index 0000000..e4bd0ae --- /dev/null +++ b/distros/ubuntu/20.04/x86_64.pkrvars.hcl @@ -0,0 +1,62 @@ +distro = "ubuntu" +version = "20.04" +iso = { + url = "https://releases.ubuntu.com/20.04/ubuntu-20.04.6-live-server-amd64.iso" + checksum = "b8f31413336b9393ad5d8ef0282717b2ab19f007df2e9ed5196c13d8f9153c8b" +} +boot_wait = "3s" +boot_command = [ + "", + "console=tty0 ", + "fsck.mode=skip ", + "locale=en_US ", + "auto=true ", + "priority=critical ", + "autoinstall ds=nocloud" +] +cd_files = { + "/meta-data" = "" + "/user-data" = < /target/etc/sudoers.d/vagrant + - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant + - chmod 440 /target/etc/sudoers.d/vagrant + - curtin in-target --target=/target -- logger "finished late-commands" + packages: + - ca-certificates + - curl + - sudo +HEREDOC +} diff --git a/distros/ubuntu/22.04/ubuntu-22.04-x86_64.pkrvars.hcl b/distros/ubuntu/22.04/ubuntu-22.04-x86_64.pkrvars.hcl deleted file mode 100644 index 0f5e214..0000000 --- a/distros/ubuntu/22.04/ubuntu-22.04-x86_64.pkrvars.hcl +++ /dev/null @@ -1,15 +0,0 @@ -distro = "ubuntu" -version = "22.04" -iso = { - url = "https://releases.ubuntu.com/jammy/ubuntu-22.04.2-live-server-amd64.iso" - checksum = "5e38b55d57d94ff029719342357325ed3bda38fa80054f9330dc789cd2d43931" -} -boot_command = [ - "e", - "fsck.mode=skip ", - "net.ifnames=0 biosdevnames=0 ", - "locale=en_US ", - "auto=true ", - "priority=critical ", - "autoinstall ds=\"nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu/22.04/\" console=tty0 ", -] diff --git a/distros/ubuntu/22.04/x86_64.pkrvars.hcl b/distros/ubuntu/22.04/x86_64.pkrvars.hcl new file mode 100644 index 0000000..4aadb2a --- /dev/null +++ b/distros/ubuntu/22.04/x86_64.pkrvars.hcl @@ -0,0 +1,62 @@ +distro = "ubuntu" +version = "22.04" +iso = { + url = "https://releases.ubuntu.com/22.04/ubuntu-22.04.3-live-server-amd64.iso" + checksum = "a4acfda10b18da50e2ec50ccaf860d7f20b389df8765611142305c0e911d16fd" +} +boot_command = [ + "e", + "console=tty0 ", + "fsck.mode=skip ", + "locale=en_US ", + "auto=true ", + "priority=critical ", + "autoinstall", + "", +] +cd_files = { + "/meta-data" = "" + "/user-data" = < /target/etc/sudoers.d/vagrant + - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /target/etc/sudoers.d/vagrant + - chmod 440 /target/etc/sudoers.d/vagrant + - curtin in-target --target=/target -- logger "finished late-commands" + packages: + - ca-certificates + - curl + - sudo +HEREDOC +} diff --git a/distros/ubuntu/supports.yml b/distros/ubuntu/supports.yml new file mode 100644 index 0000000..61c8f60 --- /dev/null +++ b/distros/ubuntu/supports.yml @@ -0,0 +1,15 @@ +18.04: + - arch: x86_64 + provider: qemu + - arch: x86_64 + provider: virtualbox-iso +20.04: + - arch: x86_64 + provider: qemu + - arch: x86_64 + provider: virtualbox-iso +22.04: + - arch: x86_64 + provider: qemu + - arch: x86_64 + provider: virtualbox-iso diff --git a/sources/virtualbox-iso.pkr.hcl b/sources/virtualbox-iso.pkr.hcl index f578c86..5693012 100644 --- a/sources/virtualbox-iso.pkr.hcl +++ b/sources/virtualbox-iso.pkr.hcl @@ -23,7 +23,8 @@ source "virtualbox-iso" "x86_64" { guest_additions_sha256 = "bbabd89b8fff38a257bab039a278f0c4dc4426eff6e4238c1db01edb7284186a" vboxmanage = [ ["modifyvm", "{{ .Name }}", "--uart1", "0x3F8", "4"], - ["modifyvm", "{{ .Name }}", "--uartmode1", "file", "serial-output-virtualbox-${var.arch}-${var.distro}-${var.version}"] + ["modifyvm", "{{ .Name }}", "--uartmode1", "file", "serial-output-virtualbox-${var.arch}-${var.distro}-${var.version}"], + ["modifyvm", "{{ .Name }}", "--nat-localhostreachable1", "on"], ] http_content = var.http_files