Class: RunData

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = defaults) ⇒ RunData

Returns a new instance of RunData.



29
30
31
# File 'lib/chef-handler-run-data.rb', line 29

def initialize(options = defaults)
  @path = options[:path]
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#defaultsObject



33
34
35
36
# File 'lib/chef-handler-run-data.rb', line 33

def defaults
  return {
    :path => Chef::Config[:file_cache_path] }
end

#reportObject



38
39
40
41
42
43
44
45
# File 'lib/chef-handler-run-data.rb', line 38

def report
  if run_status.success?
    Chef::Log.info "Writing node information to #{@path}/successful-run-data.json"
    Chef::FileCache.store('successful-run-data.json', Chef::JSONCompat.to_json_pretty(data), 0640)
  else
    Chef::Log.error 'Chef run was not successful! Cancelling successful run data write'
  end
end