diff options
author | Peter Meier <peter.meier@immerda.ch> | 2011-04-29 15:56:15 +0200 |
---|---|---|
committer | Pieter van de Bruggen <pieter@puppetlabs.com> | 2011-07-27 14:20:42 -0700 |
commit | c315da0efeace1878a877dc4b2f4aebc1ec13f0d (patch) | |
tree | 1d3faf4e63d214c5ed10a48629acb1437ac93e71 /lib/puppet/reports | |
parent | 5682125e1800f4c7b69b20fdd28f97a473d5d93c (diff) | |
download | puppet-c315da0efeace1878a877dc4b2f4aebc1ec13f0d.tar.gz puppet-c315da0efeace1878a877dc4b2f4aebc1ec13f0d.tar.xz puppet-c315da0efeace1878a877dc4b2f4aebc1ec13f0d.zip |
Fix #1886 - Add node cleanup capability
Here is a changeset that adds a new action to the puppet node face.
This application removes all traces of a node on the puppetmaster
(including certs, cached facts and nodes, reports, and storedconfig
entries).
Furthermore it is capable of unexporting exported resources of a
host so that consumers of these resources can remove the exported
resources and we will safely remove the node from our
infrastructure.
Usage:
puppet node clean [--unexport] <host> [<host2> ...]
To achieve this we add different destroy methods to the different
parts of the indirector. So for example for yaml indirections we
already offer read access for the yaml, this changeset adds
the destroy handler which only removes the yaml file for
a request. This can be used to remove cached entries.
This work is based on the initial work of Brice Figureau
<brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/reports')
-rw-r--r-- | lib/puppet/reports/store.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb index 625a263b3..997206ec4 100644 --- a/lib/puppet/reports/store.rb +++ b/lib/puppet/reports/store.rb @@ -41,5 +41,20 @@ Puppet::Reports.register_report(:store) do # Only testing cares about the return value file end + + # removes all reports for a given host + def self.destroy(host) + client = host.gsub("..",".") + dir = File.join(Puppet[:reportdir], client) + + if File.exists?(dir) + Dir.entries(dir).each do |file| + next if ['.','..'].include?(file) + file = File.join(dir, file) + File.unlink(file) if File.file?(file) + end + Dir.rmdir(dir) + end + end end |