diff --git a/.gitignore b/.gitignore index 1404c31..9bc63e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ output .DS_Store -packer_cache \ No newline at end of file +packer_cache +artifacts +.vagrant +*.box diff --git a/LICENSE b/LICENSE index b9fe5cf..00accd7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Adam Hartley +Copyright (c) 2023 Adam Hartley Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 8ced2f9..a90ab38 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,64 @@ # arm-base-boxes -Vagrant Base Boxes for ARM Hosts (e.g., Apple Silicon / M1) -This repository provides the Packer files for building Vagrant base boxes for ARM hosts. +VMware Fusion Vagrant base boxes for ARM hosts (e.g., Apple Silicon M1). -The pre-built boxes can be found on [Vagrant Cloud](https://app.vagrantup.com/bytesguy) +This repository contains Packer files for building VMware Fusion based Vagrant base boxes for ARM hosts. -🚨 These should not be used for production workloads - use them at your own risk! 🚨 +🚨 These Vagrant boxes should not be used for production workloads - use them at your own risk! 🚨 -## Currently Supported Boxes +## Supported Boxes -| Distro | Version | Provider | Source | Box | -| ------ | ------- | -------- | ------ | --- | -| Ubuntu Server | 20.04.3 (Focal Fossa) | VMWare Fusion | [Source](ubuntu-server-20.04/) | [bytesguy/ubuntu-server-20.04-arm64](https://app.vagrantup.com/bytesguy/boxes/ubuntu-server-20.04-arm64) | -| Ubuntu Server | 20.04.3 (Focal Fossa) | Parallels | [Source](ubuntu-server-20.04/) | [bytesguy/ubuntu-server-20.04-arm64](https://app.vagrantup.com/bytesguy/boxes/ubuntu-server-20.04-arm64) | -| Ubuntu Server | 21.10 (Impish Indri) | VMWare Fusion | [Source](ubuntu-server-21.10/) | [bytesguy/ubuntu-server-21.10-arm64](https://app.vagrantup.com/bytesguy/boxes/ubuntu-server-21.10-arm64) | -| Debian | 11.2 (Bullseye) | VMWare Fusion | [Source](debian-11/) | [bytesguy/debian-11-arm64](https://app.vagrantup.com/bytesguy/boxes/debian-11-arm64) | -| Debian | 11.3 (Bullseye) | Parallels | [Source](debian-11/) | [bytesguy/debian-11-arm64](https://app.vagrantup.com/bytesguy/boxes/debian-11-arm64) | -| Debian | 10.11 (Buster) | VMWare Fusion | [Source](debian-10/) | [bytesguy/debian-10-arm64](https://app.vagrantup.com/bytesguy/boxes/debian-10-arm64) | +| Distro | Version | Provider | Source | +| ------------- | ------- | ------------- | ----------------------------- | +| CentOS Stream | 9 | VMware Fusion | [Source](centos-9) | +| Ubuntu Server | 22.04.2 | VMware Fusion | [Source](ubuntu-server-22.04) | +| Debian | 11 | VMware Fusion | [Source](debian-11) | -## In-Progress / Planned +## Dependencies -| Distro | Version | Provider | Source | -| ------ | ------- | -------- | ------ | -| Ubuntu Server | 22.04 | VMWare Fusion | [Source](ubuntu-server-22.04/) | -| Centos | 9 Stream | VMWare Fusion | [Source](centos-9/) | -| Fedora | 35 | VMWare Fusion | [Source](fedora-35/) | -| FreeBSD | 14 | VMWare Fusion | [Source](freebsd-14/) | +- [Packer](https://www.packer.io/): -## Usage Instructions + ```bash + brew install packer + ``` -TODO +- [Vagrant](https://www.vagrantup.com/): -## Building Instructions + ```bash + # You may need to install rosetta first + # sudo softwareupdate --install-rosetta + brew install --cask vagrant + ``` -The VM images are built with Packer and VMWare Fusion. Each subdirectory in this repo contains all the files needed to build the base box. The easiest way of building the box is to run the `buildbox.sh` command. This will start Packer and build the image, then compact the image into a box and print the checksum. +- [VMware Fusion](https://customerconnect.vmware.com/en/evalcenter?p=fusion-player-personal-13) +- [Vagrant VMware Utility](https://formulae.brew.sh/cask/vagrant-vmware-utility): + + ```bash + brew install --cask vagrant-vmware-utility + ``` + +- [Vagrant VMware provider plugin](https://developer.hashicorp.com/vagrant/docs/providers/vmware/installation): + + ```bash + vagrant plugin install vagrant-vmware-desktop + ``` + +## Usage + +1. Use the `buildbox.sh` script in each directory to build the box and add it to Vagrant: + + ```bash + chmod +x ./buildbox.sh && ./buildbox.sh + ``` + +2. Start the VM with Vagrant: + + ```bash + vagrant up + ``` + +Enjoy! ✨🚀 + +## License + +[MIT](LICENSE) diff --git a/centos-9/Vagrantfile b/centos-9/Vagrantfile new file mode 100644 index 0000000..9c7ea45 --- /dev/null +++ b/centos-9/Vagrantfile @@ -0,0 +1,11 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "centos9-arm64" + config.vm.provider "vmware_desktop" do |v| + v.gui = true + v.vmx["ethernet0.virtualDev"] = "e1000e" + v.vmx["usb_xhci.present"] = "true" + end +end diff --git a/centos-9/add-key.sh b/centos-9/add-key.sh deleted file mode 100644 index 4f6f19a..0000000 --- a/centos-9/add-key.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -mkdir /home/vagrant/.ssh -chmod 0700 /home/vagrant/.ssh -wget -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub -chmod 0600 /home/vagrant/.ssh/authorized_keys \ No newline at end of file diff --git a/centos-9/buildbox.sh b/centos-9/buildbox.sh index 1dfff11..c4ce29e 100755 --- a/centos-9/buildbox.sh +++ b/centos-9/buildbox.sh @@ -1,10 +1,16 @@ #!/bin/bash +BOX_NAME="centos9-arm64.box" -# TODO: Pull and inject md5 hash into packer -packer init vmware-centos9.pkr.hcl -packer build -force vmware-centos9.pkr.hcl -cp metadata.json output/metadata.json -cd output -tar cvzf vmware-centos9-arm64.box ./* -md5 vmware-centos9-arm64.box -rm -f *.v* *.nvram metadata.json \ No newline at end of file +# Initalise packer and build the VM +packer init . +packer build -force . +# Copy Vagrant metadata file to artifacts directory +cp metadata.json artifacts/metadata.json && cd artifacts +# Create Vagrant box +tar -cvzf $BOX_NAME ./* +# Show the SHA256 checksum of the box +shasum -a 256 $BOX_NAME +# Clean up +rm -f *.v* *.nvram *.log *.scoreboard *.plist metadata.json +# Add the box to Vagrant +vagrant box add --force --name "centos9-arm64" $BOX_NAME diff --git a/centos-9/centos9.auto.pkr.hcl b/centos-9/centos9.auto.pkr.hcl new file mode 100644 index 0000000..5c30fc8 --- /dev/null +++ b/centos-9/centos9.auto.pkr.hcl @@ -0,0 +1,106 @@ +// centos9 packer variables file + +variable "vm_guest_os_language" { + type = string + description = "Guest OS language" + default = "en_GB" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "Guest OS keyboard" + default = "gb" +} + +variable "vm_guest_os_timezone" { + type = string + description = "Guest OS timezone" + default = "Europe/London" +} + +variable "vm_guest_os_install_url" { + type = string + description = "Guest OS install URL" + default = "https://mirror.stream.centos.org/9-stream/BaseOS/aarch64/os/" +} + +variable "vm_guest_os_repo_url" { + type = string + description = "Guest OS repo URL" + default = "https://mirror.stream.centos.org/9-stream/AppStream/aarch64/os/" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#disk_size +variable "disk_size" { + type = number + description = "Size of the disk in MB" + // ~40GB + default = 40000 +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#guest_os_type +variable "guest_os_type" { + type = string + description = "Guest OS type" + default = "arm-fedora-64" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#version +variable "vmx_hardware_version" { + type = number + description = "VMX hardware version" + default = 20 +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#vm_name +variable "vm_name" { + type = string + description = "VM name" + default = "centos9" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration +variable "disk_adapter_type" { + type = string + description = "Disk adapter type" + default = "nvme" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration +variable "disk_type_id" { + type = string + description = "Disk type ID" + default = "1" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#iso-configuration +variable "iso_checksum" { + type = string + description = "ISO checksum" + default = "file:https://mirror.stream.centos.org/9-stream/BaseOS/aarch64/iso/CentOS-Stream-9-latest-aarch64-boot.iso.SHA256SUM" +} + +variable "iso_url" { + type = string + default = "https://mirror.stream.centos.org/9-stream/BaseOS/aarch64/iso/CentOS-Stream-9-latest-aarch64-boot.iso" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#hardware-configuration +variable "cpus" { + type = number + description = "Number of CPUs" + default = 2 +} + +variable "memory" { + type = number + description = "Memory in MB" + default = 2048 +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional-ssh-fields +variable "ssh_timeout" { + type = string + description = "SSH timeout" + default = "30m" +} diff --git a/centos-9/centos9.pkr.hcl b/centos-9/centos9.pkr.hcl new file mode 100644 index 0000000..7704474 --- /dev/null +++ b/centos-9/centos9.pkr.hcl @@ -0,0 +1,91 @@ +packer { + required_version = ">= 1.8.5" + required_plugins { + vmware = { + version = ">= 1.0.7" + source = "github.com/hashicorp/vmware" + } + } +} + +locals { + data_source_content = { + "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", { + vm_guest_os_language = var.vm_guest_os_language + vm_guest_os_keyboard = var.vm_guest_os_keyboard + vm_guest_os_timezone = var.vm_guest_os_timezone + vm_guest_os_install_url = var.vm_guest_os_install_url + vm_guest_os_repo_url = var.vm_guest_os_repo_url + }) + } +} + +source "vmware-iso" "centos-9" { + // Optional configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional + disk_size = var.disk_size + guest_os_type = var.guest_os_type + version = var.vmx_hardware_version + vm_name = var.vm_name + + // Extra disk configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration + disk_adapter_type = var.disk_adapter_type + disk_type_id = var.disk_type_id + + // ISO configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#iso-configuration + iso_checksum = var.iso_checksum + iso_url = var.iso_url + + // HTTP configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#http-directory-configuration + http_content = local.data_source_content + + // Shutdown configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#shutdown-configuration + shutdown_command = "sudo shutdown -h now" + + // Hardware configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#hardware-configuration + cpus = var.cpus + memory = var.memory + usb = true + + // Output configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#output-configuration + output_directory = "artifacts" + + // VMX configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#vmx-configuration + vmx_data = { + "ethernet0.virtualdev" = "e1000e" + "usb_xhci.present" = "true" + } + + // SSH configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional-ssh-fields + ssh_username = "vagrant" + ssh_password = "vagrant" + ssh_timeout = var.ssh_timeout + + // Boot configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#boot-configuration + boot_command = [ + "", + "e", + "", + "text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", + "x" + ] +} + +build { + sources = ["sources.vmware-iso.centos-9"] + + provisioner "shell" { + scripts = [ + "scripts/post-install.sh" + ] + } +} diff --git a/centos-9/data/ks.pkrtpl.hcl b/centos-9/data/ks.pkrtpl.hcl new file mode 100644 index 0000000..861de6e --- /dev/null +++ b/centos-9/data/ks.pkrtpl.hcl @@ -0,0 +1,45 @@ +# Kickstart file for CentOS 9 Stream +reboot +text --non-interactive +eula --agreed + +# Configure language +lang ${vm_guest_os_language} + +# Configure keyboard +keyboard ${vm_guest_os_keyboard} + +# Configure timezone +timezone ${vm_guest_os_timezone} + +# Configure install source +url --url=${vm_guest_os_install_url} + +# Configure repo for CentOS 9 Stream +repo --name=centos9-AppStream --baseurl=${vm_guest_os_repo_url} + +# Configure packages to be installed +%packages +@^minimal-environment +open-vm-tools +wget +%end + +# Run the setup agent on first boot +firstboot --enable + +# Configure disk and paritioning +ignoredisk --only-use=nvme0n1 +autopart + +# Partition clearing information +clearpart --none --initlabel + +# Root password and user configuration +rootpw --plaintext vagrant +user --groups=wheel --name=vagrant --password=vagrant --plaintext --uid=1000 --gid=1000 --gecos="vagrant" + +# Post configuration +%post +echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant +%end diff --git a/centos-9/http/ks.cfg b/centos-9/http/ks.cfg deleted file mode 100644 index 7a7dca5..0000000 --- a/centos-9/http/ks.cfg +++ /dev/null @@ -1,40 +0,0 @@ -# Generated by Anaconda 34.25.0.23 -# Generated by pykickstart v3.32 -#version=RHEL9 -text --non-interactive - -%addon com_redhat_kdump --enable --reserve-mb='auto' - -%end - -# Keyboard layouts -keyboard --xlayouts='us' -# System language -lang en_US.UTF-8 - -%packages -@^minimal-environment -open-vm-tools - -%end - -# Run the Setup Agent on first boot -firstboot --enable - -# Generated using Blivet version 3.4.0 -ignoredisk --only-use=nvme0n1 -autopart -# Partition clearing information -clearpart --none --initlabel - -# System timezone -timezone Europe/London --utc - -# Root password -rootpw --iscrypted $6$abuMwhR2mVqZe90T$xB8SpkmbZx3NiAhm.vQZjRaS9h/XYow3mlF1i0pgJxyl8Qb7gAg/TPbw.6rXDAo7VxPBkLFz06buhdGtYofcG/ -user --groups=wheel --name=vagrant --password=$6$9qB2Wej06Q0KUf75$jX4ePKHL2x.T.TNVGEksqHcumXoLhEm6//HiMN4r2/z2twhF95Oo4IIQlIJQ0iXgMv.usRm7adw3eEoixDmbl1 --iscrypted --uid=1000 --gecos="vagrant" --gid=1000 - -%post -echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant - -%end \ No newline at end of file diff --git a/centos-9/scripts/post-install.sh b/centos-9/scripts/post-install.sh new file mode 100644 index 0000000..fa7de7d --- /dev/null +++ b/centos-9/scripts/post-install.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Configure vagrant SSH key based authentication +mkdir -pv /home/vagrant/.ssh +chmod 700 /home/vagrant/.ssh +wget -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub +chmod 644 /home/vagrant/.ssh/authorized_keys +# Modify SSH server configuration +sudo sed -i 's/^UseDNS yes/UseDNS no/' /etc/ssh/sshd_config +# Shrink the disk +sudo dd if=/dev/zero of=/EMPTY bs=1M +sudo rm -f /EMPTY +sync +sudo vmware-toolbox-cmd disk shrink / diff --git a/centos-9/vmware-centos9.pkr.hcl b/centos-9/vmware-centos9.pkr.hcl deleted file mode 100644 index 7743d91..0000000 --- a/centos-9/vmware-centos9.pkr.hcl +++ /dev/null @@ -1,53 +0,0 @@ -packer { - required_plugins { - vmware = { - version = ">= 1.0.5" - source = "github.com/hashicorp/vmware" - } - } -} - -source "vmware-iso" "centos-9" { - iso_url = "http://mirror.stream.centos.org/9-stream/BaseOS/aarch64/iso/CentOS-Stream-9-latest-aarch64-boot.iso" - # As Stream is updated daily we skip the checksum by default - # buildbox script can pull the latest checksum for verfication if required - iso_checksum = "none" - ssh_username = "vagrant" - ssh_password = "vagrant" - ssh_timeout = "30m" - shutdown_command = "sudo shutdown -h now" - guest_os_type = "arm-fedora-64" - disk_adapter_type = "nvme" - version = 19 - http_directory = "http" - boot_command = [ - "c", - "linux /images/pxeboot/vmlinuz inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg", - "", - "initrd /images/pxeboot/initrd.img", - "", - "boot", - "" - ] - usb = true - vmx_data = { - "usb_xhci.present" = "true", - "ethernet0.virtualdev" = "e1000e" - } - memory = 2048 - cpus = 2 - disk_size = 40000 - vm_name = "Centos 9 Stream" - output_directory = "output" -} - -build { - sources = ["sources.vmware-iso.centos-9"] - - provisioner "shell" { - scripts = [ - "add-key.sh", - "vmware-cleanup.sh" - ] - } -} \ No newline at end of file diff --git a/centos-9/vmware-cleanup.sh b/centos-9/vmware-cleanup.sh deleted file mode 100644 index b4508e5..0000000 --- a/centos-9/vmware-cleanup.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -sudo e4defrag / -sudo dd if=/dev/zero of=/EMPTY bs=1M -sudo rm -f /EMPTY -sync -sudo vmware-toolbox-cmd disk shrink / \ No newline at end of file diff --git a/debian-10/add-key.sh b/debian-10/add-key.sh deleted file mode 100644 index 4f6f19a..0000000 --- a/debian-10/add-key.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -mkdir /home/vagrant/.ssh -chmod 0700 /home/vagrant/.ssh -wget -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub -chmod 0600 /home/vagrant/.ssh/authorized_keys \ No newline at end of file diff --git a/debian-10/buildbox.sh b/debian-10/buildbox.sh deleted file mode 100755 index b70e374..0000000 --- a/debian-10/buildbox.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -packer init vmware-buster.pkr.hcl -packer build -force vmware-buster.pkr.hcl -cp metadata.json output/metadata.json -cd output -tar cvzf vmware-buster-arm64.box ./* -md5 vmware-buster-arm64.box -rm -rf *.v* *.nvram metadata.json \ No newline at end of file diff --git a/debian-10/http/preseed.cfg b/debian-10/http/preseed.cfg deleted file mode 100644 index 7144bf9..0000000 --- a/debian-10/http/preseed.cfg +++ /dev/null @@ -1,436 +0,0 @@ -#### Contents of the preconfiguration file (for buster) -### Localization -# Preseeding only locale sets language, country and locale. -d-i debian-installer/locale string en_US - -# The values can also be preseeded individually for greater flexibility. -#d-i debian-installer/language string en -#d-i debian-installer/country string NL -#d-i debian-installer/locale string en_GB.UTF-8 -# Optionally specify additional locales to be generated. -#d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8 - -# Keyboard selection. -d-i keyboard-configuration/xkb-keymap select us -# d-i keyboard-configuration/toggle select No toggling - -### Network configuration -# Disable network configuration entirely. This is useful for cdrom -# installations on non-networked devices where the network questions, -# warning and long timeouts are a nuisance. -#d-i netcfg/enable boolean false - -# netcfg will choose an interface that has link if possible. This makes it -# skip displaying a list if there is more than one interface. -d-i netcfg/choose_interface select auto - -# To pick a particular interface instead: -#d-i netcfg/choose_interface select eth1 - -# To set a different link detection timeout (default is 3 seconds). -# Values are interpreted as seconds. -#d-i netcfg/link_wait_timeout string 10 - -# If you have a slow dhcp server and the installer times out waiting for -# it, this might be useful. -#d-i netcfg/dhcp_timeout string 60 -#d-i netcfg/dhcpv6_timeout string 60 - -# If you prefer to configure the network manually, uncomment this line and -# the static network configuration below. -#d-i netcfg/disable_autoconfig boolean true - -# If you want the preconfiguration file to work on systems both with and -# without a dhcp server, uncomment these lines and the static network -# configuration below. -#d-i netcfg/dhcp_failed note -#d-i netcfg/dhcp_options select Configure network manually - -# Static network configuration. -# -# IPv4 example -#d-i netcfg/get_ipaddress string 192.168.1.42 -#d-i netcfg/get_netmask string 255.255.255.0 -#d-i netcfg/get_gateway string 192.168.1.1 -#d-i netcfg/get_nameservers string 192.168.1.1 -#d-i netcfg/confirm_static boolean true -# -# IPv6 example -#d-i netcfg/get_ipaddress string fc00::2 -#d-i netcfg/get_netmask string ffff:ffff:ffff:ffff:: -#d-i netcfg/get_gateway string fc00::1 -#d-i netcfg/get_nameservers string fc00::1 -#d-i netcfg/confirm_static boolean true - -# Any hostname and domain names assigned from dhcp take precedence over -# values set here. However, setting the values still prevents the questions -# from being shown, even if values come from dhcp. -d-i netcfg/get_hostname string unassigned-hostname -d-i netcfg/get_domain string unassigned-domain - -# If you want to force a hostname, regardless of what either the DHCP -# server returns or what the reverse DNS entry for the IP is, uncomment -# and adjust the following line. -d-i netcfg/hostname string debian - -# Disable that annoying WEP key dialog. -d-i netcfg/wireless_wep string -# The wacky dhcp hostname that some ISPs use as a password of sorts. -#d-i netcfg/dhcp_hostname string radish - -# If non-free firmware is needed for the network or other hardware, you can -# configure the installer to always try to load it, without prompting. Or -# change to false to disable asking. -#d-i hw-detect/load_firmware boolean true - -### Network console -# Use the following settings if you wish to make use of the network-console -# component for remote installation over SSH. This only makes sense if you -# intend to perform the remainder of the installation manually. -#d-i anna/choose_modules string network-console -#d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key -#d-i network-console/password password r00tme -#d-i network-console/password-again password r00tme - -### Mirror settings -# If you select ftp, the mirror/country string does not need to be set. -#d-i mirror/protocol string ftp -d-i mirror/country string manual -d-i mirror/http/hostname string http.us.debian.org -d-i mirror/http/directory string /debian -d-i mirror/http/proxy string - -# Suite to install. -#d-i mirror/suite string testing -# Suite to use for loading installer components (optional). -#d-i mirror/udeb/suite string testing - -### Account setup -# Skip creation of a root account (normal user account will be able to -# use sudo). -#d-i passwd/root-login boolean false -# Alternatively, to skip creation of a normal user account. -#d-i passwd/make-user boolean false - -# Root password, either in clear text -d-i passwd/root-password password vagrant -d-i passwd/root-password-again password vagrant -# or encrypted using a crypt(3) hash. -#d-i passwd/root-password-crypted password [crypt(3) hash] - -# To create a normal user account. -d-i passwd/user-fullname string Debian User -d-i passwd/username string vagrant -# Normal user's password, either in clear text -d-i passwd/user-password password vagrant -d-i passwd/user-password-again password vagrant -# or encrypted using a crypt(3) hash. -#d-i passwd/user-password-crypted password [crypt(3) hash] -# Create the first user with the specified UID instead of the default. -d-i passwd/user-uid string 1010 - -# The user account will be added to some standard initial groups. To -# override that, use this. -#d-i passwd/user-default-groups string audio cdrom video - -### Clock and time zone setup -# Controls whether or not the hardware clock is set to UTC. -d-i clock-setup/utc boolean true - -# You may set this to any valid setting for $TZ; see the contents of -# /usr/share/zoneinfo/ for valid values. -d-i time/zone string US/Eastern - -# Controls whether to use NTP to set the clock during the install -d-i clock-setup/ntp boolean true -# NTP server to use. The default is almost always fine here. -#d-i clock-setup/ntp-server string ntp.example.com - -### Partitioning -## Partitioning example -# If the system has free space you can choose to only partition that space. -# This is only honoured if partman-auto/method (below) is not set. -#d-i partman-auto/init_automatically_partition select biggest_free - -# Alternatively, you may specify a disk to partition. If the system has only -# one disk the installer will default to using that, but otherwise the device -# name must be given in traditional, non-devfs format (so e.g. /dev/sda -# and not e.g. /dev/discs/disc0/disc). -# For example, to use the first SCSI/SATA hard disk: -#d-i partman-auto/disk string /dev/sda -# In addition, you'll need to specify the method to use. -# The presently available methods are: -# - regular: use the usual partition types for your architecture -# - lvm: use LVM to partition the disk -# - crypto: use LVM within an encrypted partition -d-i partman-auto/method string lvm - -# You can define the amount of space that will be used for the LVM volume -# group. It can either be a size with its unit (eg. 20 GB), a percentage of -# free space or the 'max' keyword. -d-i partman-auto-lvm/guided_size string max - -# If one of the disks that are going to be automatically partitioned -# contains an old LVM configuration, the user will normally receive a -# warning. This can be preseeded away... -d-i partman-lvm/device_remove_lvm boolean true -# The same applies to pre-existing software RAID array: -d-i partman-md/device_remove_md boolean true -# And the same goes for the confirmation to write the lvm partitions. -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm_nooverwrite boolean true - -# You can choose one of the three predefined partitioning recipes: -# - atomic: all files in one partition -# - home: separate /home partition -# - multi: separate /home, /var, and /tmp partitions -d-i partman-auto/choose_recipe select atomic - -# Or provide a recipe of your own... -# If you have a way to get a recipe file into the d-i environment, you can -# just point at it. -#d-i partman-auto/expert_recipe_file string /hd-media/recipe - -# If not, you can put an entire recipe into the preconfiguration file in one -# (logical) line. This example creates a small /boot partition, suitable -# swap, and uses the rest of the space for the root partition: -#d-i partman-auto/expert_recipe string \ -# boot-root :: \ -# 40 50 100 ext3 \ -# $primary{ } $bootable{ } \ -# method{ format } format{ } \ -# use_filesystem{ } filesystem{ ext3 } \ -# mountpoint{ /boot } \ -# . \ -# 500 10000 1000000000 ext3 \ -# method{ format } format{ } \ -# use_filesystem{ } filesystem{ ext3 } \ -# mountpoint{ / } \ -# . \ -# 64 512 300% linux-swap \ -# method{ swap } format{ } \ -# . - -# The full recipe format is documented in the file partman-auto-recipe.txt -# included in the 'debian-installer' package or available from D-I source -# repository. This also documents how to specify settings such as file -# system labels, volume group names and which physical devices to include -# in a volume group. - -# This makes partman automatically partition without confirmation, provided -# that you told it what to do using one of the methods above. -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -# When disk encryption is enabled, skip wiping the partitions beforehand. -#d-i partman-auto-crypto/erase_disks boolean false - -## Partitioning using RAID -# The method should be set to "raid". -#d-i partman-auto/method string raid -# Specify the disks to be partitioned. They will all get the same layout, -# so this will only work if the disks are the same size. -#d-i partman-auto/disk string /dev/sda /dev/sdb - -# Next you need to specify the physical partitions that will be used. -#d-i partman-auto/expert_recipe string \ -# multiraid :: \ -# 1000 5000 4000 raid \ -# $primary{ } method{ raid } \ -# . \ -# 64 512 300% raid \ -# method{ raid } \ -# . \ -# 500 10000 1000000000 raid \ -# method{ raid } \ -# . - -# Last you need to specify how the previously defined partitions will be -# used in the RAID setup. Remember to use the correct partition numbers -# for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported; -# devices are separated using "#". -# Parameters are: -# \ -# - -#d-i partman-auto-raid/recipe string \ -# 1 2 0 ext3 / \ -# /dev/sda1#/dev/sdb1 \ -# . \ -# 1 2 0 swap - \ -# /dev/sda5#/dev/sdb5 \ -# . \ -# 0 2 0 ext3 /home \ -# /dev/sda6#/dev/sdb6 \ -# . - -# For additional information see the file partman-auto-raid-recipe.txt -# included in the 'debian-installer' package or available from D-I source -# repository. - -# This makes partman automatically partition without confirmation. -d-i partman-md/confirm boolean true -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -## Controlling how partitions are mounted -# The default is to mount by UUID, but you can also choose "traditional" to -# use traditional device names, or "label" to try filesystem labels before -# falling back to UUIDs. -#d-i partman/mount_style select uuid - -### Base system installation -# Configure APT to not install recommended packages by default. Use of this -# option can result in an incomplete system and should only be used by very -# experienced users. -#d-i base-installer/install-recommends boolean false - -# The kernel image (meta) package to be installed; "none" can be used if no -# kernel is to be installed. -#d-i base-installer/kernel/image string linux-image-686 - -### Apt setup -# You can choose to install non-free and contrib software. -#d-i apt-setup/non-free boolean true -#d-i apt-setup/contrib boolean true -# Uncomment this if you don't want to use a network mirror. -#d-i apt-setup/use_mirror boolean false -# Select which update services to use; define the mirrors to be used. -# Values shown below are the normal defaults. -#d-i apt-setup/services-select multiselect security, updates -#d-i apt-setup/security_host string security.debian.org - -# Additional repositories, local[0-9] available -#d-i apt-setup/local0/repository string \ -# http://local.server/debian stable main -#d-i apt-setup/local0/comment string local server -# Enable deb-src lines -#d-i apt-setup/local0/source boolean true -# URL to the public key of the local repository; you must provide a key or -# apt will complain about the unauthenticated repository and so the -# sources.list line will be left commented out -#d-i apt-setup/local0/key string http://local.server/key - -# By default the installer requires that repositories be authenticated -# using a known gpg key. This setting can be used to disable that -# authentication. Warning: Insecure, not recommended. -#d-i debian-installer/allow_unauthenticated boolean true - -# Uncomment this to add multiarch configuration for i386 -#d-i apt-setup/multiarch string i386 - - -### Package selection -tasksel tasksel/first multiselect standard, ssh-server - -# Individual additional packages to install -d-i pkgsel/include string sudo fuse3 -# Whether to upgrade packages after debootstrap. -# Allowed values: none, safe-upgrade, full-upgrade -#d-i pkgsel/upgrade select none - -# Some versions of the installer can report back on what software you have -# installed, and what software you use. The default is not to report back, -# but sending reports helps the project determine what software is most -# popular and include it on CDs. -#popularity-contest popularity-contest/participate boolean false - -### Boot loader installation -# Grub is the default boot loader (for x86). If you want lilo installed -# instead, uncomment this: -#d-i grub-installer/skip boolean true -# To also skip installing lilo, and install no bootloader, uncomment this -# too: -#d-i lilo-installer/skip boolean true - - -# This is fairly safe to set, it makes grub install automatically to the MBR -# if no other operating system is detected on the machine. -d-i grub-installer/only_debian boolean true - -# This one makes grub-installer install to the MBR if it also finds some other -# OS, which is less safe as it might not be able to boot that other OS. -d-i grub-installer/with_other_os boolean true - -# Due notably to potential USB sticks, the location of the MBR can not be -# determined safely in general, so this needs to be specified: -#d-i grub-installer/bootdev string /dev/sda -# To install to the first device (assuming it is not a USB stick): -#d-i grub-installer/bootdev string default - -# Alternatively, if you want to install to a location other than the mbr, -# uncomment and edit these lines: -#d-i grub-installer/only_debian boolean false -#d-i grub-installer/with_other_os boolean false -#d-i grub-installer/bootdev string (hd0,1) -# To install grub to multiple disks: -#d-i grub-installer/bootdev string (hd0,1) (hd1,1) (hd2,1) - -# Optional password for grub, either in clear text -#d-i grub-installer/password password r00tme -#d-i grub-installer/password-again password r00tme -# or encrypted using an MD5 hash, see grub-md5-crypt(8). -#d-i grub-installer/password-crypted password [MD5 hash] - -# Use the following option to add additional boot parameters for the -# installed system (if supported by the bootloader installer). -# Note: options passed to the installer will be added automatically. -#d-i debian-installer/add-kernel-opts string nousb - -### Finishing up the installation -# During installations from serial console, the regular virtual consoles -# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next -# line to prevent this. -#d-i finish-install/keep-consoles boolean true - -# Avoid that last message about the install being complete. -d-i finish-install/reboot_in_progress note - -# This will prevent the installer from ejecting the CD during the reboot, -# which is useful in some situations. -#d-i cdrom-detect/eject boolean false - -# This is how to make the installer shutdown when finished, but not -# reboot into the installed system. -#d-i debian-installer/exit/halt boolean true -# This will power off the machine instead of just halting it. -#d-i debian-installer/exit/poweroff boolean true - -### Preseeding other packages -# Depending on what software you choose to install, or if things go wrong -# during the installation process, it's possible that other questions may -# be asked. You can preseed those too, of course. To get a list of every -# possible question that could be asked during an install, do an -# installation, and then run these commands: -# debconf-get-selections --installer > file -# debconf-get-selections >> file - - -#### Advanced options -### Running custom commands during the installation -# d-i preseeding is inherently not secure. Nothing in the installer checks -# for attempts at buffer overflows or other exploits of the values of a -# preconfiguration file like this one. Only use preconfiguration files from -# trusted locations! To drive that home, and because it's generally useful, -# here's a way to run any shell command you'd like inside the installer, -# automatically. - -# This first command is run as early as possible, just after -# preseeding is read. -#d-i preseed/early_command string anna-install some-udeb -# This command is run immediately before the partitioner starts. It may be -# useful to apply dynamic partitioner preseeding that depends on the state -# of the disks (which may not be visible when preseed/early_command runs). -#d-i partman/early_command \ -# string debconf-set partman-auto/disk "$(list-devices disk | head -n1)" -# This command is run just before the install finishes, but when there is -# still a usable /target directory. You can chroot to /target and use it -# directly, or use the apt-install and in-target commands to easily install -# packages and run commands in the target system. -d-i preseed/late_command string \ - echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /target/etc/sudoers.d/vagrant ; - echo export PATH=/sbin:$PATH >> ~/.bashrc diff --git a/debian-10/metadata.json b/debian-10/metadata.json deleted file mode 100644 index 121f0fc..0000000 --- a/debian-10/metadata.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "provider": "vmware_fusion" -} \ No newline at end of file diff --git a/debian-10/vmware-buster.pkr.hcl b/debian-10/vmware-buster.pkr.hcl deleted file mode 100644 index 0948454..0000000 --- a/debian-10/vmware-buster.pkr.hcl +++ /dev/null @@ -1,50 +0,0 @@ -packer { - required_plugins { - vmware = { - version = ">= 1.0.5" - source = "github.com/hashicorp/vmware" - } - } -} - -source "vmware-iso" "debian-buster" { - iso_url = "https://cdimage.debian.org/cdimage/archive/10.11.0/arm64/iso-cd/debian-10.11.0-arm64-netinst.iso" - iso_checksum = "md5:6dc8ea84db6cc9c36c34045891f12f5b" - ssh_username = "vagrant" - ssh_password = "vagrant" - ssh_timeout = "30m" - shutdown_command = "sudo shutdown -h now" - guest_os_type = "arm-debian10-64" - disk_adapter_type = "nvme" - version = 19 - http_directory = "http" - boot_command = [ - "c", - "linux /install.a64/vmlinuz auto=true priority=critical url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg --- quiet", - "", - "initrd /install.a64/initrd.gz", - "", - "boot", - "" - ] - usb = true - vmx_data = { - "usb_xhci.present" = "true" - } - memory = 2048 - cpus = 2 - disk_size = 40000 - vm_name = "Debian 10" - output_directory = "output" -} - -build { - sources = ["sources.vmware-iso.debian-buster"] - - provisioner "shell" { - scripts = [ - "add-key.sh", - "vmware-cleanup.sh" - ] - } -} \ No newline at end of file diff --git a/debian-10/vmware-cleanup.sh b/debian-10/vmware-cleanup.sh deleted file mode 100644 index ef9e60a..0000000 --- a/debian-10/vmware-cleanup.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -x - -# sudo e4defrag / - -wget https://packages.vmware.com/tools/open-vm-tools/ovt-arm-tech-preview/Debian-10/open-vm-tools-11.2.5-2debian10.tgz -tar -zxf open-vm-tools-11.2.5-2debian10.tgz -sudo dpkg -i ./open-vm-tools_11.2.5-2debian10_arm64.deb -sudo apt --fix-broken install -y -sudo mkdir -p /mnt/hgfs/ -sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs/ -o subtype=vmhgfs-fuse,allow_other - -sudo apt-get clean -sudo dd if=/dev/zero of=/EMPTY bs=1M -sudo rm -f /EMPTY -sync - -sudo vmware-toolbox-cmd disk shrink / \ No newline at end of file diff --git a/debian-11/Vagrantfile b/debian-11/Vagrantfile new file mode 100644 index 0000000..fbe6654 --- /dev/null +++ b/debian-11/Vagrantfile @@ -0,0 +1,11 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "debian-11-arm64" + config.vm.provider "vmware_desktop" do |v| + v.gui = true + v.vmx["ethernet0.virtualDev"] = "e1000e" + v.vmx["usb_xhci.present"] = "true" + end +end diff --git a/debian-11/add-key.sh b/debian-11/add-key.sh deleted file mode 100644 index 4f6f19a..0000000 --- a/debian-11/add-key.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -mkdir /home/vagrant/.ssh -chmod 0700 /home/vagrant/.ssh -wget -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub -chmod 0600 /home/vagrant/.ssh/authorized_keys \ No newline at end of file diff --git a/debian-11/buildbox-parallels.sh b/debian-11/buildbox-parallels.sh deleted file mode 100755 index 881d9b6..0000000 --- a/debian-11/buildbox-parallels.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -packer init parallels-bullseye.pkr.hcl -packer build -force parallels-bullseye.pkr.hcl -cp metadata-parallels.json output/metadata.json -prl_disk_tool compact --hdd output/*.pvm/*.hdd -cd output -tar cvzf parallels-bullseye-arm64.box ./* -md5 parallels-bullseye-arm64.box -rm -rf *.pvm metadata.json \ No newline at end of file diff --git a/debian-11/buildbox-vmware.sh b/debian-11/buildbox-vmware.sh deleted file mode 100755 index 814849d..0000000 --- a/debian-11/buildbox-vmware.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -packer init vmware-bullseye.pkr.hcl -packer build -force vmware-bullseye.pkr.hcl -cp metadata.json output/metadata.json -cd output -tar cvzf vmware-bullseye-arm64.box ./* -md5 vmware-bullseye-arm64.box -rm -rf *.v* *.nvram metadata.json \ No newline at end of file diff --git a/debian-11/buildbox.sh b/debian-11/buildbox.sh new file mode 100755 index 0000000..10e978c --- /dev/null +++ b/debian-11/buildbox.sh @@ -0,0 +1,16 @@ +#!/bin/bash +BOX_NAME="debian-11-arm64.box" + +# Initalise packer and build the VM +packer init . +packer build -force . +# Copy Vagrant metadata file to artifacts directory +cp metadata.json artifacts/metadata.json && cd artifacts +# Create Vagrant box +tar -cvzf $BOX_NAME ./* +# Show the SHA256 checksum of the box +shasum -a 256 $BOX_NAME +# Clean up +rm -f *.v* *.nvram *.log *.scoreboard *.plist metadata.json +# Add the box to Vagrant +vagrant box add --force --name "debian-11-arm64" $BOX_NAME diff --git a/debian-11/data/preseed.cfg.pkrtpl.hcl b/debian-11/data/preseed.cfg.pkrtpl.hcl new file mode 100644 index 0000000..2e4dc65 --- /dev/null +++ b/debian-11/data/preseed.cfg.pkrtpl.hcl @@ -0,0 +1,289 @@ +#### Contents of the preconfiguration file +### Localization +# Locale sets language and country. +d-i debian-installer/locale string ${vm_guest_os_language} + +# Keyboard selection. +#d-i console-tools/archs select at +d-i keyboard-configuration/xkb-keymap select ${vm_guest_os_keyboard} +# Example for a different keyboard architecture +#d-i console-keymaps-usb/keymap select mac-usb-us + +### Network configuration +# netcfg will choose an interface that has link if possible. This makes it +# skip displaying a list if there is more than one interface. +d-i netcfg/choose_interface select auto + +# To pick a particular interface instead: +#d-i netcfg/choose_interface select eth1 + +# If you have a slow dhcp server and the installer times out waiting for +# it, this might be useful. +#d-i netcfg/dhcp_timeout string 60 + +# If you prefer to configure the network manually, uncomment this line and +# the static network configuration below. +#d-i netcfg/disable_dhcp boolean true + +# If you want the preconfiguration file to work on systems both with and +# without a dhcp server, uncomment these lines and the static network +# configuration below. +#d-i netcfg/dhcp_failed note +#d-i netcfg/dhcp_options select Configure network manually + +# Static network configuration. +#d-i netcfg/get_nameservers string 192.168.1.1 +#d-i netcfg/get_ipaddress string 192.168.1.42 +#d-i netcfg/get_netmask string 255.255.255.0 +#d-i netcfg/get_gateway string 192.168.1.1 +#d-i netcfg/confirm_static boolean true + +# Any hostname and domain names assigned from dhcp take precedence over +# values set here. However, setting the values still prevents the questions +# from being shown, even if values come from dhcp. +d-i netcfg/get_hostname string unassigned-hostname +d-i netcfg/get_domain string unassigned-domain + +# Disable that annoying WEP key dialog. +d-i netcfg/wireless_wep string +# The wacky dhcp hostname that some ISPs use as a password of sorts. +#d-i netcfg/dhcp_hostname string radish + +### Mirror settings +# If you select ftp, the mirror/country string does not need to be set. +#d-i mirror/protocol string ftp +d-i mirror/country string manual +d-i mirror/http/hostname string http.us.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string + +# Suite to install. +#d-i mirror/suite string testing +# Suite to use for loading installer components (optional). +#d-i mirror/udeb/suite string testing + +### Partitioning +# If the system has free space you can choose to only partition that space. +# Note: this must be preseeded with a localized (translated) value. +#d-i partman-auto/init_automatically_partition \ +# select Guided - use the largest continuous free space + +# Alternatively, you can specify a disk to partition. The device name +# can be given in either devfs or traditional non-devfs format. +# For example, to use the first disk: +#d-i partman-auto/disk string /dev/discs/disc0/disc +# In addition, you'll need to specify the method to use. +# The presently available methods are: "regular", "lvm" and "crypto" +d-i partman-auto/method string lvm + +# If one of the disks that are going to be automatically partitioned +# contains an old LVM configuration, the user will normally receive a +# warning. This can be preseeded away... +d-i partman-auto/purge_lvm_from_device boolean true +# And the same goes for the confirmation to write the lvm partitions. +d-i partman-lvm/confirm boolean true +d-i partman-lvm/confirm_nooverwrite boolean true +d-i partman-lvm/device_remove_lvm boolean true +d-i partman-md/device_remove_md boolean true + +# You can choose from any of the predefined partitioning recipes. +# Note: this must be preseeded with a localized (translated) value. +d-i partman-auto/choose_recipe select atomic +# You can define the amount of space that will be used for the LVM volume +# group. It can either be a size with its unit (eg. 20 GB), a percentage of +# free space or the 'max' keyword. +d-i partman-auto-lvm/guided_size string max +#d-i partman-auto/choose_recipe \ +# select Separate /home partition +#d-i partman-auto/choose_recipe \ +# select Separate /home, /usr, /var, and /tmp partitions + +# Or provide a recipe of your own... +# The recipe format is documented in the file devel/partman-auto-recipe.txt. +# If you have a way to get a recipe file into the d-i environment, you can +# just point at it. +#d-i partman-auto/expert_recipe_file string /hd-media/recipe + +# If not, you can put an entire recipe into the preconfiguration file in one +# (logical) line. This example creates a small /boot partition, suitable +# swap, and uses the rest of the space for the root partition: +#d-i partman-auto/expert_recipe string \ +# boot-root :: \ +# 40 50 100 ext3 \ +# $primary{ } $bootable{ } \ +# method{ format } format{ } \ +# use_filesystem{ } filesystem{ ext3 } \ +# mountpoint{ /boot } \ +# . \ +# 500 10000 1000000000 ext3 \ +# method{ format } format{ } \ +# use_filesystem{ } filesystem{ ext3 } \ +# mountpoint{ / } \ +# . \ +# 64 512 300% linux-swap \ +# method{ swap } format{ } \ +# . + +# This makes partman automatically partition without confirmation. +d-i partman/confirm_write_new_label boolean true +d-i partman/choose_partition select finish +d-i partman/confirm boolean true +d-i partman/confirm_nooverwrite boolean true + +### Clock and time zone setup +# Controls whether or not the hardware clock is set to UTC. +d-i clock-setup/utc boolean true + +# You may set this to any valid setting for $TZ; see the contents of +# /usr/share/zoneinfo/ for valid values. +d-i time/zone string ${vm_guest_os_timezone} + +### Apt setup +# You can choose to install non-free and contrib software. +#d-i apt-setup/non-free boolean true +#d-i apt-setup/contrib boolean true +# Uncomment this if you don't want to use a network mirror. +#d-i apt-setup/use_mirror boolean false +# Uncomment this to avoid adding security sources, or +# add a hostname to use a different server than security.debian.org. +#d-i apt-setup/security_host string + +# Additional repositories, local[0-9] available +#d-i apt-setup/local0/repository string \ +# deb http://local.server/debian stable main +#d-i apt-setup/local0/comment string local server +# Enable deb-src lines +#d-i apt-setup/local0/source boolean true +# URL to the public key of the local repository; you must provide a key or +# apt will complain about the unauthenticated repository and so the +# sources.list line will be left commented out +#d-i apt-setup/local0/key string http://local.server/key + +# By default the installer requires that repositories be authenticated +# using a known gpg key. This setting can be used to disable that +# authentication. Warning: Insecure, not recommended. +#d-i debian-installer/allow_unauthenticated string true + +### Account setup +# Skip creation of a root account (normal user account will be able to +# use sudo). +#d-i passwd/root-login boolean false +# Alternatively, to skip creation of a normal user account. +#d-i passwd/make-user boolean false + +# Root password, either in clear text +d-i passwd/root-password password vagrant +d-i passwd/root-password-again password vagrant +# or encrypted using an MD5 hash. +#d-i passwd/root-password-crypted password [MD5 hash] + +# To create a normal user account. +d-i passwd/user-fullname string vagrant +d-i passwd/username string vagrant +# Normal user's password, either in clear text +d-i passwd/user-password password vagrant +d-i passwd/user-password-again password vagrant +# or encrypted using an MD5 hash. +#d-i passwd/user-password-crypted password [MD5 hash] + +### Base system installation +# Select the initramfs generator used to generate the initrd for 2.6 kernels. +#d-i base-installer/kernel/linux/initramfs-generators string yaird + +### Boot loader installation +# Grub is the default boot loader (for x86). If you want lilo installed +# instead, uncomment this: +#d-i grub-installer/skip boolean true + +# This is fairly safe to set, it makes grub install automatically to the MBR +# if no other operating system is detected on the machine. +d-i grub-installer/only_debian boolean true + +# This one makes grub-installer install to the MBR if it also finds some other +# OS, which is less safe as it might not be able to boot that other OS. +d-i grub-installer/with_other_os boolean true + +# Alternatively, if you want to install to a location other than the mbr, +# uncomment and edit these lines: +#d-i grub-installer/only_debian boolean false +#d-i grub-installer/with_other_os boolean false +#d-i grub-installer/bootdev string (hd0,0) +# To install grub to multiple disks: +#d-i grub-installer/bootdev string (hd0,0) (hd1,0) (hd2,0) + +### Package selection +tasksel tasksel/first multiselect standard +#tasksel tasksel/first multiselect standard, desktop +#tasksel tasksel/first multiselect standard, web-server +#tasksel tasksel/first multiselect standard, kde-desktop + +# Individual additional packages to install +d-i pkgsel/include string openssh-server sudo fuse + +# Some versions of the installer can report back on what software you have +# installed, and what software you use. The default is not to report back, +# but sending reports helps the project determine what software is most +# popular and include it on CDs. +#popularity-contest popularity-contest/participate boolean false + +### Finishing up the first stage install +# Avoid that last message about the install being complete. +d-i finish-install/reboot_in_progress note + +# This will prevent the installer from ejecting the CD during the reboot, +# which is useful in some situations. +#d-i cdrom-detect/eject boolean false + +### X configuration +# X can detect the right driver for some cards, but if you're preseeding, +# you override whatever it chooses. Still, vesa will work most places. +#xserver-xorg xserver-xorg/config/device/driver select vesa + +# A caveat with mouse autodetection is that if it fails, X will retry it +# over and over. So if it's preseeded to be done, there is a possibility of +# an infinite loop if the mouse is not autodetected. +#xserver-xorg xserver-xorg/autodetect_mouse boolean true + +# Monitor autodetection is recommended. +#xserver-xorg xserver-xorg/autodetect_monitor boolean true +# Uncomment if you have an LCD display. +#xserver-xorg xserver-xorg/config/monitor/lcd boolean true +# X has three configuration paths for the monitor. Here's how to preseed +# the "medium" path, which is always available. The "simple" path may not +# be available, and the "advanced" path asks too many questions. +#xserver-xorg xserver-xorg/config/monitor/selection-method \ +# select medium +#xserver-xorg xserver-xorg/config/monitor/mode-list \ +# select 1024x768 @ 60 Hz + +### Preseeding other packages +# Depending on what software you choose to install, or if things go wrong +# during the installation process, it's possible that other questions may +# be asked. You can preseed those too, of course. To get a list of every +# possible question that could be asked during an install, do an +# installation, and then run these commands: +# debconf-get-selections --installer > file +# debconf-get-selections >> file + + +#### Advanced options +### Running custom commands during the installation +# d-i preseeding is inherently not secure. Nothing in the installer checks +# for attempts at buffer overflows or other exploits of the values of a +# preconfiguration file like this one. Only use preconfiguration files from +# trusted locations! To drive that home, and because it's generally useful, +# here's a way to run any shell command you'd like inside the installer, +# automatically. + +# This first command is run as early as possible, just after +# preseeding is read. +#d-i preseed/early_command string anna-install some-udeb + +# This command is run just before the install finishes, but when there is +# still a usable /target directory. You can chroot to /target and use it +# directly, or use the apt-install and in-target commands to easily install +# packages and run commands in the target system. +#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh +d-i preseed/late_command string \ + echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /target/etc/sudoers.d/vagrant ; \ + in-target chmod 440 /etc/sudoers.d/vagrant ; diff --git a/debian-11/debian11.auto.pkr.hcl b/debian-11/debian11.auto.pkr.hcl new file mode 100644 index 0000000..3b3dde7 --- /dev/null +++ b/debian-11/debian11.auto.pkr.hcl @@ -0,0 +1,94 @@ +// debian11 packer variables file + +variable "vm_guest_os_language" { + type = string + description = "Guest OS language" + default = "en_GB" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "Guest OS keyboard" + default = "gb" +} + +variable "vm_guest_os_timezone" { + type = string + description = "Guest OS timezone" + default = "Europe/London" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#disk_size +variable "disk_size" { + type = number + description = "Size of the disk in MB" + // ~40GB + default = 40000 +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#guest_os_type +variable "guest_os_type" { + type = string + description = "Guest OS type" + default = "arm-debian-64" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#version +variable "vmx_hardware_version" { + type = number + description = "VMX hardware version" + default = 20 +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#vm_name +variable "vm_name" { + type = string + description = "VM name" + default = "debian11" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration +variable "disk_adapter_type" { + type = string + description = "Disk adapter type" + default = "nvme" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration +variable "disk_type_id" { + type = string + description = "Disk type ID" + default = "1" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#iso-configuration +variable "iso_checksum" { + type = string + description = "ISO checksum" + default = "file:https://cdimage.debian.org/mirror/cdimage/archive/11.6.0/arm64/iso-cd/SHA256SUMS" +} + +variable "iso_url" { + type = string + default = "https://cdimage.debian.org/mirror/cdimage/archive/11.6.0/arm64/iso-cd/debian-11.6.0-arm64-netinst.iso" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#hardware-configuration +variable "cpus" { + type = number + description = "Number of CPUs" + default = 2 +} + +variable "memory" { + type = number + description = "Memory in MB" + default = 2048 +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional-ssh-fields +variable "ssh_timeout" { + type = string + description = "SSH timeout" + default = "30m" +} diff --git a/debian-11/debian11.pkr.hcl b/debian-11/debian11.pkr.hcl new file mode 100644 index 0000000..00965da --- /dev/null +++ b/debian-11/debian11.pkr.hcl @@ -0,0 +1,90 @@ +packer { + required_version = ">= 1.8.5" + required_plugins { + vmware = { + version = ">= 1.0.7" + source = "github.com/hashicorp/vmware" + } + } +} + +locals { + data_source_content = { + "/preseed.cfg" = templatefile("${abspath(path.root)}/data/preseed.cfg.pkrtpl.hcl", { + vm_guest_os_language = var.vm_guest_os_language + vm_guest_os_keyboard = var.vm_guest_os_keyboard + vm_guest_os_timezone = var.vm_guest_os_timezone + }) + } +} + +source "vmware-iso" "debian-11" { + // Optional configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional + disk_size = var.disk_size + guest_os_type = var.guest_os_type + version = var.vmx_hardware_version + vm_name = var.vm_name + + // Extra disk configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration + disk_adapter_type = var.disk_adapter_type + disk_type_id = var.disk_type_id + + // ISO configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#iso-configuration + iso_checksum = var.iso_checksum + iso_url = var.iso_url + + // HTTP configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#http-directory-configuration + http_content = local.data_source_content + + // Shutdown configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#shutdown-configuration + shutdown_command = "sudo shutdown -h now" + + // Hardware configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#hardware-configuration + cpus = var.cpus + memory = var.memory + usb = true + + // Output configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#output-configuration + output_directory = "artifacts" + + // VMX configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#vmx-configuration + vmx_data = { + "ethernet0.virtualdev" = "e1000e" + "usb_xhci.present" = "true" + } + + // SSH configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional-ssh-fields + ssh_username = "vagrant" + ssh_password = "vagrant" + ssh_timeout = var.ssh_timeout + + // Boot configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#boot-configuration + boot_command = [ + "c", + "linux /install.a64/vmlinuz auto-install/enable=true debconf/priority=critical noprompt url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg --", + "initrd /install.a64/initrd.gz", + "", + "boot", + "" + ] +} + +build { + sources = ["sources.vmware-iso.debian-11"] + + provisioner "shell" { + scripts = [ + "scripts/post-install.sh" + ] + } +} diff --git a/debian-11/http/preseed.cfg b/debian-11/http/preseed.cfg deleted file mode 100644 index dc60f1f..0000000 --- a/debian-11/http/preseed.cfg +++ /dev/null @@ -1,456 +0,0 @@ -#_preseed_V1 -#### Contents of the preconfiguration file (for bullseye) -### Localization -# Preseeding only locale sets language, country and locale. -d-i debian-installer/locale string en_US - -# The values can also be preseeded individually for greater flexibility. -#d-i debian-installer/language string en -#d-i debian-installer/country string NL -#d-i debian-installer/locale string en_GB.UTF-8 -# Optionally specify additional locales to be generated. -#d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8 - -# Keyboard selection. -d-i keyboard-configuration/xkb-keymap select us -# d-i keyboard-configuration/toggle select No toggling - -### Network configuration -# Disable network configuration entirely. This is useful for cdrom -# installations on non-networked devices where the network questions, -# warning and long timeouts are a nuisance. -#d-i netcfg/enable boolean false - -# netcfg will choose an interface that has link if possible. This makes it -# skip displaying a list if there is more than one interface. -d-i netcfg/choose_interface select auto - -# To pick a particular interface instead: -#d-i netcfg/choose_interface select eth1 - -# To set a different link detection timeout (default is 3 seconds). -# Values are interpreted as seconds. -#d-i netcfg/link_wait_timeout string 10 - -# If you have a slow dhcp server and the installer times out waiting for -# it, this might be useful. -#d-i netcfg/dhcp_timeout string 60 -#d-i netcfg/dhcpv6_timeout string 60 - -# If you prefer to configure the network manually, uncomment this line and -# the static network configuration below. -#d-i netcfg/disable_autoconfig boolean true - -# If you want the preconfiguration file to work on systems both with and -# without a dhcp server, uncomment these lines and the static network -# configuration below. -#d-i netcfg/dhcp_failed note -#d-i netcfg/dhcp_options select Configure network manually - -# Static network configuration. -# -# IPv4 example -#d-i netcfg/get_ipaddress string 192.168.1.42 -#d-i netcfg/get_netmask string 255.255.255.0 -#d-i netcfg/get_gateway string 192.168.1.1 -#d-i netcfg/get_nameservers string 192.168.1.1 -#d-i netcfg/confirm_static boolean true -# -# IPv6 example -#d-i netcfg/get_ipaddress string fc00::2 -#d-i netcfg/get_netmask string ffff:ffff:ffff:ffff:: -#d-i netcfg/get_gateway string fc00::1 -#d-i netcfg/get_nameservers string fc00::1 -#d-i netcfg/confirm_static boolean true - -# Any hostname and domain names assigned from dhcp take precedence over -# values set here. However, setting the values still prevents the questions -# from being shown, even if values come from dhcp. -d-i netcfg/get_hostname string unassigned-hostname -d-i netcfg/get_domain string unassigned-domain - -# If you want to force a hostname, regardless of what either the DHCP -# server returns or what the reverse DNS entry for the IP is, uncomment -# and adjust the following line. -d-i netcfg/hostname string debian - -# Disable that annoying WEP key dialog. -d-i netcfg/wireless_wep string -# The wacky dhcp hostname that some ISPs use as a password of sorts. -#d-i netcfg/dhcp_hostname string radish - -# If non-free firmware is needed for the network or other hardware, you can -# configure the installer to always try to load it, without prompting. Or -# change to false to disable asking. -#d-i hw-detect/load_firmware boolean true - -### Network console -# Use the following settings if you wish to make use of the network-console -# component for remote installation over SSH. This only makes sense if you -# intend to perform the remainder of the installation manually. -#d-i anna/choose_modules string network-console -#d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key -#d-i network-console/password password r00tme -#d-i network-console/password-again password r00tme - -### Mirror settings -# If you select ftp, the mirror/country string does not need to be set. -#d-i mirror/protocol string ftp -d-i mirror/country string manual -d-i mirror/http/hostname string http.us.debian.org -d-i mirror/http/directory string /debian -d-i mirror/http/proxy string - -# Suite to install. -#d-i mirror/suite string testing -# Suite to use for loading installer components (optional). -#d-i mirror/udeb/suite string testing - -### Account setup -# Skip creation of a root account (normal user account will be able to -# use sudo). -#d-i passwd/root-login boolean false -# Alternatively, to skip creation of a normal user account. -#d-i passwd/make-user boolean false - -# Root password, either in clear text -d-i passwd/root-password password vagrant -d-i passwd/root-password-again password vagrant -# or encrypted using a crypt(3) hash. -#d-i passwd/root-password-crypted password [crypt(3) hash] - -# To create a normal user account. -d-i passwd/user-fullname string Debian User -d-i passwd/username string vagrant -# Normal user's password, either in clear text -d-i passwd/user-password password vagrant -d-i passwd/user-password-again password vagrant -# or encrypted using a crypt(3) hash. -#d-i passwd/user-password-crypted password [crypt(3) hash] -# Create the first user with the specified UID instead of the default. -d-i passwd/user-uid string 1010 - -# The user account will be added to some standard initial groups. To -# override that, use this. -#d-i passwd/user-default-groups string audio cdrom video - -### Clock and time zone setup -# Controls whether or not the hardware clock is set to UTC. -d-i clock-setup/utc boolean true - -# You may set this to any valid setting for $TZ; see the contents of -# /usr/share/zoneinfo/ for valid values. -d-i time/zone string US/Eastern - -# Controls whether to use NTP to set the clock during the install -d-i clock-setup/ntp boolean true -# NTP server to use. The default is almost always fine here. -#d-i clock-setup/ntp-server string ntp.example.com - -### Partitioning -## Partitioning example -# If the system has free space you can choose to only partition that space. -# This is only honoured if partman-auto/method (below) is not set. -#d-i partman-auto/init_automatically_partition select biggest_free - -# Alternatively, you may specify a disk to partition. If the system has only -# one disk the installer will default to using that, but otherwise the device -# name must be given in traditional, non-devfs format (so e.g. /dev/sda -# and not e.g. /dev/discs/disc0/disc). -# For example, to use the first SCSI/SATA hard disk: -#d-i partman-auto/disk string /dev/sda -# In addition, you'll need to specify the method to use. -# The presently available methods are: -# - regular: use the usual partition types for your architecture -# - lvm: use LVM to partition the disk -# - crypto: use LVM within an encrypted partition -d-i partman-auto/method string lvm - -# You can define the amount of space that will be used for the LVM volume -# group. It can either be a size with its unit (eg. 20 GB), a percentage of -# free space or the 'max' keyword. -d-i partman-auto-lvm/guided_size string max - -# If one of the disks that are going to be automatically partitioned -# contains an old LVM configuration, the user will normally receive a -# warning. This can be preseeded away... -d-i partman-lvm/device_remove_lvm boolean true -# The same applies to pre-existing software RAID array: -d-i partman-md/device_remove_md boolean true -# And the same goes for the confirmation to write the lvm partitions. -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm_nooverwrite boolean true - -# You can choose one of the three predefined partitioning recipes: -# - atomic: all files in one partition -# - home: separate /home partition -# - multi: separate /home, /var, and /tmp partitions -d-i partman-auto/choose_recipe select atomic - -# Or provide a recipe of your own... -# If you have a way to get a recipe file into the d-i environment, you can -# just point at it. -#d-i partman-auto/expert_recipe_file string /hd-media/recipe - -# If not, you can put an entire recipe into the preconfiguration file in one -# (logical) line. This example creates a small /boot partition, suitable -# swap, and uses the rest of the space for the root partition: -#d-i partman-auto/expert_recipe string \ -# boot-root :: \ -# 40 50 100 ext3 \ -# $primary{ } $bootable{ } \ -# method{ format } format{ } \ -# use_filesystem{ } filesystem{ ext3 } \ -# mountpoint{ /boot } \ -# . \ -# 500 10000 1000000000 ext3 \ -# method{ format } format{ } \ -# use_filesystem{ } filesystem{ ext3 } \ -# mountpoint{ / } \ -# . \ -# 64 512 300% linux-swap \ -# method{ swap } format{ } \ -# . - -# The full recipe format is documented in the file partman-auto-recipe.txt -# included in the 'debian-installer' package or available from D-I source -# repository. This also documents how to specify settings such as file -# system labels, volume group names and which physical devices to include -# in a volume group. - -## Partitioning for EFI -# If your system needs an EFI partition you could add something like -# this to the recipe above, as the first element in the recipe: -# 538 538 1075 free \ -# $iflabel{ gpt } \ -# $reusemethod{ } \ -# method{ efi } \ -# format{ } \ -# . \ -# -# The fragment above is for the amd64 architecture; the details may be -# different on other architectures. The 'partman-auto' package in the -# D-I source repository may have an example you can follow. - -# This makes partman automatically partition without confirmation, provided -# that you told it what to do using one of the methods above. -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -# Force UEFI booting ('BIOS compatibility' will be lost). Default: false. -#d-i partman-efi/non_efi_system boolean true -# Ensure the partition table is GPT - this is required for EFI -#d-i partman-partitioning/choose_label string gpt -#d-i partman-partitioning/default_label string gpt - -# When disk encryption is enabled, skip wiping the partitions beforehand. -#d-i partman-auto-crypto/erase_disks boolean false - -## Partitioning using RAID -# The method should be set to "raid". -#d-i partman-auto/method string raid -# Specify the disks to be partitioned. They will all get the same layout, -# so this will only work if the disks are the same size. -#d-i partman-auto/disk string /dev/sda /dev/sdb - -# Next you need to specify the physical partitions that will be used. -#d-i partman-auto/expert_recipe string \ -# multiraid :: \ -# 1000 5000 4000 raid \ -# $primary{ } method{ raid } \ -# . \ -# 64 512 300% raid \ -# method{ raid } \ -# . \ -# 500 10000 1000000000 raid \ -# method{ raid } \ -# . - -# Last you need to specify how the previously defined partitions will be -# used in the RAID setup. Remember to use the correct partition numbers -# for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported; -# devices are separated using "#". -# Parameters are: -# \ -# - -#d-i partman-auto-raid/recipe string \ -# 1 2 0 ext3 / \ -# /dev/sda1#/dev/sdb1 \ -# . \ -# 1 2 0 swap - \ -# /dev/sda5#/dev/sdb5 \ -# . \ -# 0 2 0 ext3 /home \ -# /dev/sda6#/dev/sdb6 \ -# . - -# For additional information see the file partman-auto-raid-recipe.txt -# included in the 'debian-installer' package or available from D-I source -# repository. - -# This makes partman automatically partition without confirmation. -d-i partman-md/confirm boolean true -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -## Controlling how partitions are mounted -# The default is to mount by UUID, but you can also choose "traditional" to -# use traditional device names, or "label" to try filesystem labels before -# falling back to UUIDs. -#d-i partman/mount_style select uuid - -### Base system installation -# Configure APT to not install recommended packages by default. Use of this -# option can result in an incomplete system and should only be used by very -# experienced users. -#d-i base-installer/install-recommends boolean false - -# The kernel image (meta) package to be installed; "none" can be used if no -# kernel is to be installed. -#d-i base-installer/kernel/image string linux-image-686 - -### Apt setup -# You can choose to install non-free and contrib software. -#d-i apt-setup/non-free boolean true -#d-i apt-setup/contrib boolean true -# Uncomment this if you don't want to use a network mirror. -#d-i apt-setup/use_mirror boolean false -# Select which update services to use; define the mirrors to be used. -# Values shown below are the normal defaults. -#d-i apt-setup/services-select multiselect security, updates -#d-i apt-setup/security_host string security.debian.org - -# Additional repositories, local[0-9] available -#d-i apt-setup/local0/repository string \ -# http://local.server/debian stable main -#d-i apt-setup/local0/comment string local server -# Enable deb-src lines -#d-i apt-setup/local0/source boolean true -# URL to the public key of the local repository; you must provide a key or -# apt will complain about the unauthenticated repository and so the -# sources.list line will be left commented out. -#d-i apt-setup/local0/key string http://local.server/key -# If the provided key file ends in ".asc" the key file needs to be an -# ASCII-armoured PGP key, if it ends in ".gpg" it needs to use the -# "GPG key public keyring" format, the "keybox database" format is -# currently not supported. - -# By default the installer requires that repositories be authenticated -# using a known gpg key. This setting can be used to disable that -# authentication. Warning: Insecure, not recommended. -#d-i debian-installer/allow_unauthenticated boolean true - -# Uncomment this to add multiarch configuration for i386 -#d-i apt-setup/multiarch string i386 - - -### Package selection -tasksel tasksel/first multiselect standard, ssh-server - -# Individual additional packages to install -d-i pkgsel/include string sudo fuse3 -# Whether to upgrade packages after debootstrap. -# Allowed values: none, safe-upgrade, full-upgrade -#d-i pkgsel/upgrade select none - -# Some versions of the installer can report back on what software you have -# installed, and what software you use. The default is not to report back, -# but sending reports helps the project determine what software is most -# popular and should be included on the first CD/DVD. -#popularity-contest popularity-contest/participate boolean false - -### Boot loader installation -# Grub is the boot loader (for x86). - -# This is fairly safe to set, it makes grub install automatically to the UEFI -# partition/boot record if no other operating system is detected on the machine. -d-i grub-installer/only_debian boolean true - -# This one makes grub-installer install to the UEFI partition/boot record, if -# it also finds some other OS, which is less safe as it might not be able to -# boot that other OS. -d-i grub-installer/with_other_os boolean true - -# Due notably to potential USB sticks, the location of the primary drive can -# not be determined safely in general, so this needs to be specified: -#d-i grub-installer/bootdev string /dev/sda -# To install to the primary device (assuming it is not a USB stick): -#d-i grub-installer/bootdev string default - -# Alternatively, if you want to install to a location other than the UEFI -# parition/boot record, uncomment and edit these lines: -#d-i grub-installer/only_debian boolean false -#d-i grub-installer/with_other_os boolean false -#d-i grub-installer/bootdev string (hd0,1) -# To install grub to multiple disks: -#d-i grub-installer/bootdev string (hd0,1) (hd1,1) (hd2,1) - -# Optional password for grub, either in clear text -#d-i grub-installer/password password r00tme -#d-i grub-installer/password-again password r00tme -# or encrypted using an MD5 hash, see grub-md5-crypt(8). -#d-i grub-installer/password-crypted password [MD5 hash] - -# Use the following option to add additional boot parameters for the -# installed system (if supported by the bootloader installer). -# Note: options passed to the installer will be added automatically. -#d-i debian-installer/add-kernel-opts string nousb - -### Finishing up the installation -# During installations from serial console, the regular virtual consoles -# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next -# line to prevent this. -#d-i finish-install/keep-consoles boolean true - -# Avoid that last message about the install being complete. -d-i finish-install/reboot_in_progress note - -# This will prevent the installer from ejecting the CD during the reboot, -# which is useful in some situations. -#d-i cdrom-detect/eject boolean false - -# This is how to make the installer shutdown when finished, but not -# reboot into the installed system. -#d-i debian-installer/exit/halt boolean true -# This will power off the machine instead of just halting it. -#d-i debian-installer/exit/poweroff boolean true - -### Preseeding other packages -# Depending on what software you choose to install, or if things go wrong -# during the installation process, it's possible that other questions may -# be asked. You can preseed those too, of course. To get a list of every -# possible question that could be asked during an install, do an -# installation, and then run these commands: -# debconf-get-selections --installer > file -# debconf-get-selections >> file - - -#### Advanced options -### Running custom commands during the installation -# d-i preseeding is inherently not secure. Nothing in the installer checks -# for attempts at buffer overflows or other exploits of the values of a -# preconfiguration file like this one. Only use preconfiguration files from -# trusted locations! To drive that home, and because it's generally useful, -# here's a way to run any shell command you'd like inside the installer, -# automatically. - -# This first command is run as early as possible, just after -# preseeding is read. -#d-i preseed/early_command string anna-install some-udeb -# This command is run immediately before the partitioner starts. It may be -# useful to apply dynamic partitioner preseeding that depends on the state -# of the disks (which may not be visible when preseed/early_command runs). -#d-i partman/early_command \ -# string debconf-set partman-auto/disk "$(list-devices disk | head -n1)" -# This command is run just before the install finishes, but when there is -# still a usable /target directory. You can chroot to /target and use it -# directly, or use the apt-install and in-target commands to easily install -# packages and run commands in the target system. -d-i preseed/late_command string \ - echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /target/etc/sudoers.d/vagrant ; - echo export PATH=/sbin:$PATH >> ~/.bashrc diff --git a/debian-11/metadata-parallels.json b/debian-11/metadata-parallels.json deleted file mode 100644 index 036aa9d..0000000 --- a/debian-11/metadata-parallels.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "provider": "parallels" -} \ No newline at end of file diff --git a/debian-11/parallels-bullseye.pkr.hcl b/debian-11/parallels-bullseye.pkr.hcl deleted file mode 100644 index 89194e5..0000000 --- a/debian-11/parallels-bullseye.pkr.hcl +++ /dev/null @@ -1,47 +0,0 @@ -source "parallels-iso" "debian-bullseye" { - iso_url = "https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-11.3.0-arm64-netinst.iso" - iso_checksum = "md5:1fb24715f545447aff432e543436e57d" - ssh_username = "vagrant" - ssh_password = "vagrant" - ssh_timeout = "30m" - shutdown_command = "sudo shutdown -h now" - guest_os_type = "debian" - http_directory = "http" - boot_command = [ - "c", - "linux /install.a64/vmlinuz auto=true priority=critical url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg --- quiet", - "", - "initrd /install.a64/initrd.gz", - "", - "boot", - "" - ] - memory = 2048 - cpus = 2 - disk_size = 40000 - vm_name = "Debian 11" - output_directory = "output" - parallels_tools_flavor = "lin-arm" - parallels_tools_mode = "upload" - parallels_tools_guest_path = "/tmp/prltools.iso" -} - -build { - sources = ["sources.parallels-iso.debian-bullseye"] - - provisioner "shell" { - scripts = [ - "add-key.sh", - "parallels-cleanup.sh" - ] - } -} - -packer { - required_plugins { - parallels = { - version = ">= 1.0.1" - source = "github.com/hashicorp/parallels" - } - } -} \ No newline at end of file diff --git a/debian-11/parallels-cleanup.sh b/debian-11/parallels-cleanup.sh deleted file mode 100644 index 0b333f3..0000000 --- a/debian-11/parallels-cleanup.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -x - -sudo mkdir -p /media/tools -sudo mount -o loop /tmp/prltools.iso /media/tools -sudo /media/tools/install --install-unattended-with-deps -sudo umount /media/tools -sudo rm -f /tmp/prltools.iso - -sudo apt-get clean -sudo dd if=/dev/zero of=/EMPTY bs=1M -sudo rm -f /EMPTY -sync \ No newline at end of file diff --git a/debian-11/scripts/post-install.sh b/debian-11/scripts/post-install.sh new file mode 100644 index 0000000..f5aa402 --- /dev/null +++ b/debian-11/scripts/post-install.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Install apt package sources +# https://wiki.debian.org/SourcesList +sudo tee /etc/apt/sources.list > /dev/null <<'EOF' +deb http://deb.debian.org/debian bullseye main +deb-src http://deb.debian.org/debian bullseye main + +deb http://deb.debian.org/debian-security/ bullseye-security main +deb-src http://deb.debian.org/debian-security/ bullseye-security main + +deb http://deb.debian.org/debian bullseye-updates main +deb-src http://deb.debian.org/debian bullseye-updates main +EOF +# Ensure system is up to date +sudo apt-get update && sudo apt-get upgrade -y +# Download open-vm-tools +wget -O open-vm-tools.tgz https://packages.vmware.com/tools/open-vm-tools/ovt-arm-tech-preview/Debian-10/open-vm-tools-11.2.5-2debian10.tgz +tar -xf open-vm-tools.tgz +# Install open-vm-tools +sudo dpkg -i ./open-vm-tools_11.2.5-2debian10_arm64.deb && rm -f open-vm-tools* +sudo apt-get install -f -y && sudo apt-get clean +# Setup HGFS for VMware Tools Shared Folders Linux mounts +# https://kb.vmware.com/s/article/60262 +sudo mkdir -pv /mnt/hgfs/ +sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_other +# Configure vagrant SSH key based authentication +mkdir -pv /home/vagrant/.ssh +chmod 700 /home/vagrant/.ssh +wget -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub +chmod 644 /home/vagrant/.ssh/authorized_keys +# Shrink the disk +sudo dd if=/dev/zero of=/EMPTY bs=1M +sudo rm -f /EMPTY +sync +sudo vmware-toolbox-cmd disk shrink / diff --git a/debian-11/vmware-bullseye.pkr.hcl b/debian-11/vmware-bullseye.pkr.hcl deleted file mode 100644 index 4fc12c3..0000000 --- a/debian-11/vmware-bullseye.pkr.hcl +++ /dev/null @@ -1,50 +0,0 @@ -packer { - required_plugins { - vmware = { - version = ">= 1.0.5" - source = "github.com/hashicorp/vmware" - } - } -} - -source "vmware-iso" "debian-bullseye" { - iso_url = "https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-11.2.0-arm64-netinst.iso" - iso_checksum = "md5:f7be9e4eeb6de6e848ee1c75dece83be" - ssh_username = "vagrant" - ssh_password = "vagrant" - ssh_timeout = "30m" - shutdown_command = "sudo shutdown -h now" - guest_os_type = "arm-debian11-64" - disk_adapter_type = "nvme" - version = 19 - http_directory = "http" - boot_command = [ - "c", - "linux /install.a64/vmlinuz auto=true priority=critical url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg --- quiet", - "", - "initrd /install.a64/initrd.gz", - "", - "boot", - "" - ] - usb = true - vmx_data = { - "usb_xhci.present" = "true" - } - memory = 2048 - cpus = 2 - disk_size = 40000 - vm_name = "Debian 11" - output_directory = "output" -} - -build { - sources = ["sources.vmware-iso.debian-bullseye"] - - provisioner "shell" { - scripts = [ - "add-key.sh", - "vmware-cleanup.sh" - ] - } -} \ No newline at end of file diff --git a/debian-11/vmware-cleanup.sh b/debian-11/vmware-cleanup.sh deleted file mode 100644 index ef9e60a..0000000 --- a/debian-11/vmware-cleanup.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -x - -# sudo e4defrag / - -wget https://packages.vmware.com/tools/open-vm-tools/ovt-arm-tech-preview/Debian-10/open-vm-tools-11.2.5-2debian10.tgz -tar -zxf open-vm-tools-11.2.5-2debian10.tgz -sudo dpkg -i ./open-vm-tools_11.2.5-2debian10_arm64.deb -sudo apt --fix-broken install -y -sudo mkdir -p /mnt/hgfs/ -sudo /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs/ -o subtype=vmhgfs-fuse,allow_other - -sudo apt-get clean -sudo dd if=/dev/zero of=/EMPTY bs=1M -sudo rm -f /EMPTY -sync - -sudo vmware-toolbox-cmd disk shrink / \ No newline at end of file diff --git a/ubuntu-server-20.04/add-key.sh b/ubuntu-server-20.04/add-key.sh deleted file mode 100644 index 4f6f19a..0000000 --- a/ubuntu-server-20.04/add-key.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -mkdir /home/vagrant/.ssh -chmod 0700 /home/vagrant/.ssh -wget -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub -chmod 0600 /home/vagrant/.ssh/authorized_keys \ No newline at end of file diff --git a/ubuntu-server-20.04/buildbox-parallels.sh b/ubuntu-server-20.04/buildbox-parallels.sh deleted file mode 100755 index 0083d34..0000000 --- a/ubuntu-server-20.04/buildbox-parallels.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -packer init parallels-focal.pkr.hcl -packer build -force parallels-focal.pkr.hcl -cp metadata-parallels.json output/metadata.json -prl_disk_tool compact --hdd output/*.pvm/*.hdd -cd output -tar cvzf parallels-focal-arm64.box ./* -md5 parallels-focal-arm64.box -rm -rf *.pvm metadata.json \ No newline at end of file diff --git a/ubuntu-server-20.04/buildbox-vmware.sh b/ubuntu-server-20.04/buildbox-vmware.sh deleted file mode 100755 index 9c85671..0000000 --- a/ubuntu-server-20.04/buildbox-vmware.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -packer init vmware-focal.pkr.hcl -packer build -force vmware-focal.pkr.hcl -cp metadata.json output/metadata.json -cd output -tar cvzf vmware-focal-arm64.box ./* -md5 vmware-focal-arm64.box -rm -f *.v* *.nvram metadata.json \ No newline at end of file diff --git a/ubuntu-server-20.04/http/user-data b/ubuntu-server-20.04/http/user-data deleted file mode 100644 index f59c945..0000000 --- a/ubuntu-server-20.04/http/user-data +++ /dev/null @@ -1,22 +0,0 @@ -#cloud-config -autoinstall: - version: 1 - early-commands: - - sudo systemctl stop ssh - locale: en_US - keyboard: - layout: en - variant: us - identity: - hostname: ubuntu - username: vagrant - password: $6$rounds=4096$WL6Yb6B2dkPIZ$r8GqjQg6InPmTtFKoT41kXWWIfIPfHIvLhmFpIp8SFKi0c4282Tufycx787xeyt7Vq4UDoSMzWqkCLYOsXpvu0 - ssh: - install-server: true - allow-pw: true - package_update: true - package_upgrade: true - packages: - - open-vm-tools - late-commands: - - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu diff --git a/ubuntu-server-20.04/metadata-parallels.json b/ubuntu-server-20.04/metadata-parallels.json deleted file mode 100644 index 036aa9d..0000000 --- a/ubuntu-server-20.04/metadata-parallels.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "provider": "parallels" -} \ No newline at end of file diff --git a/ubuntu-server-20.04/metadata.json b/ubuntu-server-20.04/metadata.json deleted file mode 100644 index 121f0fc..0000000 --- a/ubuntu-server-20.04/metadata.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "provider": "vmware_fusion" -} \ No newline at end of file diff --git a/ubuntu-server-20.04/parallels-cleanup.sh b/ubuntu-server-20.04/parallels-cleanup.sh deleted file mode 100644 index 1dba0ff..0000000 --- a/ubuntu-server-20.04/parallels-cleanup.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -x - -sudo apt clean -sudo e4defrag / -sudo dd if=/dev/zero of=/EMPTY bs=1M -sudo rm -f /EMPTY -sync \ No newline at end of file diff --git a/ubuntu-server-20.04/parallels-focal.pkr.hcl b/ubuntu-server-20.04/parallels-focal.pkr.hcl deleted file mode 100644 index 1a16eaa..0000000 --- a/ubuntu-server-20.04/parallels-focal.pkr.hcl +++ /dev/null @@ -1,45 +0,0 @@ -source "parallels-iso" "ubuntu-focal" { - iso_url = "https://cdimage.ubuntu.com/releases/20.04/release/ubuntu-20.04.3-live-server-arm64.iso" - iso_checksum = "md5:679870a4e76a34a7438689cd7ebccf49" - ssh_username = "vagrant" - ssh_password = "vagrant" - ssh_timeout = "30m" - shutdown_command = "sudo shutdown -h now" - guest_os_type = "ubuntu" - http_directory = "http" - boot_command = [ - "c", - "linux /casper/vmlinuz \"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" --- autoinstall", - "", - "initrd /casper/initrd", - "", - "boot", - "" - ] - memory = 2048 - cpus = 2 - disk_size = 40000 - vm_name = "Ubuntu Server 20.04" - output_directory = "output" - parallels_tools_flavor = "lin" -} - -build { - sources = ["sources.parallels-iso.ubuntu-focal"] - - provisioner "shell" { - scripts = [ - "add-key.sh", - "parallels-cleanup.sh" - ] - } -} - -packer { - required_plugins { - parallels = { - version = ">= 1.0.0" - source = "github.com/hashicorp/parallels" - } - } -} \ No newline at end of file diff --git a/ubuntu-server-20.04/vmware-cleanup.sh b/ubuntu-server-20.04/vmware-cleanup.sh deleted file mode 100644 index d7b7884..0000000 --- a/ubuntu-server-20.04/vmware-cleanup.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -x - -sudo apt clean -sudo e4defrag / -sudo dd if=/dev/zero of=/EMPTY bs=1M -sudo rm -f /EMPTY -sync -sudo vmware-toolbox-cmd disk shrink / \ No newline at end of file diff --git a/ubuntu-server-20.04/vmware-focal.pkr.hcl b/ubuntu-server-20.04/vmware-focal.pkr.hcl deleted file mode 100644 index 1d8f15b..0000000 --- a/ubuntu-server-20.04/vmware-focal.pkr.hcl +++ /dev/null @@ -1,47 +0,0 @@ -packer { - required_plugins { - vmware = { - version = ">= 1.0.5" - source = "github.com/hashicorp/vmware" - } - } -} - -source "vmware-iso" "ubuntu-focal" { - iso_url = "https://cdimage.ubuntu.com/releases/20.04/release/ubuntu-20.04.3-live-server-arm64.iso" - iso_checksum = "md5:679870a4e76a34a7438689cd7ebccf49" - ssh_username = "vagrant" - ssh_password = "vagrant" - ssh_timeout = "30m" - shutdown_command = "sudo shutdown -h now" - guest_os_type = "arm-ubuntu-64" - disk_adapter_type = "nvme" - version = 19 - http_directory = "http" - boot_command = [ - "c", - "linux /casper/vmlinuz \"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" --- autoinstall", - "", - "initrd /casper/initrd", - "", - "boot", - "" - ] - usb = true - memory = 2048 - cpus = 2 - disk_size = 40000 - vm_name = "Ubuntu Server 20.04" - output_directory = "output" -} - -build { - sources = ["sources.vmware-iso.ubuntu-focal"] - - provisioner "shell" { - scripts = [ - "add-key.sh", - "vmware-cleanup.sh" - ] - } -} \ No newline at end of file diff --git a/ubuntu-server-21.10/add-key.sh b/ubuntu-server-21.10/add-key.sh deleted file mode 100644 index 4f6f19a..0000000 --- a/ubuntu-server-21.10/add-key.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -mkdir /home/vagrant/.ssh -chmod 0700 /home/vagrant/.ssh -wget -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub -chmod 0600 /home/vagrant/.ssh/authorized_keys \ No newline at end of file diff --git a/ubuntu-server-21.10/buildbox.sh b/ubuntu-server-21.10/buildbox.sh deleted file mode 100755 index 567208d..0000000 --- a/ubuntu-server-21.10/buildbox.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -packer init vmware-impish.pkr.hcl -packer build -force vmware-impish.pkr.hcl -cp metadata.json output/metadata.json -cd output -tar cvzf vmware-impish-arm64.box ./* -md5 vmware-impish-arm64.box -rm -f *.v* *.nvram metadata.json \ No newline at end of file diff --git a/ubuntu-server-21.10/http/meta-data b/ubuntu-server-21.10/http/meta-data deleted file mode 100644 index e69de29..0000000 diff --git a/ubuntu-server-21.10/http/user-data b/ubuntu-server-21.10/http/user-data deleted file mode 100644 index f59c945..0000000 --- a/ubuntu-server-21.10/http/user-data +++ /dev/null @@ -1,22 +0,0 @@ -#cloud-config -autoinstall: - version: 1 - early-commands: - - sudo systemctl stop ssh - locale: en_US - keyboard: - layout: en - variant: us - identity: - hostname: ubuntu - username: vagrant - password: $6$rounds=4096$WL6Yb6B2dkPIZ$r8GqjQg6InPmTtFKoT41kXWWIfIPfHIvLhmFpIp8SFKi0c4282Tufycx787xeyt7Vq4UDoSMzWqkCLYOsXpvu0 - ssh: - install-server: true - allow-pw: true - package_update: true - package_upgrade: true - packages: - - open-vm-tools - late-commands: - - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu diff --git a/ubuntu-server-21.10/metadata.json b/ubuntu-server-21.10/metadata.json deleted file mode 100644 index 121f0fc..0000000 --- a/ubuntu-server-21.10/metadata.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "provider": "vmware_fusion" -} \ No newline at end of file diff --git a/ubuntu-server-21.10/vmware-cleanup.sh b/ubuntu-server-21.10/vmware-cleanup.sh deleted file mode 100644 index d362b5f..0000000 --- a/ubuntu-server-21.10/vmware-cleanup.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -sudo apt clean -sudo e4defrag / -sudo dd if=/dev/zero of=/EMPTY bs=1M -sudo rm -f /EMPTY -sync -sudo vmware-toolbox-cmd disk shrink / \ No newline at end of file diff --git a/ubuntu-server-21.10/vmware-impish.pkr.hcl b/ubuntu-server-21.10/vmware-impish.pkr.hcl deleted file mode 100644 index 2420420..0000000 --- a/ubuntu-server-21.10/vmware-impish.pkr.hcl +++ /dev/null @@ -1,47 +0,0 @@ -packer { - required_plugins { - vmware = { - version = ">= 1.0.5" - source = "github.com/hashicorp/vmware" - } - } -} - -source "vmware-iso" "ubuntu-impish" { - iso_url = "https://cdimage.ubuntu.com/releases/21.10/release/ubuntu-21.10-live-server-arm64.iso" - iso_checksum = "md5:5420a741f41927ce9ddac768b69181c7" - ssh_username = "vagrant" - ssh_password = "vagrant" - ssh_timeout = "30m" - shutdown_command = "sudo shutdown -h now" - guest_os_type = "arm-ubuntu-64" - disk_adapter_type = "nvme" - version = 19 - http_directory = "http" - boot_command = [ - "c", - "linux /casper/vmlinuz \"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" --- autoinstall", - "", - "initrd /casper/initrd", - "", - "boot", - "" - ] - usb = true - memory = 2048 - cpus = 2 - disk_size = 40000 - vm_name = "Ubuntu Server 21.10" - output_directory = "output" -} - -build { - sources = ["sources.vmware-iso.ubuntu-impish"] - - provisioner "shell" { - scripts = [ - "add-key.sh", - "vmware-cleanup.sh" - ] - } -} \ No newline at end of file diff --git a/ubuntu-server-22.04/Vagrantfile b/ubuntu-server-22.04/Vagrantfile new file mode 100644 index 0000000..bb57cf2 --- /dev/null +++ b/ubuntu-server-22.04/Vagrantfile @@ -0,0 +1,11 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu-server-2204-arm64" + config.vm.provider "vmware_desktop" do |v| + v.gui = true + v.vmx["ethernet0.virtualDev"] = "e1000e" + v.vmx["usb_xhci.present"] = "true" + end +end diff --git a/ubuntu-server-22.04/add-key.sh b/ubuntu-server-22.04/add-key.sh deleted file mode 100644 index 4f6f19a..0000000 --- a/ubuntu-server-22.04/add-key.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -mkdir /home/vagrant/.ssh -chmod 0700 /home/vagrant/.ssh -wget -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub -chmod 0600 /home/vagrant/.ssh/authorized_keys \ No newline at end of file diff --git a/ubuntu-server-22.04/buildbox.sh b/ubuntu-server-22.04/buildbox.sh index e6a628c..8010ae3 100755 --- a/ubuntu-server-22.04/buildbox.sh +++ b/ubuntu-server-22.04/buildbox.sh @@ -1,11 +1,16 @@ #!/bin/bash +BOX_NAME="ubuntu-server-2204-arm64.box" -packer init vmware-jammy.pkr.hcl -packer build -force vmware-jammy.pkr.hcl - - -cp metadata.json output/metadata.json -cd output -tar cvzf vmware-jammy-arm64.box ./* -md5 vmware-jammy-arm64.box -rm -f *.v* *.nvram metadata.json \ No newline at end of file +# Initalise packer and build the VM +packer init . +packer build -force . +# Copy Vagrant metadata file to artifacts directory +cp metadata.json artifacts/metadata.json && cd artifacts +# Create Vagrant box +tar -cvzf $BOX_NAME ./* +# Show the SHA256 checksum of the box +shasum -a 256 $BOX_NAME +# Clean up +rm -f *.v* *.nvram *.log *.scoreboard *.plist metadata.json +# Add the box to Vagrant +vagrant box add --force --name "ubuntu-server-2204-arm64" $BOX_NAME diff --git a/ubuntu-server-20.04/http/meta-data b/ubuntu-server-22.04/data/meta-data similarity index 100% rename from ubuntu-server-20.04/http/meta-data rename to ubuntu-server-22.04/data/meta-data diff --git a/ubuntu-server-22.04/data/user-data.pkrtpl.hcl b/ubuntu-server-22.04/data/user-data.pkrtpl.hcl new file mode 100644 index 0000000..b134371 --- /dev/null +++ b/ubuntu-server-22.04/data/user-data.pkrtpl.hcl @@ -0,0 +1,28 @@ +#cloud-config +autoinstall: + version: 1 + early-commands: + - sudo systemctl stop ssh + locale: ${vm_guest_os_language} + keyboard: + layout: ${vm_guest_os_keyboard} + ssh: + install-server: true + allow-pw: true + packages: + - openssh-server + - open-vm-tools + - cloud-init + - wget + user-data: + disable_root: false + timezone: ${vm_guest_os_timezone} + late-commands: + - sed -i -e 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /target/etc/ssh/sshd_config + - sed -i -e 's/^UseDNS yes/UseDNS no/' /target/etc/ssh/sshd_config + - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/vagrant + - curtin in-target --target=/target -- chmod 440 /etc/sudoers.d/vagrant + identity: + hostname: ubuntu-server-2204 + password: "$1$r2NloNBC$kSbIBH09KfzNU9PXtH3.D." + username: vagrant diff --git a/ubuntu-server-22.04/http/meta-data b/ubuntu-server-22.04/http/meta-data deleted file mode 100644 index e69de29..0000000 diff --git a/ubuntu-server-22.04/http/user-data b/ubuntu-server-22.04/http/user-data deleted file mode 100644 index f59c945..0000000 --- a/ubuntu-server-22.04/http/user-data +++ /dev/null @@ -1,22 +0,0 @@ -#cloud-config -autoinstall: - version: 1 - early-commands: - - sudo systemctl stop ssh - locale: en_US - keyboard: - layout: en - variant: us - identity: - hostname: ubuntu - username: vagrant - password: $6$rounds=4096$WL6Yb6B2dkPIZ$r8GqjQg6InPmTtFKoT41kXWWIfIPfHIvLhmFpIp8SFKi0c4282Tufycx787xeyt7Vq4UDoSMzWqkCLYOsXpvu0 - ssh: - install-server: true - allow-pw: true - package_update: true - package_upgrade: true - packages: - - open-vm-tools - late-commands: - - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu diff --git a/ubuntu-server-22.04/scripts/post-install.sh b/ubuntu-server-22.04/scripts/post-install.sh new file mode 100644 index 0000000..c969efd --- /dev/null +++ b/ubuntu-server-22.04/scripts/post-install.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Configure vagrant SSH key based authentication +mkdir -pv /home/vagrant/.ssh +chmod 700 /home/vagrant/.ssh +wget -O /home/vagrant/.ssh/authorized_keys https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub +chmod 644 /home/vagrant/.ssh/authorized_keys +# Shrink the disk +sudo dd if=/dev/zero of=/EMPTY bs=1M +sudo rm -f /EMPTY +sync +sudo vmware-toolbox-cmd disk shrink / diff --git a/ubuntu-server-22.04/ubuntu2204.auto.pkr.hcl b/ubuntu-server-22.04/ubuntu2204.auto.pkr.hcl new file mode 100644 index 0000000..debf5bb --- /dev/null +++ b/ubuntu-server-22.04/ubuntu2204.auto.pkr.hcl @@ -0,0 +1,94 @@ +// ubuntu-server-22.04 packer variables file + +variable "vm_guest_os_language" { + type = string + description = "Guest OS language" + default = "en_GB" +} + +variable "vm_guest_os_keyboard" { + type = string + description = "Guest OS keyboard" + default = "gb" +} + +variable "vm_guest_os_timezone" { + type = string + description = "Guest OS timezone" + default = "Europe/London" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#disk_size +variable "disk_size" { + type = number + description = "Size of the disk in MB" + // ~40GB + default = 40000 +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#guest_os_type +variable "guest_os_type" { + type = string + description = "Guest OS type" + default = "arm-ubuntu-64" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#version +variable "vmx_hardware_version" { + type = number + description = "VMX hardware version" + default = 20 +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#vm_name +variable "vm_name" { + type = string + description = "VM name" + default = "ubuntu-server-2204" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration +variable "disk_adapter_type" { + type = string + description = "Disk adapter type" + default = "nvme" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration +variable "disk_type_id" { + type = string + description = "Disk type ID" + default = "1" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#iso-configuration +variable "iso_checksum" { + type = string + description = "ISO checksum" + default = "file:https://cdimage.ubuntu.com/releases/22.04/release/SHA256SUMS" +} + +variable "iso_url" { + type = string + default = "https://cdimage.ubuntu.com/releases/22.04/release/ubuntu-22.04.2-live-server-arm64.iso" +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#hardware-configuration +variable "cpus" { + type = number + description = "Number of CPUs" + default = 2 +} + +variable "memory" { + type = number + description = "Memory in MB" + default = 2048 +} + +// https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional-ssh-fields +variable "ssh_timeout" { + type = string + description = "SSH timeout" + default = "30m" +} diff --git a/ubuntu-server-22.04/ubuntu2204.pkr.hcl b/ubuntu-server-22.04/ubuntu2204.pkr.hcl new file mode 100644 index 0000000..928e7c1 --- /dev/null +++ b/ubuntu-server-22.04/ubuntu2204.pkr.hcl @@ -0,0 +1,92 @@ +packer { + required_version = ">= 1.8.5" + required_plugins { + vmware = { + version = ">= 1.0.7" + source = "github.com/hashicorp/vmware" + } + } +} + +locals { + data_source_content = { + "/meta-data" = file("${abspath(path.root)}/data/meta-data") + "/user-data" = templatefile("${abspath(path.root)}/data/user-data.pkrtpl.hcl", { + vm_guest_os_language = var.vm_guest_os_language + vm_guest_os_keyboard = var.vm_guest_os_keyboard + vm_guest_os_timezone = var.vm_guest_os_timezone + }) + } +} + +source "vmware-iso" "ubuntu-server-2204" { + // Optional configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional + disk_size = var.disk_size + guest_os_type = var.guest_os_type + version = var.vmx_hardware_version + vm_name = var.vm_name + + // Extra disk configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#extra-disk-configuration + disk_adapter_type = var.disk_adapter_type + disk_type_id = var.disk_type_id + + // ISO configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#iso-configuration + iso_checksum = var.iso_checksum + iso_url = var.iso_url + + // HTTP configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#http-directory-configuration + http_content = local.data_source_content + + // Shutdown configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#shutdown-configuration + shutdown_command = "sudo shutdown -h now" + + // Hardware configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#hardware-configuration + cpus = var.cpus + memory = var.memory + usb = true + + // Output configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#output-configuration + output_directory = "artifacts" + + // VMX configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#vmx-configuration + vmx_data = { + "ethernet0.virtualdev" = "e1000e" + "usb_xhci.present" = "true" + } + + // SSH configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#optional-ssh-fields + ssh_username = "vagrant" + ssh_password = "vagrant" + ssh_timeout = var.ssh_timeout + + // Boot configuration + // https://developer.hashicorp.com/packer/plugins/builders/vmware/iso#boot-configuration + boot_command = [ + "c", + "linux /casper/vmlinuz \"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" --- autoinstall", + "", + "initrd /casper/initrd", + "", + "boot", + "" + ] +} + +build { + sources = ["sources.vmware-iso.ubuntu-server-2204"] + + provisioner "shell" { + scripts = [ + "scripts/post-install.sh" + ] + } +} diff --git a/ubuntu-server-22.04/vmware-cleanup.sh b/ubuntu-server-22.04/vmware-cleanup.sh deleted file mode 100644 index d362b5f..0000000 --- a/ubuntu-server-22.04/vmware-cleanup.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -sudo apt clean -sudo e4defrag / -sudo dd if=/dev/zero of=/EMPTY bs=1M -sudo rm -f /EMPTY -sync -sudo vmware-toolbox-cmd disk shrink / \ No newline at end of file diff --git a/ubuntu-server-22.04/vmware-jammy.pkr.hcl b/ubuntu-server-22.04/vmware-jammy.pkr.hcl deleted file mode 100644 index 989e7cf..0000000 --- a/ubuntu-server-22.04/vmware-jammy.pkr.hcl +++ /dev/null @@ -1,47 +0,0 @@ -packer { - required_plugins { - vmware = { - version = ">= 1.0.5" - source = "github.com/hashicorp/vmware" - } - } -} - -source "vmware-iso" "ubuntu-jammy" { - iso_url = "https://cdimage.ubuntu.com/releases/22.04/release/ubuntu-22.04-live-server-arm64.iso" - iso_checksum = "md5:4dcafe2e69d6d0a8979cb4eb7c26c3fd" - ssh_username = "vagrant" - ssh_password = "vagrant" - ssh_timeout = "30m" - shutdown_command = "sudo shutdown -h now" - guest_os_type = "arm-ubuntu-64" - disk_adapter_type = "nvme" - version = 19 - http_directory = "http" - boot_command = [ - "c", - "linux /casper/vmlinuz \"ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/\" --- autoinstall", - "", - "initrd /casper/initrd", - "", - "boot", - "" - ] - usb = true - memory = 2048 - cpus = 2 - disk_size = 40000 - vm_name = "Ubuntu Server 22.04" - output_directory = "output" -} - -build { - sources = ["sources.vmware-iso.ubuntu-jammy"] - - provisioner "shell" { - scripts = [ - "add-key.sh", - "vmware-cleanup.sh" - ] - } -} \ No newline at end of file