Sha256: 2ed6d917411071184405bdcd1815827c2e8872bed9cf82b98bf7a04ff312ac4a

Contents?: true

Size: 894 Bytes

Versions: 35

Compression:

Stored size: 894 Bytes

Contents

require 'puppet'
require 'puppet/network/http_pool'
require 'uri'

Puppet::Reports.register_report(:http) do

  desc <<-DESC
    Send reports via HTTP or HTTPS. This report processor submits reports as
    POST requests to the address in the `reporturl` setting. The body of each POST
    request is the YAML dump of a Puppet::Transaction::Report object, and the
    Content-Type is set as `application/x-yaml`.
  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

35 entries across 35 versions & 2 rubygems

Version Path
puppet-3.4.3 lib/puppet/reports/http.rb
puppet-3.4.2 lib/puppet/reports/http.rb
puppet-3.4.1 lib/puppet/reports/http.rb
puppet-3.4.0 lib/puppet/reports/http.rb
puppet-3.4.0.rc2 lib/puppet/reports/http.rb
puppet-3.4.0.rc1 lib/puppet/reports/http.rb
puppet-3.3.2 lib/puppet/reports/http.rb
puppet-3.3.1 lib/puppet/reports/http.rb
puppet-3.3.1.rc3 lib/puppet/reports/http.rb
puppet-3.3.1.rc2 lib/puppet/reports/http.rb
puppet-3.3.1.rc1 lib/puppet/reports/http.rb
puppet-3.3.0 lib/puppet/reports/http.rb
puppet-3.3.0.rc3 lib/puppet/reports/http.rb
puppet-3.3.0.rc2 lib/puppet/reports/http.rb
puppet-3.2.4 lib/puppet/reports/http.rb
puppet-3.2.3 lib/puppet/reports/http.rb
puppet-3.2.3.rc1 lib/puppet/reports/http.rb
puppet-3.2.2 lib/puppet/reports/http.rb
puppet-3.2.1 lib/puppet/reports/http.rb
puppet-3.2.1.rc1 lib/puppet/reports/http.rb