11#! /usr/bin/env bash
22set -euo pipefail
33
4- # AU_FROM_SEED="false "
4+ AU_FROM_SEED=" true "
55# OS_IMAGE="Rocky9"
6- # TAINT_REBUILD="false "
6+ TAINT_REBUILD=" true "
77
88echo " Starting AUFN test action with:"
99echo " AU_FROM_SEED: $AU_FROM_SEED "
1010echo " OS Image: $OS_IMAGE "
11+ echo " TAINT_REBUILD: $TAINT_REBUILD "
12+ echo
1113
1214if [[ " $OS_IMAGE " == " Ubuntu" ]]; then
1315 export LAB_IMAGE_USER=" ubuntu"
1921fi
2022
2123function check_lab_vm_connections() {
24+ echo
2225 echo " Checking VM connections..."
23- cat ssh_list.txt
26+ echo
2427 while IFS= read -r line; do
2528 ip=$( echo " $line " | awk ' {print $3}' )
2629 name=$( echo " $line " | awk ' {print $2}' )
2730 password=$( echo " $line " | awk ' {print $5}' )
2831
29- echo " Connecting to $name ($password ) at $ip ..."
32+ echo
33+ echo
34+ echo " Connecting to $name at $ip ..."
3035 sshpass -p " $password " ssh -o StrictHostKeyChecking=no \
3136 " lab@${ip} " ' echo "Connected to $(hostname)"'
3237 done < ssh_list.txt
3338}
3439
3540function validate_lab_vms() {
41+ echo && echo
3642 echo " Validating Lab VMs setup..."
3743 index=0
3844 rm -f failed-labs.txt
@@ -42,16 +48,18 @@ function validate_lab_vms() {
4248 name=$( echo " $line " | awk ' {print $2}' )
4349 password=$( echo " $line " | awk ' {print $5}' )
4450
45- echo " Validating $name at $ip ..."
51+ echo && echo
52+ echo " Validating $name at $ip ..." && echo
4653
47- sshpass -p " $password " ssh -o StrictHostKeyChecking=no \
54+ sshpass -p " $password " ssh -o StrictHostKeyChecking=no\
4855 " lab@${ip} " << 'EOF '
4956 output=$(sudo virsh list --all)
5057 echo "$output"
5158 if ! echo "$output" | grep -q 'seed.*running'; then echo "'seed' not running"; fi
5259 if ! echo "$output" | grep -q 'compute0.*shut off'; then echo "'compute0' not shut off"; fi
5360 if ! echo "$output" | grep -q 'controller0.*shut off'; then echo "'controller0' not shut off"; fi
5461
62+ echo && echo
5563 echo "$(ssh [email protected] 'sudo docker ps')" 5664 if ! ssh [email protected] 'sudo docker ps' | grep -q bifrost_deploy; then echo "Bifrost container isn't deployed"; fi 5765 if ! tail -n 10 a-seed-from-nothing.out | grep -q 'PLAY RECAP.*failed=0'; then echo "There was an error in running 'a-seed-from-nothing'"; fi
7785 index=$(( index + 1 ))
7886 set -euo pipefail
7987 done < ssh_list.txt
88+ # echo >> failed-labs.txt
8089}
8190
8291function taint_and_reapply() {
@@ -88,7 +97,7 @@ function taint_and_reapply() {
8897 echo " Tainting failed VMs..."
8998 while IFS= read -r line; do
9099 idx=$( echo " $line " | tr -d ' \r' )
91- echo " Tainting VM at index $idx "
100+ echo " Tainting aufn-lab $idx VM "
92101 terraform taint openstack_compute_instance_v2.lab[$idx ]
93102 done < failed-labs.txt
94103 echo " Rebuilding tainted Lab VMs..."
@@ -133,7 +142,7 @@ check_lab_vm_connections
133142validate_lab_vms
134143
135144
136- if [[ " $TAINT_REBUILD " = " true" ]]; then
145+ if [[ " $TAINT_REBUILD " = " true" && ! -s failed-labs.txt ]]; then
137146 taint_and_reapply
138147 terraform output -json > tf-outputs.json
139148 terraform output -raw labs > ssh_list.txt
0 commit comments