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 00bb4c7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 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
18 changes: 18 additions & 0 deletions tests/scripts/vagrant.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

vagrant(){
root_dir=$(realpath "${PWD}/Vagrantfile")
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} \
-v "${root_dir}:${root_dir}" \
-w "${PWD}" \
--network host \
--entrypoint vagrant \
--security-opt label=disable \
docker.io/vagrantlibvirt/vagrant-libvirt:latest \
$@
}
25 changes: 16 additions & 9 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
#sleep 10
popd

0 comments on commit 00bb4c7

Please sign in to comment.