Sha256: 744d44a345125450718bf7ff77d8bac6eb541d47ca96436375da09b9dc31b5b8

Contents?: true

Size: 1.23 KB

Versions: 11

Compression:

Stored size: 1.23 KB

Contents

require 'puppet'

Puppet::Reports.register_report(:store) do
  desc "Store the yaml report on disk.  Each host sends its report as a YAML dump
    and this just stores the file on disk, in the `reportdir` directory.

    These files collect quickly -- one every half hour -- so it is a good idea
    to perform some maintenance on them if you use this report (it's the only
    default report)."

  def process
    # We don't want any tracking back in the fs.  Unlikely, but there
    # you go.
    client = self.host.gsub("..",".")

    dir = File.join(Puppet[:reportdir], client)

    if ! FileTest.exists?(dir)
      FileUtils.mkdir_p(dir)
      FileUtils.chmod_R(0750, dir)
    end

    # Now store the report.
    now = Time.now.gmtime
    name = %w{year month day hour min}.collect do |method|
      # Make sure we're at least two digits everywhere
      "%02d" % now.send(method).to_s
    end.join("") + ".yaml"

    file = File.join(dir, name)

    begin
      File.open(file, "w", 0640) do |f|
        f.print to_yaml
      end
    rescue => detail
      puts detail.backtrace if Puppet[:trace]
      Puppet.warning "Could not write report for #{client} at #{file}: #{detail}"
    end

    # Only testing cares about the return value
    file
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
puppet-2.6.16 lib/puppet/reports/store.rb
puppet-2.6.15 lib/puppet/reports/store.rb
puppet-2.6.14 lib/puppet/reports/store.rb
puppet-2.6.13 lib/puppet/reports/store.rb
puppet-2.6.12 lib/puppet/reports/store.rb
puppet-2.6.11 lib/puppet/reports/store.rb
puppet-2.6.10 lib/puppet/reports/store.rb
puppet-2.7.1 lib/puppet/reports/store.rb
puppet-2.6.9 lib/puppet/reports/store.rb
puppet-2.6.8 lib/puppet/reports/store.rb
puppet-2.6.7 lib/puppet/reports/store.rb