From 0432fd52fdd7c191955adfa8561a9eb994b9301f 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 | 2 ++ tests/scripts/vagrant_up.sh | 5 +++++ vagrant.sh | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 vagrant.sh diff --git a/tests/scripts/generate_ssh_config.sh b/tests/scripts/generate_ssh_config.sh index feebaf676c..a98c1f181e 100644 --- a/tests/scripts/generate_ssh_config.sh +++ b/tests/scripts/generate_ssh_config.sh @@ -2,6 +2,8 @@ # Generate a custom ssh config from Vagrant so that it can then be used by # ansible.cfg +source vagrant.sh + path=$1 if [ $# -eq 0 ] diff --git a/tests/scripts/vagrant_up.sh b/tests/scripts/vagrant_up.sh index 05b17582f4..609f296c17 100644 --- a/tests/scripts/vagrant_up.sh +++ b/tests/scripts/vagrant_up.sh @@ -1,5 +1,10 @@ #!/bin/bash set -x + +source vagrant.sh + +test -d ~/.vagrant.d && mkdir ~/.vagrant.d + if [[ -n $1 ]]; then DIRECTORY=$1 shift diff --git a/vagrant.sh b/vagrant.sh new file mode 100644 index 0000000000..492c19176d --- /dev/null +++ b/vagrant.sh @@ -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 $@ +}