Help manually deleting host?

Greetings, I've into a pickle I'm with two hosts that are identical accept
for the hostname.

Basically, the host is a multi-homed host. The eth0 interface
(primary/default route) is a public IP, the eth1 interface is a RFC1918 ip
that should route to Foreman/Puppet, etc (which all also live on RFC1918 ip
space). The trouble was noticed when after adding the host to
Foreman/Puppet via a puppet run. The initial checkin worked, but the
hostname was the public hostname and fqdn. So we messed around with the
puppet client config, and networking config, change the localhost name to
the private name that eth1 resolves to and executed a puppet run. Now I
have two hosts in Foreman with nearly identical facts.

The most annoying issue is that my puppet store-configs driven nagios host
can't talk to the public IP on this host, so all its alarms are firing, and
there is little way to resolve this w/o the reconfig I did on puppet. In
hindsight, perhaps I should have deleted the host before the reconfig. In
order to get Nagios under control, I have run puppet node clean <public
> and wiped the host out of puppet. This has cleaned up the Nagios
noise, but I'm left with Foreman still being messed up.

I have tried to delete the bad host, and I get :

NoMethodError
*undefined method []&#39; for nil:NilClass* app/controllers/hosts_controller.rb:122:indestroy'
lib/foreman/thread_session.rb:31:in `clear_thread'

I have also tried to delete the "good" host as well but the outcome is the
same.

Could someone school me on a postgresql query to manually remove this
offending host record?

Thanks!

I'd do this as a last resort, it'd be good to find out why that
deletion's failing first. I just helped someone debug a similar case in
Bug #3570: Error during delete an Host - Foreman which turned out to be the
puppetdb_foreman plugin not being configured causing problems.

Try enabling debugging and pastebin the whole stack trace from
/var/log/foreman/production.log:
http://projects.theforeman.org/projects/foreman/wiki/Troubleshooting#How-do-I-enable-debugging

Deleting a record from the DB can be tricky as there will be related
records (like facts or reports) which also need deleting.

··· On 05/11/13 19:36, Sean Alderman wrote: > Greetings, I've into a pickle I'm with two hosts that are identical > accept for the hostname. > > Basically, the host is a multi-homed host. The eth0 interface > (primary/default route) is a public IP, the eth1 interface is a RFC1918 > ip that should route to Foreman/Puppet, etc (which all also live on > RFC1918 ip space). The trouble was noticed when after adding the host > to Foreman/Puppet via a puppet run. The initial checkin worked, but the > hostname was the public hostname and fqdn. So we messed around with the > puppet client config, and networking config, change the localhost name > to the private name that eth1 resolves to and executed a puppet run. > Now I have two hosts in Foreman with nearly identical facts. > > The most annoying issue is that my puppet store-configs driven nagios > host can't talk to the public IP on this host, so all its alarms are > firing, and there is little way to resolve this w/o the reconfig I did > on puppet. In hindsight, perhaps I should have deleted the host before > the reconfig. In order to get Nagios under control, I have run puppet > node clean and wiped the host out of puppet. This has > cleaned up the Nagios noise, but I'm left with Foreman still being > messed up. > > I have tried to delete the bad host, and I get : > > /NoMethodError/ > *undefined method `[]' for nil:NilClass* > app/controllers/hosts_controller.rb:122:in `destroy' > lib/foreman/thread_session.rb:31:in `clear_thread' > > I have also tried to delete the "good" host as well but the outcome is > the same. > > Could someone school me on a postgresql query to manually remove this > offending host record?


Dominic Cleal
Red Hat Engineering

Thanks for the reply Dominic! I am running the puppetdb plugin as well.
It seems to work, I have deleted hosts before and their puppet data (e.g.
nagios stuff) has been removed as well.

Enjoy… :slight_smile: https://gist.github.com/salderma/7326998

··· On Tuesday, November 5, 2013 3:31:58 PM UTC-5, Dominic Cleal wrote: > > On 05/11/13 19:36, Sean Alderman wrote: > > Greetings, I've into a pickle I'm with two hosts that are identical > > accept for the hostname. > > > > Basically, the host is a multi-homed host. The eth0 interface > > (primary/default route) is a public IP, the eth1 interface is a RFC1918 > > ip that should route to Foreman/Puppet, etc (which all also live on > > RFC1918 ip space). The trouble was noticed when after adding the host > > to Foreman/Puppet via a puppet run. The initial checkin worked, but the > > hostname was the public hostname and fqdn. So we messed around with the > > puppet client config, and networking config, change the localhost name > > to the private name that eth1 resolves to and executed a puppet run. > > Now I have two hosts in Foreman with nearly identical facts. > > > > The most annoying issue is that my puppet store-configs driven nagios > > host can't talk to the public IP on this host, so all its alarms are > > firing, and there is little way to resolve this w/o the reconfig I did > > on puppet. In hindsight, perhaps I should have deleted the host before > > the reconfig. In order to get Nagios under control, I have run puppet > > node clean and wiped the host out of puppet. This has > > cleaned up the Nagios noise, but I'm left with Foreman still being > > messed up. > > > > I have tried to delete the bad host, and I get : > > > > /NoMethodError/ > > *undefined method `[]' for nil:NilClass* > > app/controllers/hosts_controller.rb:122:in `destroy' > > lib/foreman/thread_session.rb:31:in `clear_thread' > > > > I have also tried to delete the "good" host as well but the outcome is > > the same. > > > > Could someone school me on a postgresql query to manually remove this > > offending host record? > > I'd do this as a last resort, it'd be good to find out why that > deletion's failing first. I just helped someone debug a similar case in > http://projects.theforeman.org/issues/3570 which turned out to be the > puppetdb_foreman plugin not being configured causing problems. > > Try enabling debugging and pastebin the whole stack trace from > /var/log/foreman/production.log: > > http://projects.theforeman.org/projects/foreman/wiki/Troubleshooting#How-do-I-enable-debugging > > Deleting a record from the DB can be tricky as there will be related > records (like facts or reports) which also need deleting. > > -- > Dominic Cleal > Red Hat Engineering >

Yes, this is the same issue as reported in that bug report. Can you
check the settings for the PuppetDB plugin are in place, else restore
them or uninstall it?

The problem comes when the settings for the plugin are missing. I
included an example config file in
/usr/share/foreman/config/settings.plugins.d/ which could be moved into
place without the .example extension.

··· On 05/11/13 22:00, Sean Alderman wrote: > Thanks for the reply Dominic! I am running the puppetdb plugin as > well. It seems to work, I have deleted hosts before and their puppet > data (e.g. nagios stuff) has been removed as well. > > Enjoy... :) https://gist.github.com/salderma/7326998


Dominic Cleal
Red Hat Engineering

I've just released a -2 version of this RPM which deploys a default
config that's disabled, and a commented out example for how to enable
it. This means it shouldn't be broken by default :slight_smile:

··· On 05/11/13 22:16, Dominic Cleal wrote: > On 05/11/13 22:00, Sean Alderman wrote: >> Thanks for the reply Dominic! I am running the puppetdb plugin as >> well. It seems to work, I have deleted hosts before and their puppet >> data (e.g. nagios stuff) has been removed as well. >> >> Enjoy... :) https://gist.github.com/salderma/7326998 > > Yes, this is the same issue as reported in that bug report. Can you > check the settings for the PuppetDB plugin are in place, else restore > them or uninstall it? > > The problem comes when the settings for the plugin are missing. I > included an example config file in > /usr/share/foreman/config/settings.plugins.d/ which could be moved into > place without the .example extension.


Dominic Cleal
Red Hat Engineering

Wonderful! updated the package, restarted httpd, and deleted the host w/o
issue. Thanks!

··· On Tuesday, November 5, 2013 5:42:36 PM UTC-5, Dominic Cleal wrote: > > On 05/11/13 22:16, Dominic Cleal wrote: > > On 05/11/13 22:00, Sean Alderman wrote: > >> Thanks for the reply Dominic! I am running the puppetdb plugin as > >> well. It seems to work, I have deleted hosts before and their puppet > >> data (e.g. nagios stuff) has been removed as well. > >> > >> Enjoy... :) https://gist.github.com/salderma/7326998 > > > > Yes, this is the same issue as reported in that bug report. Can you > > check the settings for the PuppetDB plugin are in place, else restore > > them or uninstall it? > > > > The problem comes when the settings for the plugin are missing. I > > included an example config file in > > /usr/share/foreman/config/settings.plugins.d/ which could be moved into > > place without the .example extension. > > I've just released a -2 version of this RPM which deploys a default > config that's disabled, and a commented out example for how to enable > it. This means it shouldn't be broken by default :) > > -- > Dominic Cleal > Red Hat Engineering >