Sha256: 2fc974cb00b848b374e9d24d2e3bf29230b3bdf7e08d163a8bebbd0ef80ebd8e

Contents?: true

Size: 1.16 KB

Versions: 36

Compression:

Stored size: 1.16 KB

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. When a HTTPS URL
    is used, the remote server must present a certificate issued by the Puppet
    CA or the connection will fail validation. 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])
    headers = { "Content-Type" => "application/x-yaml" }
    options = {}
    if url.user && url.password
      options[:basic_auth] = {
        :user => url.user,
        :password => url.password
      }
    end
    use_ssl = url.scheme == 'https'
    conn = Puppet::Network::HttpPool.http_instance(url.host, url.port, use_ssl)
    response = conn.post(url.path, self.to_yaml, headers, options)
    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

36 entries across 36 versions & 2 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/reports/http.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/reports/http.rb
puppet-4.10.12 lib/puppet/reports/http.rb
puppet-4.10.12-x86-mingw32 lib/puppet/reports/http.rb
puppet-4.10.12-x64-mingw32 lib/puppet/reports/http.rb
puppet-4.10.12-universal-darwin lib/puppet/reports/http.rb
puppet-4.10.11 lib/puppet/reports/http.rb
puppet-4.10.11-x86-mingw32 lib/puppet/reports/http.rb
puppet-4.10.11-x64-mingw32 lib/puppet/reports/http.rb
puppet-4.10.11-universal-darwin lib/puppet/reports/http.rb
puppet-4.10.10 lib/puppet/reports/http.rb
puppet-4.10.10-x86-mingw32 lib/puppet/reports/http.rb
puppet-4.10.10-x64-mingw32 lib/puppet/reports/http.rb
puppet-4.10.10-universal-darwin lib/puppet/reports/http.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/reports/http.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/reports/http.rb
puppet-4.10.9 lib/puppet/reports/http.rb
puppet-4.10.9-x86-mingw32 lib/puppet/reports/http.rb
puppet-4.10.9-x64-mingw32 lib/puppet/reports/http.rb
puppet-4.10.9-universal-darwin lib/puppet/reports/http.rb