Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: install local cloud-init packages in ubuntu packer
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
  • Loading branch information
awesomenix and Copilot committed Mar 11, 2026
commit ed3d302ce55c601816671f72b45514795217c6df
Binary file not shown.
Binary file not shown.
Binary file not shown.
29 changes: 28 additions & 1 deletion vhdbuilder/packer/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@ echo ""
echo "Components downloaded in this VHD build (some of the below components might get deleted during cluster provisioning if they are not needed):" >> ${VHD_LOGS_FILEPATH}
capture_benchmark "${SCRIPT_NAME}_source_packer_files_and_declare_variables"

installLocalCloudInitPackages() {
local package_dir="/home/packer/cloud-init-packages"
local cloud_init_base_pkg
local cloud_init_azure_pkg
local cloud_init_pkg

if [ "$OS" != "$UBUNTU_OS_NAME" ] || [ ! -d "$package_dir" ]; then
return 0
fi

cloud_init_base_pkg=$(find "$package_dir" -maxdepth 1 -type f -name 'cloud-init-base*.deb' | sort -V | tail -n 1)
cloud_init_azure_pkg=$(find "$package_dir" -maxdepth 1 -type f -name 'cloud-init-azure*.deb' | sort -V | tail -n 1)
cloud_init_pkg=$(find "$package_dir" -maxdepth 1 -type f -name 'cloud-init_*.deb' | sort -V | tail -n 1)

if [ -z "$cloud_init_base_pkg" ] || [ -z "$cloud_init_azure_pkg" ] || [ -z "$cloud_init_pkg" ]; then
echo "Missing one or more cloud-init packages in $package_dir"
return 1
fi

echo "Installing cloud-init packages from $package_dir"
wait_for_apt_locks
dpkg -i "$cloud_init_base_pkg" "$cloud_init_azure_pkg" "$cloud_init_pkg"
}

echo "Logging the kernel after purge and reinstall + reboot: $(uname -r)"
# fix grub issue with cvm by reinstalling before other deps
# other VHDs use grub-pc, not grub-efi
Expand Down Expand Up @@ -86,9 +110,12 @@ else
journalctl --no-pager -u $apt_package
exit $ERR_APT_INSTALL_TIMEOUT
fi
done
done
fi

installLocalCloudInitPackages || exit 1
capture_benchmark "${SCRIPT_NAME}_install_local_cloud_init_packages"

CHRONYD_DIR=/etc/systemd/system/chronyd.service.d

mkdir -p "${CHRONYD_DIR}"
Expand Down
16 changes: 16 additions & 0 deletions vhdbuilder/packer/vhd-image-builder-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
{
"type": "shell",
"inline": [
"mkdir -p /home/packer/cloud-init-packages",
"sudo mkdir -p /opt/azure/containers",
"sudo mkdir -p /opt/scripts",
"sudo mkdir -p /opt/certs"
Expand Down Expand Up @@ -116,6 +117,21 @@
"source": "parts/linux/cloud-init/artifacts/cloud-init-status-check.sh",
"destination": "/home/packer/cloud-init-status-check.sh"
},
{
"type": "file",
"source": "vhdbuilder/packer/cloud-init-packages/cloud-init-base_all.deb",
"destination": "/home/packer/cloud-init-packages/cloud-init-base_all.deb"
},
{
"type": "file",
"source": "vhdbuilder/packer/cloud-init-packages/cloud-init-azure_all.deb",
"destination": "/home/packer/cloud-init-packages/cloud-init-azure_all.deb"
},
{
"type": "file",
"source": "vhdbuilder/packer/cloud-init-packages/cloud-init_all.deb",
"destination": "/home/packer/cloud-init-packages/cloud-init_all.deb"
},
{
"type": "file",
Comment on lines +122 to 136
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds prebuilt cloud-init .deb artifacts into the repo and bakes them into the VHD. This creates a hard-to-audit dependency surface (no explicit version metadata/checksums, no provenance, and manual updates), and it increases repo/VHD build maintenance burden. Prefer downloading versioned packages during the VHD build from an approved source (and tracking the version via components.json/renovate where applicable), or at least include explicit versioning + integrity verification for these artifacts.

Suggested change
"source": "vhdbuilder/packer/cloud-init-packages/cloud-init-base_all.deb",
"destination": "/home/packer/cloud-init-packages/cloud-init-base_all.deb"
},
{
"type": "file",
"source": "vhdbuilder/packer/cloud-init-packages/cloud-init-azure_all.deb",
"destination": "/home/packer/cloud-init-packages/cloud-init-azure_all.deb"
},
{
"type": "file",
"source": "vhdbuilder/packer/cloud-init-packages/cloud-init_all.deb",
"destination": "/home/packer/cloud-init-packages/cloud-init_all.deb"
},
{
"type": "file",

Copilot uses AI. Check for mistakes.
"source": "vhdbuilder/packer/prefetch.sh",
Expand Down
Loading