TL;DR: Using the latest version of https://github.com/vyos/vyos-vm-images.git, the task setup-root-partition fails when running inside a Docker container.
A PR (#36) was already submitted. It has fixed the problem for me.
Long version:
Each I run ansible-playbook inside the docker container it gives a slightly different error:
1st run:
TASK [setup-root-partition : Create a fileystem on EFI partition] *********************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "msg": "Device p2 not found."}
2nd run:
TASK [mount-root-fs : Mount squashfs image from root partition] ************************************************************************************************************************************************* fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error mounting /mnt/squashfs: mount: /mnt/squashfs: failed to setup loop device for /mnt/wroot/boot/2024.01.12.1618/2024.01.12.1618.squashfs.\n"}
3rd run:
TASK [setup-root-partition : Create a fileystem on EFI partition] *********************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "msg": "Device /dev/loop8\n/dev/loop9p2 not found."}
4th run:
TASK [setup-root-partition : Create a fileystem on EFI partition] *********************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "msg": "Device /dev/loop8\n/dev/loop9\n/dev/loop10p2 not found."}
5th run:
TASK [setup-root-partition : Create a fileystem on EFI partition] *********************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": false, "msg": "Device /dev/loop8\n/dev/loop11\n/dev/loop9\n/dev/loop10p2 not found."}
etc.
To reproduce:
# Source: https://docs.vyos.io/en/latest/contributing/build-vyos.html#build-iso VYOS_BRANCH=sagitta [email protected] DOCKER_BUILD_IMAGE=vyos/vyos-build:$VYOS_BRANCH VYOS_ROOT=/tmp/vyos-build/$VYOS_BRANCH git clone -b $VYOS_BRANCH --single-branch https://github.com/vyos/vyos-build $VYOS_ROOT VYOS_VERSION=1.4.666 docker pull $DOCKER_BUILD_IMAGE # For VyOS 1.4 (sagitta) For VyOS 1.5 (circinus,current) docker run --rm -it --privileged -v $VYOS_ROOT:/vyos -w /vyos $DOCKER_BUILD_IMAGE bash -c "sudo make clean ; sudo ./build-vyos-image iso --architecture amd64 --build-by $BUILD_BY --build-type release --version $VYOS_VERSION" OUTPUT_ISO="$VYOS_ROOT/build/vyos-$VYOS_VERSION-amd64.iso" # Build VyOS Hyper-V cloud image # Source: https://github.com/vyos/vyos-vm-images#prepare # Copy ISO to /tmp cp $OUTPUT_ISO /tmp/vyos.iso VYOS_VM_ROOT=/tmp/vyos-vm-images # Original repo: Failing when building inside docker. git clone --single-branch https://github.com/vyos/vyos-vm-images.git $VYOS_VM_ROOT # Build local docker image cd $VYOS_VM_ROOT docker build --tag vyos-vm-images:latest -f ./Dockerfile . # [FAIL!]: Build Hyper-V image with cloud-init OUTPUT_IMAGE_NAME=vyos-$VYOS_VERSION-hyperv.vhdx docker run --rm -it --privileged -v $VYOS_VM_ROOT:/vm-build -v $VYOS_VM_ROOT/images:/images -v /tmp:/source -w /vm-build vyos-vm-images:latest bash -c "ansible-playbook hyperv.yml -e iso_local=/source/vyos.iso -e vyos_version=$VYOS_VERSION -e vyos_hyperv_img=/source/$OUTPUT_IMAGE_NAME -e disk_size=20 -e cloud_init=true -e cloud_init_ds=NoCloud,ConfigDrive,None -e grub_console=KVM -e keep_user=true"
Now, using a version of vyos-vm-images with PR #36 applied, it works:
(...) # Copy ISO to /tmp cp $OUTPUT_ISO /tmp/vyos.iso VYOS_VM_ROOT=/tmp/vyos-vm-images # Fixed repo. PR #36 applied. git clone --single-branch https://github.com/fdcastel/vyos-vm-images $VYOS_VM_ROOT # Build local docker image cd $VYOS_VM_ROOT docker build --tag vyos-vm-images:latest -f ./Dockerfile . # [WORKS!]: Build Hyper-V image with cloud-init OUTPUT_IMAGE_NAME=vyos-$VYOS_VERSION-hyperv.vhdx docker run --rm -it --privileged -v $VYOS_VM_ROOT:/vm-build -v $VYOS_VM_ROOT/images:/images -v /tmp:/source -w /vm-build vyos-vm-images:latest bash -c "ansible-playbook hyperv.yml -e iso_local=/source/vyos.iso -e vyos_version=$VYOS_VERSION -e vyos_hyperv_img=/source/$OUTPUT_IMAGE_NAME -e disk_size=20 -e cloud_init=true -e cloud_init_ds=NoCloud,ConfigDrive,None -e grub_console=KVM -e keep_user=true"