fix(ci): configure Ubuntu box prewarming

- Use the Molecule Ubuntu SSH settings when creating its linked-clone master
- Bound a prewarm SSH failure to ten minutes
- Verify the generated Vagrantfile in the master-preparation fixture
This commit is contained in:
Timothy Stewart
2026-08-01 08:41:43 -05:00
committed by Techno Tim
parent 4c50fbbe10
commit bbca35331d
3 changed files with 18 additions and 0 deletions
@@ -70,9 +70,19 @@ write_prewarm_vagrantfile() {
printf '%s\n' "Vagrant.configure('2') do |config|"
printf ' config.vm.box = "%s"\n' "$box"
printf ' config.vm.box_version = "%s"\n' "$version"
# generic/ubuntu2204 does not accept Vagrant's bundled insecure key.
# Match the repository's Molecule connection settings for the short-lived
# prewarm clone so Vagrant can record its linked-clone master.
if [[ "$box" == 'generic/ubuntu2204' ]]; then
printf '%s\n' \
' config.ssh.username = "vagrant"' \
' config.ssh.password = "vagrant"' \
' config.ssh.insert_key = false'
fi
printf '%s\n' \
' config.vm.synced_folder ".", "/vagrant", disabled: true' \
' config.vm.hostname = "k3s-ansible-box-prewarm"' \
' config.vm.boot_timeout = 600' \
' config.vm.provider "virtualbox" do |virtualbox|' \
' virtualbox.linked_clone = true' \
' virtualbox.memory = 512' \
@@ -5,6 +5,9 @@ set -Eeuo pipefail
printf '%s\n' "$*" >> "$MOCK_VAGRANT_LOG"
case "${1:-}" in
up)
if [[ -n "${MOCK_VAGRANTFILE_CAPTURE:-}" ]]; then
cp -- "$VAGRANT_CWD/Vagrantfile" "$MOCK_VAGRANTFILE_CAPTURE"
fi
counter_file="$MOCK_VBOX_STATE/counter"
counter=0
[[ ! -r "$counter_file" ]] || counter="$(cat "$counter_file")"
@@ -32,6 +32,7 @@ export MOCK_VBOX_ROOT="$mock_vbox_root"
export MOCK_BOX_DIR="$mock_box_dir"
export MOCK_VBOX_LOG="$fixture/vbox.log"
export MOCK_VAGRANT_LOG="$fixture/vagrant.log"
export MOCK_VAGRANTFILE_CAPTURE="$fixture/prewarm-Vagrantfile"
: > "$MOCK_VBOX_LOG"
: > "$MOCK_VAGRANT_LOG"
@@ -44,6 +45,10 @@ second_output="$fixture/second-output"
third_output="$fixture/third-output"
"$script" > "$first_output"
grep -Fq 'config.ssh.username = "vagrant"' "$MOCK_VAGRANTFILE_CAPTURE"
grep -Fq 'config.ssh.password = "vagrant"' "$MOCK_VAGRANTFILE_CAPTURE"
grep -Fq 'config.ssh.insert_key = false' "$MOCK_VAGRANTFILE_CAPTURE"
grep -Fq 'config.vm.boot_timeout = 600' "$MOCK_VAGRANTFILE_CAPTURE"
mapping_file="$mock_master_root/generic_ubuntu2204-4.3.12-amd64.uuid"
test -s "$mapping_file"
cmp -s "$mapping_file" "$mock_box_dir/master_id"