diff --git a/.gitignore b/.gitignore index f4ae247..d36d6d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vault-token.txt controller_cert.crt license.txt +root_ca.cert diff --git a/devstack.sh b/devstack.sh new file mode 100755 index 0000000..d599efd --- /dev/null +++ b/devstack.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +lxc="lxc" +lxc_exec="lxc exec" +inst_name="jammy-devstack" + +${lxc} delete ${inst_name} --force +${lxc} launch ubuntu:jammy ${inst_name} --vm -c limits.cpu=4 -c limits.memory=8GiB + +echo -n "Checking VM status of ${inst_name} " + +while true ; do + num_of_procs=$(${lxc} info ${inst_name} | yq .Resources.Processes) + [[ ${num_of_procs} -gt 0 ]] && break + sleep 3 + echo -n "." +done + +echo done + + +echo -n "Checking cloud-init status of ${inst_name}" + +while true ; do + status=$(${lxc_exec} ${inst_name} -- cloud-init status | grep status | awk '{print $2}') + [[ "${status}" == "done" ]] && break + [[ "${status}" == "error" ]] && break + sleep 3 + echo -n "." +done + +echo done + +${lxc_exec} ${inst_name} -- sudo apt -y remove python3-httplib2 python3-pyasn1 python3-pyasn1-modules + +cat > initialise.sh << EOF +cd /home/ubuntu +git clone -b stable/2024.2 https://opendev.org/openstack/devstack +cp local.conf devstack +cd devstack +./stack.sh +EOF + +IP_ADDR=$(${lxc} info ${inst_name} | yq '.Resources.["Network usage"].enp5s0.["IP addresses"].inet' | awk -F'/' '{print $1}') + +cat > local.conf << EOF +[[local|localrc]] +ADMIN_PASSWORD=somesecretpassword +DATABASE_PASSWORD=\$ADMIN_PASSWORD +RABBIT_PASSWORD=\$ADMIN_PASSWORD +SERVICE_PASSWORD=\$ADMIN_PASSWORD +HOST_IP=${IP_ADDR} +EOF + +${lxc} file push initialise.sh ${inst_name}/home/ubuntu/ +${lxc} file push local.conf ${inst_name}/home/ubuntu/ + +${lxc_exec} ${inst_name} -- chmod +x /home/ubuntu/initialise.sh +${lxc_exec} ${inst_name} -- sudo -u ubuntu /home/ubuntu/initialise.sh diff --git a/get_vault_ca.sh b/get_vault_ca.sh new file mode 100755 index 0000000..7359e0f --- /dev/null +++ b/get_vault_ca.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +. functions.sh +check_juju_version + +${juju_run_action} vault/leader get-root-ca --format json | jq -rc ".[].results.output" > root_ca.cert diff --git a/restart_juju_controllers.sh b/restart_juju_controllers.sh new file mode 100755 index 0000000..a1dfe6b --- /dev/null +++ b/restart_juju_controllers.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +controller="home-maas" + +for i in $(seq 0 2) +do + ./restart_juju_nojuju.sh $i ${controller} +done diff --git a/sunbeam.sh b/sunbeam.sh new file mode 100755 index 0000000..ecc5cdd --- /dev/null +++ b/sunbeam.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +lxc="lxc" +lxc_exec="lxc exec" +series="noble" +image="ubuntu:${series}" +inst_name="${series}-sunbeam" + +SUNBEAM_VERSION="2024.1/stable" + +${lxc} delete ${inst_name} --force +${lxc} launch ${image} ${inst_name} --vm -c limits.cpu=6 -c limits.memory=16GiB -d root,size=80GiB -s virtual + +echo -n "Checking VM status of ${inst_name} " + +while true ; do + num_of_procs=$(${lxc} info ${inst_name} | yq .Resources.Processes) + [[ ${num_of_procs} -gt 0 ]] && break + sleep 3 + echo -n "." +done + +echo done + +echo -n "Checking cloud-init status of ${inst_name} " + +while true ; do + status=$(${lxc_exec} ${inst_name} -- cloud-init status | grep status | awk '{print $2}') + [[ "${status}" == "done" ]] && break + [[ "${status}" == "error" ]] && break + sleep 3 + echo -n "." +done + +echo done + +cat > initialise.sh << EOF +#!/bin/bash + +# Waiting 10 seconds +sleep 10 + +SUNBEAM_VERSION=$SUNBEAM_VERSION +sudo snap install openstack --channel \$SUNBEAM_VERSION +sudo sunbeam prepare-node-script --bootstrap | sudo -i -u ubuntu bash -x +sudo -i -u ubuntu -- sunbeam -v cluster bootstrap --accept-defaults +EOF + +${lxc} file push initialise.sh ${inst_name}/root/ + +${lxc_exec} ${inst_name} -- chmod +x /root/initialise.sh +${lxc_exec} ${inst_name} -- /root/initialise.sh