Problem:
We encounter this error whenever we move some of the hosts to a hostgroup - “Name has already been taken”
I don’t see any duplicates for the host/s even when I switch to “Any Organization”.
I tried checking the database to see if there is a duplicate entry for some of the problematic host.
Querying the “hosts” table in the database I found 2 IDs pointing to the same host (all the problematic hosts has this behavior)
id | name | hostgroup_id | created_at | updated_at | last_report
-----+---------------+--------------+----------------------------+----------------------------+---------------------
301 | aikengall1 | | 2021-02-08 00:06:58.701721 | 2021-02-08 00:07:02.755265 |
319 | aikengall1 | | 2021-02-08 00:36:14.74654 | 2021-02-10 00:45:47.595442 | 2021-02-10 00:43:06
(2 rows)
I was hoping to find the host via the foreman-rake console so I could delete it but it does not seem to see the resource.
$> foreman-rake console
Loading production environment (Rails 6.0.3.1)
irb(main):001:0> Host.find_by_id(301)
=> nil
It would seem like the only way to fix this is by deleting the duplicate host from the database. I’m tempted to just delete the host as was done in this old post Removing Duplicated Host but would like to know
is there a proper/clean way of removing these duplicate hosts from the DB?
Thanks in advance for the help.
Expected outcome:
The duplicate ID, related facts, reports, etc. are removed and Host can be added to hostgroup.
Foreman and Proxy versions:
Katello 3.17
Foreman 2.2.1
Foreman-Proxy 2.2.1
Foreman and Proxy plugin versions:
Distribution and version:
Other relevant data: