Skip to content

Instantly share code, notes, and snippets.

@loe
Created December 22, 2011 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loe/1512077 to your computer and use it in GitHub Desktop.
Save loe/1512077 to your computer and use it in GitHub Desktop.
require 'puppet'
require 'net/http'
require 'net/https'
FOREMAN_HOST = 'your.domain.com'
FOREMAN_PORT = 443
Puppet::Reports.register_report(:foreman) do
Puppet.settings.use(:reporting)
desc "Sends reports directly to Foreman"
def process
begin
http = Net::HTTP.new(FOREMAN_HOST, FOREMAN_PORT)
http.use_ssl = true
http.start do |conn|
req = Net::HTTP::Post.new("/reports/create?format=yml")
req.set_form_data({'report' => to_yaml})
req.basic_auth('user', 'pass')
conn.request(req)
end
rescue Exception => e
raise Puppet::Error, "Could not send report to Foreman: #{e}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment