Class: StatusNotifierHandler

Inherits:
Chef::Handler
  • Object
show all
Defined in:
lib/chef/handler/status_notifier.rb

Constant Summary collapse

DEFAULT_FAILED_MESSAGE =
'"Failure on #{node.name}: #{run_status.formatted_exception}"'.freeze
DEFAULT_SUCCESS_MESSAGE =
'"Chef run succesfully on #{node.name}"'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(slack_params, hipchat_params, custom_message_params = {}) ⇒ StatusNotifierHandler

Returns a new instance of StatusNotifierHandler.



15
16
17
18
19
# File 'lib/chef/handler/status_notifier.rb', line 15

def initialize(slack_params, hipchat_params, custom_message_params = {})
  @slack_params   = slack_params
  @hipchat_params = hipchat_params
  @custom_message_params = custom_message_params
end

Instance Method Details

#reportObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/chef/handler/status_notifier.rb', line 21

def report
  if run_status.failed?
    msg = failed_message
    status = :failed
  else
    msg = success_message
    status = :success
  end

  send_to_slack(node.name, status, msg)
  send_to_hipchat(msg)
end