| Add the following report processor to lib/puppet/reports/legacy.rb, which is a simplified version of the http processor from puppet 5/6:
require 'puppet' |
require 'puppet/network/http_pool' |
require 'uri' |
|
Puppet::Reports.register_report(:legacy) do |
def process |
url = URI.parse(Puppet[:reporturl]) |
conn = Puppet::Network::HttpPool.http_instance(url.host, url.port, false) |
response = conn.post(url.path, self.to_yaml, { "Content-Type" => "application/x-yaml" }) |
unless response.kind_of?(Net::HTTPSuccess) |
Puppet.err ("Unable to submit report to #{Puppet[:reporturl]} [#{response.code}] #{response.msg}") |
end |
end |
end
|
Make sure puppetserver includes commit https://github.com/puppetlabs/puppetserver/commit/d6c07c9fae476cfd07502436fd397fa8ef60ac67 and the report processor is the jruby load-path. Configure puppet.conf with:
Start a simple http server on port 8000, like python -m SimpleHTTPServer Start puppetserver and run the agent, and the report processor will fail with:
020-10-28 11:26:04,868 ERROR [qtp470539277-446] [puppetserver] Puppet Report processor failed: undefined method `code' for nil:NilClass |
/Users/josh/work/puppet/lib/puppet/reports/legacy.rb:35:in `process' |
/Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:37:in `block in process' |
/Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:54:in `block in processors' |
org/jruby/RubyArray.java:1809:in `each' |
/Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:51:in `processors' |
/Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:30:in `process' |
/Users/josh/work/puppet/lib/puppet/indirector/report/processor.rb:14:in `save'
|
This is because Puppet::HTTP::Response#nethttp returns nil |