useful_scripts/fix_cloud.sh

64 lines
1.9 KiB
Bash
Raw Normal View History

2021-10-12 19:24:31 +00:00
#!/bin/bash
2021-10-12 19:36:06 +00:00
# Used for debugging
# set -ax
2021-10-12 19:24:31 +00:00
# This script is required after a reboot of the cloud after the cloud has been
# shut down
. functions.sh
2022-10-24 10:37:22 +00:00
check_juju_version
juju-wait -v ${model}
2021-10-12 19:24:31 +00:00
get_juju_status
2021-10-12 19:36:06 +00:00
# Check if we're using percona-cluster and/or mysql-innodb-cluster
percona_cluster=$(jq -r ".applications | to_entries[] | select(.value[\"charm-name\"] == \"percona-cluster\") | .key" "${juju_status_out}")
mysql_innodb_cluster=$(jq -r ".applications | to_entries[] | select(.value[\"charm-name\"] == \"mysql-innodb-cluster\") | .key" "${juju_status_out}")
2021-10-12 19:24:31 +00:00
if [[ -n "${percona_cluster}" ]] ; then
do_percona_cluster
2021-10-12 19:24:31 +00:00
fi
if [[ -n "${mysql_innodb_cluster}" ]] ; then
do_mysql_innodb_cluster
fi
2022-10-24 10:37:22 +00:00
${juju_run} -u elasticsearch/leader -- sudo systemctl restart elasticsearch &
${juju_run} -a heat -- sudo systemctl restart heat-engine &
${juju_run} -a ceph-radosgw -- 'sudo systemctl restart ceph-radosgw@*' &
2021-10-12 19:36:06 +00:00
wait
2021-10-12 19:24:31 +00:00
2021-10-12 19:36:06 +00:00
# cleanup all crm resources
jq -r ".applications | to_entries[] | select(.value[\"charm-name\"] == \"hacluster\") | .key" "${juju_status_out}" \
| xargs -I{} ${juju_run} -u "{}"/leader -- 'sudo crm_resource -l | sed s/:.*//g | uniq | xargs -i sudo crm resource cleanup \"\{\}\"'
2021-10-12 19:24:31 +00:00
do_vault restart
2021-10-12 19:24:31 +00:00
2022-07-22 08:42:40 +00:00
# remove DNS entry for external network
${juju_run} --all -- "sudo sed -i -e s/192.168.1.13,//g -e s/192.168.1.9,//g /etc/netplan/99-juju.yaml"
${juju_run} --all -- "sudo netplan apply ; sudo systemctl restart systemd-resolved"
2021-10-12 19:24:31 +00:00
do_ceph
2021-10-12 19:36:06 +00:00
lds_servers=$(jq -rc ". | .applications[\"landscape-server\"].units | to_entries[] | .key" "${juju_status_out}")
2021-10-12 19:24:31 +00:00
cat > /tmp/restart-landscape.sh << EOF
#!/bin/bash
sudo systemctl restart landscape-*
EOF
for lds_server in ${lds_servers}
do
${juju_scp} /tmp/restart-landscape.sh "${lds_server}":.
${juju_ssh} "${lds_server}" chmod +x restart-landscape.sh
${juju_ssh} "${lds_server}" sudo ./restart-landscape.sh &
2021-10-12 19:24:31 +00:00
done
wait
[[ $LMA_SERVERS == "off" ]] && ${juju_run} -m lma --all -- sudo halt -p