lib/chef/handler/status_notifier.rb in chef-handler-status_notifier-0.4.0 vs lib/chef/handler/status_notifier.rb in chef-handler-status_notifier-0.4.2
- old
+ new
@@ -30,41 +30,41 @@
else
msg = "Chef run succesfully on #{node.name}"
status = :success
end
- send_to_slack(status, msg)
+ send_to_slack(node.name, status, msg)
send_to_hipchat(msg)
end
private
def send_to_hipchat(msg)
return unless @hipchat_params[:enabled]
hipchat[@hipchat_params[:room_name]].send(@hipchat_params[:username], msg, :notify => @hipchat_params[:notify])
end
- def send_to_slack(status, msg)
+ def send_to_slack(node_name, status, msg)
return unless @slack_params[:enabled]
slack.channel = @slack_params[:channel]
slack.username = @slack_params[:username]
- slack.ping '', attachments: [slack_attachment(status, msg)]
+ slack.ping '', attachments: [slack_attachment(node_name, status, msg)]
end
def hipchat
@hipchat ||= HipChat::Client.new(@hipchat_params[:api_token])
end
def slack
@slack ||= Slack::Notifier.new(@slack_params[:webhook_url])
end
- def slack_attachment(status, msg)
+ def slack_attachment(node_name, status, msg)
color = (status == :failed)? "#ff0000" : "#36a64f"
{
fallback: "Opsworks status, #{msg}",
color: "#{color}",
- author_name: "OpsworksBot (",
+ author_name: "OpsworksBot (#{node_name})",
title: "status: #{status}",
text: "#{msg}"
}
end
end