I am trying to delete a host via Hammer:
hammer host update --name test --managed false
hammer host delete --name test
After running these commands, I still see the machine on the web interface.
I am attempting to delete it using these commands.
Can someone assist?
Here’s how you delete hosts using Hammer CLI:
# get a list of hosts
$ hammer host list
# delete your host based on its ID or host name
$ hammer host delete --id _My_Host_ID_ --organization-id _My_Organization_ID_ --location-id _My_Location_ID_
$ hammer host delete --name "my-host.example.com" --organization-id _My_Organization_ID_ --location-id _My_Location_ID_
If you are unsure about any Hammer commands, you can add
--help to every command from
hammer --help all the way to
hammer host delete --help.
I’ll make sure this ends up in the documentation and extends Removing a Host from Foreman in Managing Hosts.
What is the different between my command to yours??
I saw my hostname in the host list, and I manage to delete by the result of the command but in the web is still there.
Did you use the FQDN of the host? Did you set the organization and location context? Can you run
echo $? after your Hammer command to ensure it works and therefore exits with “0”?
I have tested both
--id on Foreman 3.5.
did it with your command ( use FQDN)
same error on the web ( my version of foreman 3.5.3 )
OK, for me, the host disappears on the WebUI as expected. Can you check the “Destroy associated VM on host delete” setting under Administer > Settings > Provisioning? I have it set to “No”; my compute resource is VMware (but that should not matter AFAIK).
Destroy associated VM was on “NO”