aboutsummaryrefslogtreecommitdiff
path: root/tests/deploy-tenks.sh
diff options
context:
space:
mode:
authorMark Goddard <mark@stackhpc.com>2018-05-16 13:36:38 +0100
committerRadosław Piliszek <radoslaw.piliszek@gmail.com>2022-03-05 20:03:36 +0000
commit91778aca76cc5df534de0a95d84363c834c2657a (patch)
tree664cd4b4ce15f7317774b9115f6588919c11f70c /tests/deploy-tenks.sh
parent68bc4f8f52f3e086efb1e72fd6ccdd36e8d0139a (diff)
downloadkolla-ansible-91778aca76cc5df534de0a95d84363c834c2657a.tar.gz
kolla-ansible-91778aca76cc5df534de0a95d84363c834c2657a.zip
[CI] Use Tenks in Ironic job
Installs Tenks [1] and uses it to create virtual machines to pose as bare metal compute nodes. The nodes are registered in Ironic, and used to provision instances. [1] https://docs.openstack.org/tenks/latest/ Depends-On: https://review.opendev.org/c/openstack/tenks/+/830182 Depends-On: https://review.opendev.org/c/openstack/tenks/+/830675 Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/831055 Change-Id: Idfb8fbb50dc7442225967b2a2ec38ae7114f3c11 Co-Authored-By: Radosław Piliszek <radoslaw.piliszek@gmail.com>
Diffstat (limited to 'tests/deploy-tenks.sh')
-rwxr-xr-xtests/deploy-tenks.sh70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/deploy-tenks.sh b/tests/deploy-tenks.sh
new file mode 100755
index 000000000..b212d38eb
--- /dev/null
+++ b/tests/deploy-tenks.sh
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+set -o xtrace
+set -o errexit
+set -o pipefail
+
+# Enable unbuffered output for Ansible in Jenkins.
+export PYTHONUNBUFFERED=1
+
+function deploy_tenks_logged {
+ . /etc/kolla/admin-openrc.sh
+
+ echo "Creating IPA images for Ironic"
+ ~/openstackclient-venv/bin/openstack image create --disk-format aki --container-format aki --private \
+ --file /etc/kolla/config/ironic/ironic-agent.kernel ipa.vmlinuz
+ ~/openstackclient-venv/bin/openstack image create --disk-format ari --container-format ari --private \
+ --file /etc/kolla/config/ironic/ironic-agent.initramfs ipa.initramfs
+
+ # Install a trivial script for ovs-vsctl that talks to containerised Open
+ # vSwitch.
+ sudo tee /usr/bin/ovs-vsctl >/dev/null <<EOF
+#!/usr/bin/env bash
+
+# Script installed onto the host to fool tenks into using the containerised
+# Open vSwitch rather than installing its own.
+
+sudo docker exec openvswitch_vswitchd ovs-vsctl "\$@"
+EOF
+ sudo chmod 755 /usr/bin/ovs-vsctl
+
+ # Install the Tenks venv.
+ python3 -m venv ${TENKS_VENV_PATH}
+ ${TENKS_VENV_PATH}/bin/pip install -U pip
+ ${TENKS_VENV_PATH}/bin/pip install ${TENKS_SRC_PATH}
+
+ local attempt
+ attempt=1
+ while ! ${TENKS_VENV_PATH}/bin/ansible-galaxy install \
+ --role-file="${TENKS_SRC_PATH}/requirements.yml" \
+ --roles-path="${TENKS_SRC_PATH}/ansible/roles/"; do
+ echo "ansible-galaxy install failed, attempt $attempt"
+ attempt=$((attempt+1))
+ if [[ $attempt -eq 10 ]]; then
+ echo "enough retrying, farewell"
+ return 1
+ fi
+ sleep 10
+ done
+
+ # Run Tenks.
+ ${TENKS_VENV_PATH}/bin/ansible-playbook \
+ -vvv \
+ --inventory "${TENKS_SRC_PATH}/ansible/inventory" \
+ --extra-vars=@"$HOME/tenks.yml" \
+ "${TENKS_SRC_PATH}/ansible/deploy.yml"
+}
+
+function deploy_tenks {
+ echo "Configuring virtual bare metal via Tenks"
+ deploy_tenks_logged > /tmp/logs/ansible/deploy-tenks 2>&1
+ result=$?
+ if [[ $result != 0 ]]; then
+ echo "Deploying tenks failed. See ansible/deploy-tenks for details"
+ else
+ echo "Successfully deployed tenks. See ansible/deploy-tenks for details"
+ fi
+ return $result
+}
+
+deploy_tenks