From df720fd36567105c6ad45301fb861dbcb036cb63 Mon Sep 17 00:00:00 2001 From: Frank Sweetser Date: Tue, 1 Dec 2009 10:39:22 -0500 Subject: [PATCH] Handle HTTPS report submissions --- extras/puppet/foreman/files/foreman-report.rb | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/extras/puppet/foreman/files/foreman-report.rb b/extras/puppet/foreman/files/foreman-report.rb index 62d7126..0652dd0 100644 --- a/extras/puppet/foreman/files/foreman-report.rb +++ b/extras/puppet/foreman/files/foreman-report.rb @@ -15,9 +15,17 @@ Puppet::Reports.register_report(:foreman) do def process begin - Net::HTTP.post_form(URI.parse("#{$foreman_url}/reports/create?format=yml"), {'report'=> to_yaml}) + uri = URI.parse($foreman_url) + http = Net::HTTP.new(uri.host, uri.port) + if uri.scheme == 'https' then + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + end + req = Net::HTTP::Post.new("/reports/create?format=yml") + req.set_form_data({'report' => to_yaml}) + response = http.request(req) rescue Exception => e - raise Puppet::Error, "Could not send report to Foreman: #{e}" + raise Puppet::Error, "Could not send report to Foreman at #{$foreman_url}/reports/create?format=yml: #{e}" end end end -- 1.6.5.2