Sha256: cde8831aaac7d45a32a68d881d2398eb6815ca514b49e7bec7f92561566898f8
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'rubygems' require 'chef' require 'chef/handler' require 'net/https' require 'uri' class ChefGroveIOHandler < Chef::Handler VERSION = '0.0.2' def initialize(url_hash) @url = "https://grove.io/api/notice/#{url_hash}/" @timestamp = Time.now.getutc end def report # build the message status = failed? ? "failed" : "succeeded" message = "chef-client run on #{node[:fqdn]} has #{status}." # notify stdout and via log.error if we have a terminal unless STDOUT.tty? begin timeout(10) do uri = URI.parse @url http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data({"service" => "Chef", "message" => message}) response = http.request(request) Chef::Log.info("Notified chefs via grove.io") end rescue Timeout::Error Chef::Log.error("Timed out while attempting to message chefs via grove.io") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chef-groveio-handler-0.0.2 | lib/chef-groveio-handler.rb |