Skip to content

Commit

Permalink
clean installation artifacts
Browse files Browse the repository at this point in the history
clean machine-id and remove cloud-init state

fixes #189
  • Loading branch information
alexsander-souza committed Jan 3, 2024
1 parent cb16c6a commit f8d6b3d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 0 additions & 4 deletions debian/scripts/networking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
rm -f /etc/cloud/cloud.cfg.d/99-installer.cfg
rm -f /etc/cloud/ds-identify.cfg

rm -f /var/log/cloud-init*.log
rm -rf /var/lib/cloud/instances \
/var/lib/cloud/instance

# Install a dpkg-query wrapper to bypass MAAS netplan.io check
cat > /usr/local/bin/dpkg-query <<EOF
#!/bin/sh
Expand Down
16 changes: 15 additions & 1 deletion scripts/fuse-tar-root
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ BOOT_MOUNT=${TMP_DIR}/boot
echo 'Mounting root partition...'
mount_part "${ROOT_PARTITION}" "${ROOT_MOUNT}"

if [ -f "$ROOT_MOUNT/etc/machine-id" ]; then
echo 'reseting machine-id...'
: >| "$ROOT_MOUNT/etc/machine-id"
fi

if [ -f "$ROOT_MOUNT/var/lib/cloud/instance" ]; then
echo 'cleaning cloud-init state...'
rm -f "$ROOT_MOUNT/var/log/cloud-init*.log" \
"$ROOT_MOUNT/var/lib/cloud/instance"
rm -rf "$ROOT_MOUNT/var/lib/cloud/instances"
fi

if [ -d curtin ] || [ -d "$CURTIN_HOOKS" ]; then
echo 'Adding Curtin hooks...'
Expand All @@ -35,7 +46,10 @@ fi

echo "Creating MAAS image ${OUTPUT}..."
TARFILE=${OUTPUT%*.gz}
tar -Scpf "${TARFILE}" --acls --selinux --xattrs -C "$ROOT_MOUNT" .
tar -Scpf "${TARFILE}" --acls --selinux --xattrs \
--one-file-system \
--exclude-backups \
-C "$ROOT_MOUNT" .

if [ "${DETECT_BLS_BOOT}" -eq 1 ]; then
echo "auto-detecting 'bls_boot' partition"
Expand Down
4 changes: 0 additions & 4 deletions ubuntu/scripts/cloudimg/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
# cloud-init put networking in place on initial boot. Let's remove that, to
# allow MAAS to configure the networking on deploy.
rm /etc/netplan/50-cloud-init.yaml
: >| /etc/machine-id
rm -f /var/log/cloud-init*.log
rm -rf /var/lib/cloud/instances \
/var/lib/cloud/instance

# Everything in /run/packer_backup should be restored.
find /run/packer_backup
Expand Down
5 changes: 0 additions & 5 deletions ubuntu/scripts/networking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,3 @@ rm -f /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg
rm -f /etc/cloud/cloud.cfg.d/99-installer.cfg
rm -f /etc/cloud/ds-identify.cfg
rm -f /etc/netplan/00-installer-config.yaml
: >| /etc/machine-id

rm -f /var/log/cloud-init*.log
rm -rf /var/lib/cloud/instances \
/var/lib/cloud/instance

0 comments on commit f8d6b3d

Please sign in to comment.