def run_action(action)
Chef::Log.info("Processing #{self} action #{action} (#{defined_at})")
updated_by_last_action(false)
begin
if only_if
unless Chef::Mixin::Command.only_if(only_if, only_if_args)
Chef::Log.debug("Skipping #{self} due to only_if")
return
end
end
if not_if
unless Chef::Mixin::Command.not_if(not_if, not_if_args)
Chef::Log.debug("Skipping #{self} due to not_if")
return
end
end
provider = Chef::Platform.provider_for_resource(self)
provider.load_current_resource
provider.send("action_#{action}")
rescue => e
if ignore_failure
Chef::Log.error("#{self} (#{defined_at}) had an error: #{e.message}")
else
Chef::Log.error("#{self} (#{defined_at}) has had an error")
new_exception = e.exception("#{self} (#{defined_at}) had an error: #{e.message}")
new_exception.set_backtrace(e.backtrace)
raise new_exception
end
end
end