From a23a68d61c22383e2e79d84eb8c5a8fc42a8f91a Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Tue, 18 Jun 2024 09:13:42 +0200 Subject: [PATCH] tests: containerize vagrant commands with podman Added a function to wrap vagrant commands within a podman container Signed-off-by: Guillaume Abrioux --- tests/scripts/generate_ssh_config.sh | 3 +++ tests/scripts/vagrant.sh | 16 ++++++++++++++++ tests/scripts/vagrant_up.sh | 25 ++++++++++++++++--------- 3 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 tests/scripts/vagrant.sh diff --git a/tests/scripts/generate_ssh_config.sh b/tests/scripts/generate_ssh_config.sh index feebaf676c..6b105ab876 100644 --- a/tests/scripts/generate_ssh_config.sh +++ b/tests/scripts/generate_ssh_config.sh @@ -2,6 +2,9 @@ # Generate a custom ssh config from Vagrant so that it can then be used by # ansible.cfg +p=$(readlink -f $(dirname $0)) +source "${p}/vagrant.sh" + path=$1 if [ $# -eq 0 ] diff --git a/tests/scripts/vagrant.sh b/tests/scripts/vagrant.sh new file mode 100644 index 0000000000..615115b005 --- /dev/null +++ b/tests/scripts/vagrant.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +vagrant(){ + podman run --rm \ + -e LIBVIRT_DEFAULT_URI \ + -e SSH_AUTH_SOCK="${SSH_AUTH_SOCK}" \ + -v /var/run/libvirt/:/var/run/libvirt/ \ + -v ~/.vagrant.d:/.vagrant.d \ + -v $(realpath "${PWD}"):${PWD} \ + -w "${PWD}" \ + --network host \ + --entrypoint /bin/bash \ + --security-opt label=disable \ + docker.io/vagrantlibvirt/vagrant-libvirt:latest \ + vagrant $@ +} diff --git a/tests/scripts/vagrant_up.sh b/tests/scripts/vagrant_up.sh index 05b17582f4..9184db3854 100644 --- a/tests/scripts/vagrant_up.sh +++ b/tests/scripts/vagrant_up.sh @@ -1,5 +1,11 @@ #!/bin/bash set -x + +p=$(readlink -f $(dirname $0)) +source "${p}/vagrant.sh" + +test -d ~/.vagrant.d || mkdir ~/.vagrant.d + if [[ -n $1 ]]; then DIRECTORY=$1 shift @@ -15,14 +21,15 @@ if [[ "${CEPH_ANSIBLE_VAGRANT_BOX}" =~ "centos/stream" ]]; then vagrant box add --force --provider libvirt --name "${CEPH_ANSIBLE_VAGRANT_BOX}" "https://cloud.centos.org/centos/${EL_VERSION}-stream/x86_64/images/${LATEST_IMAGE}" --force fi -retries=0 -until [ $retries -ge 5 ] -do - echo "Attempting to start VMs. Attempts: $retries" - timeout 10m time vagrant up "$@" && break - retries=$((retries+1)) - sleep 5 -done +vagrant up "$@" +#retries=0 +#until [ $retries -ge 5 ] +#do +# echo "Attempting to start VMs. Attempts: $retries" +# timeout 10m time vagrant up "$@" && break +# retries=$((retries+1)) +# sleep 5 +#done -sleep 10 +#sleep 10 popd