From b39b7b5e5425b8250a125f5a68ee4993396f4fff Mon Sep 17 00:00:00 2001 From: Florian Wilhelm Date: Fri, 22 Apr 2022 20:34:19 +0200 Subject: [PATCH 1/2] Add builder for VirtualBox Based on Jeff Geerling's config for ubuntu 20.04 https://github.com/geerlingguy/packer-boxes/blob/master/ubuntu2004/box-config.json --- .gitignore | 1 + README.md | 4 ++-- ubuntu-22.04.json | 54 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9451225 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +output-virtualbox-iso \ No newline at end of file diff --git a/README.md b/README.md index f4ace02..497b8f9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Build Ubuntu 22.04 (Beta) with Packer +# Build Ubuntu 22.04 with Packer This project demonstrates usage of Packer with the new [Ubuntu autoinstaller](https://ubuntu.com/server/docs/install/autoinstall) which was introduced in Ubuntu 20.04 while the classic Debian Installer (d-i) using `preseed.conf` files has been deprecated. @@ -45,7 +45,7 @@ Display `gtk` doesn't work on my system, YMMV. -## License +## License MIT diff --git a/ubuntu-22.04.json b/ubuntu-22.04.json index 2859d75..c5cc921 100644 --- a/ubuntu-22.04.json +++ b/ubuntu-22.04.json @@ -8,16 +8,16 @@ { "type" : "qemu", "iso_urls": [ - "ubuntu-22.04-beta-live-server-amd64.iso", - "https://releases.ubuntu.com/22.04/ubuntu-22.04-beta-live-server-amd64.iso" + "ubuntu-22.04-live-server-amd64.iso", + "https://releases.ubuntu.com/22.04/ubuntu-22.04-live-server-amd64.iso" ], - "iso_checksum": "sha256:39fdd5f7e868ab7981b492a8887dbaec85acf798b209162a37893cb4b209a26b", + "iso_checksum": "sha256:84aeaf7823c8c61baa0ae862d0a06b03409394800000b3235854a6b38eb4856f", "headless": "{{ user `is_headless` }}", "boot_key_interval" : "50ms", "boot_wait": "5s", "http_directory": "http", "disk_size": "5000M", - "memory": 2048, + "memory": 2048, "format": "qcow2", "display": "sdl", "accelerator": "kvm", @@ -35,12 +35,56 @@ "ssh_password": "{{ user `user_pass` }}", "ssh_timeout": "60m", "ssh_handshake_attempts": 420 + }, + { + "type": "virtualbox-iso", + "boot_command": [ + "e", + "", + "", + "autoinstall ds=nocloud-net\\;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ---", + "" + ], + "boot_wait": "10s", + "disk_size": 81920, + "guest_os_type": "Ubuntu_64", + "headless": "{{ user `is_headless` }}", + "http_directory": "http", + "iso_urls": [ + "ubuntu-22.04-live-server-amd64.iso", + "https://releases.ubuntu.com/22.04/ubuntu-22.04-live-server-amd64.iso" + ], + "iso_checksum": "sha256:84aeaf7823c8c61baa0ae862d0a06b03409394800000b3235854a6b38eb4856f", + "ssh_username": "{{ user `user_name` }}", + "ssh_password": "{{ user `user_pass` }}", + "ssh_port": 22, + "ssh_wait_timeout": "1800s", + "ssh_timeout": "60m", + "ssh_handshake_attempts": 420, + "shutdown_command": "echo '{{ user `user_pass` }}' |sudo -S shutdown -P now", + "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", + "virtualbox_version_file": ".vbox_version", + "vm_name": "packer-ubuntu-22.04-amd64", + "vboxmanage": [ + [ + "modifyvm", + "{{.Name}}", + "--memory", + "1024" + ], + [ + "modifyvm", + "{{.Name}}", + "--cpus", + "1" + ] + ] } ], "provisioners": [ { "type": "shell", - "execute_command": "echo '{{ user `user_name` }}' | {{.Vars}} sudo -S -E bash '{{.Path}}'", + "execute_command": "echo '{{ user `user_pass` }}' | {{.Vars}} sudo -S -E bash '{{.Path}}'", "script": "scripts/cleanup.sh" } ] From 7b28b5c1efdd605a67bdbcfdeb68bf9c1f2c0cbb Mon Sep 17 00:00:00 2001 From: Florian Wilhelm Date: Fri, 22 Apr 2022 22:05:21 +0200 Subject: [PATCH 2/2] Vagrant box --- .gitignore | 3 ++- ubuntu-22.04.json | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9451225..9cd1b36 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -output-virtualbox-iso \ No newline at end of file +output-virtualbox-iso +builds \ No newline at end of file diff --git a/ubuntu-22.04.json b/ubuntu-22.04.json index c5cc921..d2a6cba 100644 --- a/ubuntu-22.04.json +++ b/ubuntu-22.04.json @@ -87,5 +87,13 @@ "execute_command": "echo '{{ user `user_pass` }}' | {{.Vars}} sudo -S -E bash '{{.Path}}'", "script": "scripts/cleanup.sh" } + ], + "post-processors": [ + [ + { + "output": "builds/{{.Provider}}-ubuntu2204.box", + "type": "vagrant" + } + ] ] } \ No newline at end of file