pvc-ansible/purge.sh

49 lines
1.9 KiB
Bash
Raw Normal View History

2020-04-06 13:39:53 -04:00
#!/bin/bash
2020-08-19 16:35:05 -04:00
echo -e "DANGER: This script will PURGE ALL PVC data and configuration from the following host(s):"
echo
echo -e " $@"
echo
echo -e "Are you sure you want to continue?"
echo
echo -en "To abort, press <Ctrl+C> now. To continue, press <Enter>. "
read
2021-01-27 17:05:20 -05:00
echo
2020-04-06 13:39:53 -04:00
for host in $@; do
2021-01-27 17:05:20 -05:00
echo -n "Purging host ${host}... "
2021-01-28 13:26:46 -05:00
ssh deploy@${host} '
2021-01-27 17:05:20 -05:00
sudo systemctl stop pvcnoded;
2021-12-15 09:47:52 -05:00
sudo systemctl stop pvcapid;
2020-04-06 13:39:53 -04:00
sudo systemctl stop ceph-mon@$(hostname -s);
2021-01-27 17:05:20 -05:00
sudo systemctl stop ceph-mgr@$(hostname -s);
sudo systemctl stop patroni;
2021-12-15 11:29:10 -05:00
for key in $( echo "ls /" | sudo /usr/share/zookeeper/bin/zkCli.sh -server $(hostname -s):2181 | grep --color=none zookeeper | tr -d "[]," | tr " " "\n" | grep -v zookeeper ); do
echo "rmr /${key}" | sudo /usr/share/zookeeper/bin/zkCli.sh -server $(hostname -s):2181;
2021-01-28 13:26:46 -05:00
done
2021-01-27 17:05:20 -05:00
sudo systemctl stop zookeeper;
sudo rm -rf /etc/pvc-install.* /etc/ceph* /etc/patroni* /etc/postgres* /etc/zookeeper* /etc/libvirt*;
2021-12-15 10:44:36 -05:00
sudo rm -rf /var/lib/postgresql /var/lib/zookeeper/* /var/lib/libvirt /var/lib/ceph/*;
suod rm -rf /var/log/postgresql /var/log/zookeeper /var/log/libvirt /var/log/ceph;
2021-01-27 17:05:20 -05:00
sudo rm -rf /run/ceph;
2020-04-06 13:39:53 -04:00
sudo rm -rf /etc/systemd/system/ceph-*.target.wants;
2021-12-15 09:47:52 -05:00
sudo apt purge -y *pvc*;
2020-04-06 13:39:53 -04:00
sudo apt purge -y *ceph* *rbd* *rados*;
sudo apt purge -y patroni* postgres* zookeeper* libvirt*
sudo apt purge -y ca-certificates-java fontconfig-config libjemalloc2 libpq5 python-psycopg2 python3-eventlet python3-greenlet python3-jinja2 python3-kazoo python3-markupsafe python3-pkg-resources python3-pygments python3-six uuid-runtime
sudo apt autoremove --purge -y;
sudo apt clean;
2020-04-06 15:20:20 -04:00
sudo apt update;
2020-04-06 13:39:53 -04:00
sudo userdel ceph;
sudo umount /var/lib/ceph;
sudo mkfs.ext4 /dev/vgx/ceph;
2021-01-28 13:26:46 -05:00
sudo mount /var/lib/ceph;
2021-12-20 04:41:03 -05:00
' &>/dev/null || continue
2021-12-15 09:47:52 -05:00
echo "done."
echo -n "Rebooting host ${host}... "
ssh deploy@${host} '
2021-01-28 14:13:15 -05:00
sudo reboot;
2021-01-28 13:26:46 -05:00
' &>/dev/null
2021-01-27 17:05:20 -05:00
echo "done."
2020-04-06 13:39:53 -04:00
done