Sha256: b000dbeb86047f5a777df648de64038a3a1f2bc6af79867001757f16e69b45c1

Contents?: true

Size: 797 Bytes

Versions: 4

Compression:

Stored size: 797 Bytes

Contents

require 'puppet'
require 'puppet/network/http_pool'
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 body of the request.
  DESC

  def process
    url = URI.parse(Puppet[:reporturl])
    body = self.to_yaml
    headers = { "Content-Type" => "application/x-yaml" }
    use_ssl = url.scheme == 'https'
    conn = Puppet::Network::HttpPool.http_instance(url.host, url.port, use_ssl)
    response = conn.post(url.path, body, headers)
    unless response.kind_of?(Net::HTTPSuccess)
      Puppet.err "Unable to submit report to #{Puppet[:reporturl].to_s} [#{response.code}] #{response.msg}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-3.0.0.rc8 lib/puppet/reports/http.rb
puppet-3.0.0.rc7 lib/puppet/reports/http.rb
puppet-3.0.0.rc5 lib/puppet/reports/http.rb
puppet-3.0.0.rc4 lib/puppet/reports/http.rb