Created
November 12, 2010 17:33
-
-
Save danielsdeleo/674396 to your computer and use it in GitHub Desktop.
add an exception/report handler from inside a recipe
This file contains hidden or 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
p = gem_package("nomnomnom-client") { action :nothing } | |
p.run_action(:install) | |
Gem.clear_paths | |
require 'nom_nom_nom' | |
nomnomnom_servers = [] | |
search(:node, "role:nomnomnom-server") do |server| | |
nomnomnom_servers << server[:ipaddress] | |
end | |
Chef::Log.debug "NomNomNom server list: '#{nomnomnom_servers.join(', ')}'" | |
if nomnomnom_servers.empty? | |
Chef::Log.info "No NomNomNom server found, not enabling the NomNomNom client" | |
else | |
unless Chef::Config.report_handlers.any? { |h| h === NomNomNom::StatusHandler } | |
Chef::Config.report_handlers << NomNomNom::StatusHandler.new(nomnomnom_servers.first) | |
end | |
unless Chef::Config.report_handlers.any? { |h| h === NomNomNom::StatusHandler } | |
Chef::Config.exception_handlers << NomNomNom::StatusHandler.new(nomnomnom_servers.first) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment