Skip to content

Commit

Permalink
fix provider updated_by_last_action return value
Browse files Browse the repository at this point in the history
  • Loading branch information
phlipper committed Feb 5, 2015
1 parent b2824ae commit 9b641bd
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions providers/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,29 @@ def whyrun_supported?

action :add do
Chef::Log.debug "Adding monitoring for #{new_resource.name}"
template "/etc/dd-agent/conf.d/#{new_resource.name}.yaml" do

t = template "/etc/dd-agent/conf.d/#{new_resource.name}.yaml" do
owner 'dd-agent'
mode 00600
mode '0600'
variables(
:init_config => new_resource.init_config,
:instances => new_resource.instances
init_config: new_resource.init_config,
instances: new_resource.instances
)
notifies :restart, 'service[datadog-agent]', :delayed
notifies :restart, 'service[datadog-agent]'
end
new_resource.updated_by_last_action(false)

new_resource.updated_by_last_action(t.updated_by_last_action?)
end

action :remove do
if ::File.exist?("/etc/dd-agent/conf.d/#{new_resource.name}.yaml")
Chef::Log.debug "Removing #{new_resource.name} from /etc/dd-agent/conf.d/"
file "/etc/dd-agent/conf.d/#{new_resource.name}.yaml" do
action :delete
notifies :restart, 'service[datadog-agent]', :delayed
end
new_resource.updated_by_last_action(true)
return unless ::File.exist?("/etc/dd-agent/conf.d/#{new_resource.name}.yaml")

Chef::Log.debug "Removing #{new_resource.name} from /etc/dd-agent/conf.d/"

f = file "/etc/dd-agent/conf.d/#{new_resource.name}.yaml" do
action :delete
notifies :restart, 'service[datadog-agent]'
end

new_resource.updated_by_last_action(f.updated_by_last_action?)
end

0 comments on commit 9b641bd

Please sign in to comment.