Skip to content

Instantly share code, notes, and snippets.

@jpadams
Last active August 29, 2015 13:56
Show Gist options
  • Save jpadams/9281986 to your computer and use it in GitHub Desktop.
Save jpadams/9281986 to your computer and use it in GitHub Desktop.
# /opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/reports/http.rb
# http://devsops.blogspot.com/2013/04/3.html
def process
raw_urls = Puppet[:reporturl]
url_array = raw_urls.gsub!(/\s+/, "").split(',')
url_array.each do |url|
#url = URI.parse(Puppet[:reporturl])
body = self.to_yaml
headers = { "Content-Type" => "application/x-yaml" }
use_ssl = url.scheme == 'https'
conn = Puppet::Network::HttpPool.http_instance(url.host, url.port, use_ssl, false)
response = conn.post(url.path, body, headers)
unless response.kind_of?(Net::HTTPSuccess)
Puppet.err "Unable to submit report to #{Puppet[:reporturl].to_s} [#{response.code}] #{response.msg}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment