From 6674be25725529acd520193be9ee76b29de87cae Mon Sep 17 00:00:00 2001 From: Maxime Guyot Date: Fri, 24 Apr 2020 10:30:07 +0200 Subject: [PATCH] Cleanup Vagrant VMs before molecule and vagrant CI (#6009) --- .gitlab-ci/vagrant.yml | 6 ++++++ tests/scripts/vagrant_clean.sh | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100755 tests/scripts/vagrant_clean.sh diff --git a/.gitlab-ci/vagrant.yml b/.gitlab-ci/vagrant.yml index 7d8c15b26..a6c0e002d 100644 --- a/.gitlab-ci/vagrant.yml +++ b/.gitlab-ci/vagrant.yml @@ -12,6 +12,7 @@ molecule_tests: - apt-get update && apt-get install -y python3-pip - update-alternatives --install /usr/bin/python python /usr/bin/python3 10 - python -m pip install -r tests/requirements.txt + - ./tests/scripts/vagrant_clean.sh script: - ./tests/scripts/molecule_run.sh @@ -26,6 +27,11 @@ molecule_tests: except: ['triggers'] image: quay.io/kubespray/vagrant:$KUBESPRAY_VERSION services: [] + before_script: + - apt-get update && apt-get install -y python3-pip + - update-alternatives --install /usr/bin/python python /usr/bin/python3 10 + - python -m pip install -r tests/requirements.txt + - ./tests/scripts/vagrant_clean.sh script: - vagrant up after_script: diff --git a/tests/scripts/vagrant_clean.sh b/tests/scripts/vagrant_clean.sh new file mode 100755 index 000000000..981c2d2f8 --- /dev/null +++ b/tests/scripts/vagrant_clean.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -euxo pipefail + +# Cleanup vagrant VMs to avoid name conflicts + +for i in $(virsh list --name) +do + virsh destroy "$i" + virsh undefine "$i" +done \ No newline at end of file