Removing Duplicated Host

Hi All,

I'm new to Foreman and inherited an existing 1.2.0 setup. One of the
hosts defined appears to be somewhat duplicated. I see this host as
an out of sync host and has been for several months, but if you look
at reports for the host, it has checked in recently. Also if I search
for this host in the Foreman web application, I only find one instance
of the hostname.

I noticed that the out of date report shows a different hardware type
than the currently checking in one, so I went poking around in the
database and noticed that there are two different entries in the hosts
table that contain the same name. I can tell which one I want to keep
but wasn't sure about how to sanely delete the other entry.

I did some Googling on this, but wasn't finding anything that really
seemed to match this scenario. Any suggestions?

Thanks,

··· -- Jason Wever

Database constraints should prevent two hosts with exactly the same name -
is it more a case of one with the shortname and one with the FQDN?

Greg

··· On 24 January 2014 18:39, Jason Wever wrote:

Hi All,

I’m new to Foreman and inherited an existing 1.2.0 setup. One of the
hosts defined appears to be somewhat duplicated. I see this host as
an out of sync host and has been for several months, but if you look
at reports for the host, it has checked in recently. Also if I search
for this host in the Foreman web application, I only find one instance
of the hostname.

I noticed that the out of date report shows a different hardware type
than the currently checking in one, so I went poking around in the
database and noticed that there are two different entries in the hosts
table that contain the same name. I can tell which one I want to keep
but wasn’t sure about how to sanely delete the other entry.

The hosts have the same FQDN.

In mysql, I did a "select * from hosts where name =
'my.hostname.com';" and the only fields that showed a difference
between the two hosts were:
id, last_compile, and image_id.

Cheers,

··· On Wed, Jan 29, 2014 at 6:13 AM, Greg Sutcliffe wrote: > On 24 January 2014 18:39, Jason Wever wrote: >> >> Hi All, >> >> I'm new to Foreman and inherited an existing 1.2.0 setup. One of the >> hosts defined appears to be somewhat duplicated. I see this host as >> an out of sync host and has been for several months, but if you look >> at reports for the host, it has checked in recently. Also if I search >> for this host in the Foreman web application, I only find one instance >> of the hostname. >> >> I noticed that the out of date report shows a different hardware type >> than the currently checking in one, so I went poking around in the >> database and noticed that there are two different entries in the hosts >> table that contain the same name. I can tell which one I want to keep >> but wasn't sure about how to sanely delete the other entry. > > > Database constraints should prevent two hosts with exactly the same name - > is it more a case of one with the shortname and one with the FQDN?


Jason

Oh, yeah, the db restriction is on the id field, not the name. Rails should
not have saved that though, so I'm really curious as to how it's happened.
You can try deleting the offending entry from the db (as ever, backup first
in case of issues), and if the facts/reports/etc are all going to the other
host it should delete fine. If not, you may get foreign_key constraint
issues, which will result in you having to delete data from other tables
first.

Greg

··· On 29 January 2014 14:59, Jason Wever wrote:

The hosts have the same FQDN.

In mysql, I did a “select * from hosts where name =
my.hostname.com’;” and the only fields that showed a difference
between the two hosts were:
id, last_compile, and image_id.

Deleting it from the hosts table worked just fine. Thanks for the suggestions!

Cheers,

··· On Wed, Jan 29, 2014 at 10:08 AM, Greg Sutcliffe wrote: > Oh, yeah, the db restriction is on the id field, not the name. Rails should > not have saved that though, so I'm really curious as to how it's happened. > You can try deleting the offending entry from the db (as ever, backup first > in case of issues), and if the facts/reports/etc are all going to the other > host it should delete fine. If not, you may get foreign_key constraint > issues, which will result in you having to delete data from other tables > first.


Jason Wever