David Schmitt
2008-Feb-04 14:08 UTC
Export/collect: Cleaning up after decomissioning server
Hi everyone! If you, like me, have wondered how to get rid of exported resources after taking a server offline without having it report back a last time without any configuration, this is what you have to do: Go to your preferred SQL-Entry tool and do the following: delete FROM hosts where name = ''the-deleted-server''; delete from resources where host_id not in (select id from hosts); delete from fact_values where host_id not in (select id from hosts); delete from param_values where resource_id not in (select id from resources); delete from resource_tags where resource_id not in (select id from resources); delete from puppet_tags where resource_id not in (select id from resources); This deletes all important resources associated with the host "the-deleted-server". Regards, DavidS
John Philips
2008-Feb-04 15:25 UTC
Re: Export/collect: Cleaning up after decomissioning server
Hmm, if foreign keys existed you could limit this task to one SQL statement: delete FROM hosts where name = ''the-deleted-server''; Since foreign key support was added to MySQL literally years ago, I think it''s safe to start using them. --- David Schmitt <david@schmitt.edv-bus.at> wrote:> Hi everyone! > > If you, like me, have wondered how to get rid of > exported resources > after taking a server offline without having it > report back a last time > without any configuration, this is what you have to > do: > > Go to your preferred SQL-Entry tool and do the > following: > > delete FROM hosts where name = ''the-deleted-server''; > delete from resources where host_id not in (select > id from hosts); > delete from fact_values where host_id not in (select > id from hosts); > delete from param_values where resource_id not in > (select id from > resources); > delete from resource_tags where resource_id not in > (select id from > resources); > delete from puppet_tags where resource_id not in > (select id from resources); > > > This deletes all important resources associated with > the host > "the-deleted-server". > > > > Regards, DavidS > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com >https://mail.madstop.com/mailman/listinfo/puppet-users>____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Luke Kanies
2008-Feb-04 16:02 UTC
Re: Export/collect: Cleaning up after decomissioning server
On Feb 4, 2008, at 8:08 AM, David Schmitt wrote:> Hi everyone! > > If you, like me, have wondered how to get rid of exported resources > after taking a server offline without having it report back a last > time > without any configuration, this is what you have to do: > > Go to your preferred SQL-Entry tool and do the following: > > delete FROM hosts where name = ''the-deleted-server''; > delete from resources where host_id not in (select id from hosts); > delete from fact_values where host_id not in (select id from hosts); > delete from param_values where resource_id not in (select id from > resources); > delete from resource_tags where resource_id not in (select id from > resources); > delete from puppet_tags where resource_id not in (select id from > resources); > > > This deletes all important resources associated with the host > "the-deleted-server".It would be much easier to write a short ruby script that just did: Puppet::Rails::Host.find_by_name("bad-host").delete Or something like that. Why stick to the SQL stuff when ActiveRecord can do the work for you? -- Neonle will continue to be rude, and will nretend that you had a small stroke which makes you unable to say or see the letter "n". Stunid nractical joke, if you ask me. Bunch of noon-heads, huh? -- Fred Barling, Humorscope --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com