From a8e7238c9f9dbf3abb76cfcc8e6276b95156d403 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Fri, 20 Sep 2024 14:31:47 +0200 Subject: [PATCH] CI: make the ansible inventory a directory Not constraining the inventory to .ini allows us to use dynamic inventory, which is needed for simplifying kubevirt jobs inventory. Also reduces the scope of the ANSIBLE_INVENTORY variable. --- .gitlab-ci.yml | 1 - tests/Makefile | 7 ++----- tests/scripts/testcases_cleanup.sh | 2 +- tests/scripts/testcases_run.sh | 3 ++- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5bd8c1b22..c1cd83bb5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,6 @@ variables: GCE_PREEMPTIBLE: "false" ANSIBLE_KEEP_REMOTE_FILES: "1" ANSIBLE_CONFIG: ./tests/ansible.cfg - ANSIBLE_INVENTORY: ./inventory/sample/${CI_JOB_NAME}-${BUILD_NUMBER}.ini IDEMPOT_CHECK: "false" RESET_CHECK: "false" REMOVE_NODE_CHECK: "false" diff --git a/tests/Makefile b/tests/Makefile index 18e87a2dd..50256b197 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,3 @@ -INVENTORY=$(PWD)/../inventory/sample/${CI_JOB_NAME}-${BUILD_NUMBER}.ini - init-packet: mkdir -p $(HOME)/.ssh echo $(PACKET_VM_SSH_PRIVATE_KEY) | base64 -d > $(HOME)/.ssh/id_rsa @@ -18,14 +16,13 @@ create-packet: init-packet -e test_id=$(TEST_ID) \ -e branch="$(CI_COMMIT_BRANCH)" \ -e pipeline_id="$(CI_PIPELINE_ID)" \ - -e inventory_path=$(INVENTORY) + -e inventory_path=$(INVENTORY_DIR) delete-packet: ; create-vagrant: vagrant up - cp $(CI_PROJECT_DIR)/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory $(INVENTORY) - + cp $(CI_PROJECT_DIR)/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory $(INVENTORY_DIR) delete-vagrant: vagrant destroy -f diff --git a/tests/scripts/testcases_cleanup.sh b/tests/scripts/testcases_cleanup.sh index 71b7fdc5b..199784490 100755 --- a/tests/scripts/testcases_cleanup.sh +++ b/tests/scripts/testcases_cleanup.sh @@ -1,7 +1,7 @@ #!/bin/bash set -euxo pipefail -cd tests && make delete-${CI_PLATFORM} -s ; cd - +make -C tests delete-${CI_PLATFORM} -s if [ -d ~/.ara ] ; then tar czvf ${CI_PROJECT_DIR}/cluster-dump/ara.tgz ~/.ara diff --git a/tests/scripts/testcases_run.sh b/tests/scripts/testcases_run.sh index db689b8c0..6235d2ed3 100755 --- a/tests/scripts/testcases_run.sh +++ b/tests/scripts/testcases_run.sh @@ -31,8 +31,9 @@ export ANSIBLE_REMOTE_USER=$SSH_USER export ANSIBLE_BECOME=true export ANSIBLE_BECOME_USER=root export ANSIBLE_CALLBACK_PLUGINS="$(python -m ara.setup.callback_plugins)" +export ANSIBLE_INVENTORY=${CI_PROJECT_DIR}/inventory/sample/ -cd tests && make create-${CI_PLATFORM} -s ; cd - +make -C tests INVENTORY_DIR=${ANSIBLE_INVENTORY} create-${CI_PLATFORM} -s ansible-playbook tests/cloud_playbooks/wait-for-ssh.yml # Flatcar Container Linux needs auto update disabled