packer: update boards and base images.

The base images make sure to remove snapd and fake-hwclock, as well
as using installing the rng-tools package.
This commit is contained in:
Kyle Isom 2023-04-13 20:42:03 -07:00
parent d44b20977b
commit 581b3972d1
6 changed files with 87 additions and 26 deletions

View File

@ -0,0 +1,61 @@
{
"variables": {},
"builders": [
{
"type": "arm",
"file_urls": [
"build/ubuntu-22.04.2-preinstalled-server-arm64+raspi.img.xz",
"https://cdimage.ubuntu.com/releases/22.04.2/release/ubuntu-22.04.2-preinstalled-server-arm64+raspi.img.xz"
],
"file_checksum_url": "http://cdimage.ubuntu.com/releases/22.04.2/release/SHA256SUMS",
"file_checksum_type": "sha256",
"file_target_extension": "xz",
"file_unarchive_cmd": [
"xz",
"--decompress",
"$ARCHIVE_PATH"
],
"image_build_method": "reuse",
"image_path": "build/cm4-cdev-ubuntu-22.04.2.img",
"image_size": "32G",
"image_type": "dos",
"image_partitions": [
{
"name": "boot",
"type": "c",
"start_sector": 2048,
"size": "256M",
"mountpoint": "/boot/firmware"
},
{
"name": "root",
"type": "83",
"start_sector": 526336,
"size": "31.7G",
"mountpoint": "/"
}
],
"image_chroot_env": [
"PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
],
"qemu_binary_source_path": "/usr/bin/qemu-aarch64-static",
"qemu_binary_destination_path": "/usr/bin/qemu-aarch64-static"
}
],
"provisioners": [
{
"destination": "/boot/firmware/user-data",
"source": "files/user-data",
"type": "file"
},
{
"scripts": [
"scripts/install-base.sh",
"scripts/setup-ssh.sh",
"scripts/setup-cdev.sh"
],
"type": "shell"
}
],
"post-processors": null
}

View File

@ -18,33 +18,24 @@ errmsg () {
echo "$@" > /dev/stderr echo "$@" > /dev/stderr
} }
IMAGE_TYPE="${1:-ubuntu}" IMAGE_TYPE="${1:-cnode}"
preflight () { preflight () {
case "${IMAGE_TYPE}" in case "${IMAGE_TYPE}" in
ubuntu) cdev) PACKER_BUILD_FILE="boards/cm4-cdev-ubuntu-22.04.2.json" ;;
PACKER_BUILD_FILE="boards/cm4-cluster-ubuntu-22.04.2.json" cnode) PACKER_BUILD_FILE="cm4-cluster-ubuntu-22.04.2.img" ;;
if [ "${SKIP_LOCAL_CACHE}" != "yes" ]
then
REMOTE_IMAGE_URL="$(jq '.builders[0].file_urls' ${PACKER_BUILD_FILE} | grep https | tr -d ' \",')"
fi
;;
custom) custom)
if [ -z "${PACKER_BUILD_FILE}" ] if [ -z "${PACKER_BUILD_FILE}" ]
then then
errmsg "[!] custom board requires a board file path" errmsg "[!] custom board requires a board file path"
exit 1 exit 1
fi fi
if [ "${SKIP_LOCAL_CACHE}" != "yes" ]
then
REMOTE_IMAGE_URL="$(jq '.builders[0].file_urls' ${PACKER_BUILD_FILE} | grep https | tr -d ' \",')"
fi
;; ;;
*) *)
errmsg "[!] invalid image type ${IMAGE_TYPE}." errmsg "[!] invalid image type ${IMAGE_TYPE}."
errmsg "[!] valid image types are" errmsg "[!] valid image types are"
errmsg " - ubuntu" errmsg " - cdev"
errmsg " - cnode"
errmsg " - custom path/to/board/file" errmsg " - custom path/to/board/file"
exit 1 exit 1
;; ;;
@ -58,6 +49,7 @@ cache_remote_url () {
return 0 return 0
fi fi
local REMOTE_IMAGE_URL="$(jq '.builders[0].file_urls' ${PACKER_BUILD_FILE} | grep https | tr -d ' \",')"
local CACHED_FILE="$(jq '.builders[0].file_urls' ${PACKER_BUILD_FILE} | grep -v https | grep \" | tr -d ' \",')" local CACHED_FILE="$(jq '.builders[0].file_urls' ${PACKER_BUILD_FILE} | grep -v https | grep \" | tr -d ' \",')"
if [ -z "${CACHED_FILE}" ] if [ -z "${CACHED_FILE}" ]
then then

View File

@ -1,15 +1,13 @@
#cloud-config #cloud-config
# This is the user-data configuration file for cloud-init. By default this sets # NOTE: this is a dev-environment fixture where I want a known user:pass to
# up an initial user called "ubuntu" with password "ubuntu", which must be # login on the serial console if things go sideways.
# changed at first login. However, many additional actions can be initiated on
# first boot from this file. The cloud-init documentation has more details:
#
# https://cloudinit.readthedocs.io/
chpasswd: chpasswd:
expire: false expire: false
list: list:
- ubuntu:ubuntu - name: ubuntu
password: ubuntu
type: text
hostname: rp3b-cdev hostname: rp3b-cdev
ssh_pwauth: true ssh_pwauth: true
@ -48,4 +46,11 @@ network:
ethernets: ethernets:
eth0: eth0:
dhcp4: yes dhcp4: yes
dhcp6: yes
eth1:
dhcp4: no
dhcp6: no
addresses:
"192.168.4.64/24"
label: "cluster"
lifetime: forever

View File

@ -8,5 +8,7 @@ echo 'nameserver 8.8.8.8' > /etc/resolv.conf
echo "==> installing base updates" echo "==> installing base updates"
apt-get -y update apt-get -y update
apt-get -y install ansible apt-transport-https ca-certificates wpasupplicant apt-get -y install ansible apt-transport-https ca-certificates rng-tools
apt-get -y clean apt-get -y remove fake-hwclock snapd
apt-get -y clean
apt-get -y autoremove

View File

@ -2,4 +2,4 @@
set -euxo pipefail set -euxo pipefail
sudo apt-get -y install picocom wpasupplicant apt-get -y install picocom wpasupplicant

View File

@ -10,10 +10,11 @@ boards:
- scripts/setup-ssh.sh - scripts/setup-ssh.sh
- version: 22.04.2 - version: 22.04.2
size: 32G size: 32G
name: rp4-cdev-ubuntu-22.04.2.img name: cm4-cdev-ubuntu-22.04.2.img
files: files:
- source: files/user-data - source: files/user-data
destination: /boot/firmware/user-data destination: /boot/firmware/user-data
scripts: scripts:
- scripts/install-base.sh - scripts/install-base.sh
- scripts/setup-ssh.sh - scripts/setup-ssh.sh
- scripts/setup-cdev.sh