Class: ChefMOTD

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = defaults) ⇒ ChefMOTD

Returns a new instance of ChefMOTD.



29
30
31
32
33
# File 'lib/chef-handler-motd.rb', line 29

def initialize(options = defaults)
  @priority = options[:priority]
  @keep_old_entries = options[:keep_old_entries]
  @failure_message = options[:failure_message]
end

Instance Attribute Details

#keep_old_entriesObject (readonly)

Returns the value of attribute keep_old_entries.



27
28
29
# File 'lib/chef-handler-motd.rb', line 27

def keep_old_entries
  @keep_old_entries
end

#priorityObject (readonly)

Returns the value of attribute priority.



27
28
29
# File 'lib/chef-handler-motd.rb', line 27

def priority
  @priority
end

Instance Method Details

#reportObject



35
36
37
38
39
40
41
42
43
# File 'lib/chef-handler-motd.rb', line 35

def report
  if run_status.success?
    Chef::Log.info 'Updating Chef info in MOTD ...'
    delete_outdated
    write_out(generate_message)
  else
    if @failure_message then write_out(failure_message) end
  end
end