Because we never set the Host Owner config to default to a usergroup, all our hosts have ownership given to the user who created our hosts. As we wanted to delete a user who left our team, I decided to use the hammer cli to update ownership to all our servers. Well that part worked.
For some reason I don’t understand, and although I didn’t use any parameter mentionning a network interface, a large number of our hosts got a new interface of type “base” added to their config. It breaks the puppet node classifier. I end up with around 650 nodes whose puppet is not functionnal anymore.
Using a bit of hammer cli, and awk I can easily find and obtain the id of the interface I need to delete for every node affected. However I can’t find the way to delete it from the cli or the rest api. Can anyone show an example on how to remove an interface using either method ? Doing so with the gui would take hours.
I could not find a hammer command to remove interface atm, but I think this is the API endpoint you are looking for: curl -X DELETE https://<yourforman.domain>/api/hosts/<hostid>/interfaces/<interface>
In case you don’t know: You can find the API Documentation for your Foreman version and all installed Plugins at https://yourforman.domain/apidoc. Searching for interface on that site should give you all the API endpoints related to interfaces as well as their docs.
hammer has a command to remove an interface, check this: hammer host interface delete -h.
For the future, there is hammer full-help command which will show all available commands and options, probably better to use with grep.
UPD: but looking at the described issue, it’s still pretty weird that ownership change will affect host’s interfaces and seems like a bug. It would be very helpful if you could share logs (hammer -d or Foreman’s production.log) when you encounter this behaviour.
I didn’t created a bug as we are still in a fairly old 1.24 version and I would like to upgrade it in the upcoming weeks before trying to reproduce it. I will definitely try it again after the upgrade.