Class: ChefTimestamp

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ ChefTimestamp

Returns a new instance of ChefTimestamp.



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

def initialize(config = {})
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

Instance Method Details

#reportObject



33
34
35
36
37
38
39
# File 'lib/chef-handler-timestamp.rb', line 33

def report
  if run_status.success?
    time = Time.now.to_i
    Chef::Log.info "Generating new Chef success timestamp with value #{time}"
    ::File.open("#{Chef::Config[:file_cache_path]}/chef-success-timestamp", 'w') {|f| f.puts time}
  end
end