Skip to content

Commit

Permalink
tests: containerize vagrant commands with podman
Browse files Browse the repository at this point in the history
Added a function to wrap vagrant commands within a podman container

Signed-off-by: Guillaume Abrioux <[email protected]>
  • Loading branch information
guits committed Jun 19, 2024
1 parent 4dc7d96 commit 3e87f3c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
3 changes: 3 additions & 0 deletions tests/scripts/generate_ssh_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down
16 changes: 16 additions & 0 deletions tests/scripts/vagrant.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

vagrant(){
podman run -it --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 $@
}
23 changes: 15 additions & 8 deletions tests/scripts/vagrant_up.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
popd

0 comments on commit 3e87f3c

Please sign in to comment.