--- /dev/null
+roles:
+- - host.a
+ - mon.a
+ - mgr.a
+ - osd.0
+ - osd.1
+- - host.b
+ - mon.b
+ - mgr.b
+ - osd.2
+ - osd.3
+- - host.c
+ - mon.c
+ - osd.4
+ - osd.5
+tasks:
+- install:
+- cephadm:
+- cephadm.shell:
+ host.a:
+ - |
+ set -ex
+ HOSTNAMES=$(ceph orch host ls --format json | jq -r '.[] | .hostname')
+ for host in $HOSTNAMES; do
+ # find the hostname for "host.c" which will have no mgr
+ HAS_MGRS=$(ceph orch ps --hostname ${host} --format json | jq 'any(.daemon_type == "mgr")')
+ if [ "$HAS_MGRS" == "false" ]; then
+ HOST_C="${host}"
+ fi
+ done
+ # now drain that host
+ ceph orch host drain $HOST_C --zap-osd-devices
+ # wait for drain to complete
+ HOST_C_DAEMONS=$(ceph orch ps --hostname $HOST_C)
+ while [ "$HOST_C_DAEMONS" != "No daemons reported" ]; do
+ sleep 15
+ HOST_C_DAEMONS=$(ceph orch ps --hostname $HOST_C)
+ done
+ # If the drain was successful, we should be able to remove the
+ # host without force with no issues. If there are still daemons
+ # we will get a response telling us to drain the host and a
+ # non-zero return code
+ ceph orch host rm $HOST_C
+
+
+