adding icn version fixes in metal3 vm
[icn.git] / deploy / metal3-vm / 05_host_cleanup.sh
1 #!/usr/bin/env bash
2 set -x
3
4 # shellcheck disable=SC1091
5 source lib/logging.sh
6 # shellcheck disable=SC1091
7 source lib/common.sh
8
9 # Kill and remove the running ironic containers
10 for name in ironic ironic-inspector dnsmasq httpd mariadb ipa-downloader; do
11     sudo "${CONTAINER_RUNTIME}" ps | grep -w "$name$" && sudo "${CONTAINER_RUNTIME}" kill $name
12     sudo "${CONTAINER_RUNTIME}" ps --all | grep -w "$name$" && sudo "${CONTAINER_RUNTIME}" rm $name -f
13 done
14
15 # Remove existing pod
16 if [[ "${CONTAINER_RUNTIME}" == "podman" ]]; then
17   if  sudo "${CONTAINER_RUNTIME}" pod exists ironic-pod ; then
18       sudo "${CONTAINER_RUNTIME}" pod rm ironic-pod -f
19   fi
20 fi
21
22 # Kill the locally running operators
23 if [ "${BMO_RUN_LOCAL}" = true ]; then
24   kill "$(pgrep "operator-sdk")" 2> /dev/null || true
25 fi
26 if [ "${CAPBM_RUN_LOCAL}" = true ]; then
27   CAPBM_PARENT_PID="$(pgrep -f "go run ./cmd/manager/main.go")"
28   if [[ "${CAPBM_PARENT_PID}" != "" ]]; then
29     CAPBM_GO_PID="$(pgrep -P "${CAPBM_PARENT_PID}" )"
30     kill "${CAPBM_GO_PID}"  2> /dev/null || true
31   fi
32 fi
33
34
35 ANSIBLE_FORCE_COLOR=true ansible-playbook \
36     -e "working_dir=$WORKING_DIR" \
37     -e "num_masters=$NUM_MASTERS" \
38     -e "num_workers=$NUM_WORKERS" \
39     -e "extradisks=$VM_EXTRADISKS" \
40     -e "virthost=$HOSTNAME" \
41     -e "manage_baremetal=$MANAGE_BR_BRIDGE" \
42     -i vm-setup/inventory.ini \
43     -b -vvv vm-setup/teardown-playbook.yml
44
45 sudo rm -rf /etc/NetworkManager/conf.d/dnsmasq.conf
46 # There was a bug in this file, it may need to be recreated.
47 if [ "$MANAGE_PRO_BRIDGE" == "y" ]; then
48     sudo ifdown provisioning || true
49     sudo rm -f /etc/sysconfig/network-scripts/ifcfg-provisioning || true
50 fi
51 # Leaving this around causes issues when the host is rebooted
52 if [ "$MANAGE_BR_BRIDGE" == "y" ]; then
53     sudo ifdown baremetal || true
54     sudo rm -f /etc/sysconfig/network-scripts/ifcfg-baremetal || true
55 fi
56
57 rm -rf $WORKING_DIR
58 rm -rf $IRONIC_DATA_DIR