How to undeploy Hosted Engine hosts via command line?

Solution Verified - Updated

Environment

Red Hat Virtualization 4.1 through RHV 4.4

Issue

Host Undeploy from RHV Manager UI failed. The host is not shown as hosted engine host in the manager, but still present in HE metadata.
How can I manually undeploy the host from HE setup?

Resolution

On the host we want to remove:

  1. Disable and stop ovirt-ha-agent and ovirt-ha-broker
  2. Confirm host id from the hosted-engine config file
  3. Delete /etc/ovirt-hosted-engine/hosted-engine.conf
# systemctl stop ovirt-ha-agent
# systemctl stop ovirt-ha-broker
# grep host_id /etc/ovirt-hosted-engine/hosted-engine.conf
# rm -f /etc/ovirt-hosted-engine/hosted-engine.conf 

On another, active HE host:
4. Make sure identified host id is associated only with the host we are trying to remove.
5. Clean metadata with the ID of the of you want to clean in N

# hosted-engine --vm-status | grep -B2 "Host ID"
# hosted-engine --clean-metadata --host-id=N --force-clean

Back to the undeployed host:
6. Confirm it has been undeployed:

# hosted-engine --vm-status 
Need to deploy Hosted Engine first.
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.