Created
December 22, 2011 22:11
-
-
Save loe/1512077 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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