From 65c9d4dadac1bf9c17386b4238c3cf3d82a32eee Mon Sep 17 00:00:00 2001 From: Alex-Welsh Date: Wed, 24 May 2023 12:34:15 +0100 Subject: [PATCH] Add automated AIO setup script --- .../contributor/environments/ci-aio.rst | 48 +++++++++++-- .../environments/ci-aio/automated-setup.sh | 72 +++++++++++++++++++ .../notes/aio-script-8221b9dcbcc40c55.yaml | 5 ++ 3 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 etc/kayobe/environments/ci-aio/automated-setup.sh create mode 100644 releasenotes/notes/aio-script-8221b9dcbcc40c55.yaml diff --git a/doc/source/contributor/environments/ci-aio.rst b/doc/source/contributor/environments/ci-aio.rst index de1d2d8fb..71aa300e0 100644 --- a/doc/source/contributor/environments/ci-aio.rst +++ b/doc/source/contributor/environments/ci-aio.rst @@ -5,14 +5,52 @@ ci-aio This environment deploys an all-in-one converged control/compute cloud for testing. +There are two ways to set up the environment. The automated setup script +automates the manual setup steps below, and is recommended for most users. +The manual setup steps are provided for reference, and for users who wish to +make changes to the setup process. + Prerequisites ============= * a CentOS Stream 8 or Ubuntu Focal 20.04 host * access to the Test Pulp server on SMS lab -Setup -===== +Automated Setup +=============== + +Access the host via SSH. + +Download the setup script: + +.. parsed-literal:: + + wget https://raw.githubusercontent.com/stackhpc/stackhpc-kayobe-config/stackhpc/yoga/etc/kayobe/environments/ci-aio/automated-setup.sh + +Change the permissions on the script: + +.. parsed-literal:: + + sudo chmod 700 automated-setup.sh + +Acquire the Ansible Vault password for this repository, and store a +copy at ``~/vault-pw``. + +Run the setup script: + +.. parsed-literal:: + + ./automated-setup.sh + +The script will pull the current version of Kayobe and this repository, and +then run the manual setup steps below. The script can be easily edited to use +a different branch of Kayobe or this repository. + +Manual Setup +============ + +Host Configuration +------------------ Access the host via SSH. @@ -67,7 +105,7 @@ Add initial network configuration: sudo ip l set dummy1 master breth1 Installation -============ +------------ Acquire the Ansible Vault password for this repository, and store a copy at ``~/vault-pw``. @@ -86,7 +124,7 @@ Ansible control host. kayobe control host bootstrap Deployment -========== +---------- Next, configure the host OS & services. @@ -103,7 +141,7 @@ Finally, deploy the overcloud services. The control plane should now be running. Testing -======= +------- Run a smoke test: diff --git a/etc/kayobe/environments/ci-aio/automated-setup.sh b/etc/kayobe/environments/ci-aio/automated-setup.sh new file mode 100644 index 000000000..6ee2515da --- /dev/null +++ b/etc/kayobe/environments/ci-aio/automated-setup.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +set -eux + +cat << EOF | sudo tee -a /etc/hosts +10.205.3.187 pulp-server pulp-server.internal.sms-cloud +EOF + +BASE_PATH=~ +KAYOBE_BRANCH=stackhpc/yoga +KAYOBE_CONFIG_BRANCH=stackhpc/yoga + +if [[ ! -f $BASE_PATH/vault-pw ]]; then + echo "Vault password file not found at $BASE_PATH/vault-pw" + exit 1 +fi + +if type dnf; then + sudo dnf -y install git python3-virtualenv +else + sudo apt update + sudo apt -y install gcc git libffi-dev python3-dev python-is-python3 python3-virtualenv +fi + +cd $BASE_PATH +mkdir -p src +pushd src +[[ -d kayobe ]] || git clone https://github.com/stackhpc/kayobe.git -b $KAYOBE_BRANCH +[[ -d kayobe-config ]] || git clone https://github.com/stackhpc/stackhpc-kayobe-config kayobe-config -b $KAYOBE_CONFIG_BRANCH +popd + +mkdir -p venvs +pushd venvs +if [[ ! -d kayobe ]]; then + virtualenv kayobe +fi +# NOTE: Virtualenv's activate and deactivate scripts reference an +# unbound variable. +set +u +source kayobe/bin/activate +set -u +pip install -U pip +pip install ../src/kayobe +popd + +if ! ip l show breth1 >/dev/null 2>&1; then + sudo ip l add breth1 type bridge +fi +sudo ip l set breth1 up +if ! ip a show breth1 | grep 192.168.33.3/24; then + sudo ip a add 192.168.33.3/24 dev breth1 +fi +if ! ip l show dummy1 >/dev/null 2>&1; then + sudo ip l add dummy1 type dummy +fi +sudo ip l set dummy1 up +sudo ip l set dummy1 master breth1 + +export KAYOBE_VAULT_PASSWORD=$(cat $BASE_PATH/vault-pw) +pushd $BASE_PATH/src/kayobe-config +source kayobe-env --environment ci-aio + +kayobe control host bootstrap + +kayobe overcloud host configure + +kayobe overcloud service deploy + +export KAYOBE_CONFIG_SOURCE_PATH=$BASE_PATH/src/kayobe-config +export KAYOBE_VENV_PATH=$BASE_PATH/venvs/kayobe +pushd $BASE_PATH/src/kayobe +./dev/overcloud-test-vm.sh diff --git a/releasenotes/notes/aio-script-8221b9dcbcc40c55.yaml b/releasenotes/notes/aio-script-8221b9dcbcc40c55.yaml new file mode 100644 index 000000000..b3148b6f3 --- /dev/null +++ b/releasenotes/notes/aio-script-8221b9dcbcc40c55.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added a script to the AIO environment that can be used to quickly + deploy an AIO for testing.