[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
test branch
puppet-dev at googlegroups.com
Wed Jul 14 10:34:42 UTC 2010
The following commit has been merged in the upstream branch:
commit c00285c395647bc19237ec6c60099d11997592bb
Author: Rein Henrichs <rein at puppetlabs.com>
Date: Thu May 20 14:41:22 2010 -0700
[#3810] Add http reports processor and `reporturl` setting
Example puppet.conf:
[puppetmasterd]
reports = store, http
reporturl = http://localhost:3000/reports
* Group reporturl and reportdir in new reports section of
Puppet::Settings
* Add specs for both
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 775e26a..1e1fc15 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -436,13 +436,6 @@ module Puppet
in puppet/reports/<name>.rb, and multiple report names should be
comma-separated (whitespace is okay)."
],
- :reportdir => {:default => "$vardir/reports",
- :mode => 0750,
- :owner => "service",
- :group => "service",
- :desc => "The directory in which to store reports
- received from the client. Each client gets a separate
- subdirectory."},
:fileserverconfig => ["$confdir/fileserver.conf",
"Where the fileserver configuration is stored."],
:rrddir => {:default => "$vardir/rrd",
@@ -630,6 +623,17 @@ module Puppet
"What files to ignore when pulling down facts."]
)
+ setdefaults :reports,
+ :reportdir => {:default => "$vardir/reports",
+ :mode => 0750,
+ :owner => "service",
+ :group => "service",
+ :desc => "The directory in which to store reports
+ received from the client. Each client gets a separate
+ subdirectory."},
+ :reporturl => ["http://localhost:3000/reports",
+ "The URL used by the http reports processor to send reports"]
+
setdefaults(:tagmail,
:tagmap => ["$confdir/tagmail.conf",
"The mapping between reporting tags and email addresses."],
diff --git a/lib/puppet/reports/http.rb b/lib/puppet/reports/http.rb
new file mode 100644
index 0000000..d74782c
--- /dev/null
+++ b/lib/puppet/reports/http.rb
@@ -0,0 +1,22 @@
+require 'puppet'
+require 'net/http'
+require 'uri'
+
+Puppet::Reports.register_report(:http) do
+
+ desc <<-DESC
+ Send report information via HTTP to the ``reporturl``. Each host sends
+ its report as a YAML dump and this sends this YAML to a client via HTTP POST.
+ The YAML is the `report` parameter of the request."
+ DESC
+
+ def process
+ url = URI.parse(Puppet[:reporturl])
+ req = Net::HTTP::Post.new(url.path)
+ req.body = self.to_yaml
+ req.content_type = "application/x-yaml"
+ Net::HTTP.new(url.host, url.port).start {|http|
+ http.request(req)
+ }
+ end
+end
diff --git a/spec/integration/defaults.rb b/spec/integration/defaults.rb
index bae281d..db8686f 100755
--- a/spec/integration/defaults.rb
+++ b/spec/integration/defaults.rb
@@ -244,4 +244,14 @@ describe "Puppet defaults" do
it "should have an http_compression setting that defaults to false" do
Puppet.settings[:http_compression].should be_false
end
+
+ describe "reportdir" do
+ subject { Puppet.settings[:reportdir] }
+ it { should == "#{Puppet[:vardir]}/reports" }
+ end
+
+ describe "reporturl" do
+ subject { Puppet.settings[:reporturl] }
+ it { should == "http://localhost:3000/reports" }
+ end
end
diff --git a/spec/unit/reports/http.rb b/spec/unit/reports/http.rb
new file mode 100644
index 0000000..2c7c32c
--- /dev/null
+++ b/spec/unit/reports/http.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+require 'puppet/reports'
+
+class Net::HTTP
+ REQUESTS = {}
+ alias_method :old_request, :request
+ def request(req, body=nil, &block)
+ REQUESTS[req.path] = req
+ old_request(req, body, &block)
+ end
+end
+
+processor = Puppet::Reports.report(:http)
+
+describe processor do
+ subject { Puppet::Transaction::Report.new.extend(processor) }
+
+ it { should respond_to(:process) }
+
+ describe "request" do
+ before { subject.process }
+
+ describe "body" do
+ it "should be the report as YAML" do
+ reports_request.body.should == subject.to_yaml
+ end
+ end
+
+ describe "content type" do
+ it "should be 'application/x-yaml'" do
+ reports_request.content_type.should == "application/x-yaml"
+ end
+ end
+ end
+
+ private
+
+ def reports_request; Net::HTTP::REQUESTS[URI.parse(Puppet[:reporturl]).path] end
+end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list