chef receipe notify problem
Hi,
I try to create a receipt which updates a configuration file in the deployed apps and, if the configuration was changed clears the caches folders of the app.
I found some code at http://wiki.opscode.com/display/chef/Resources#Resources-Notifications
template "/etc/nagios3/configures-nagios.conf" do
# other parameters
notifies :run, "execute[test-nagios-config]", :immediately
end
# this will fail and prevent us from restarting nagios if we broke the config
execute "test-nagios-config" do
command "nagios3 --verify-config"
action :nothing
end
This is my code:
node[:deploy].each do |application, deploy|
template "#{deploy[:deploy_to]}/current/app/config/parameters.ini" do
source "parameters.ini.erb"
mode "0660"
group deploy[:group]
owner deploy[:user]
variables(:database => deploy[:database])
only_if do
File.directory?("#{deploy[:deploy_to]}/current/app/config")
end
notifies :run, "execute[clear_cache]"
end
execute "clear_cache" do
command "rm -rf #{deploy[:deploy_to]}/current/app/cache/*"
action :nothing
end
end
and the error is:
DEBUG: Re-raising exception: NoMethodError - undefined method `run_action' for "execute[clear_cache]":String
Sorry, I've not done much with ruby, yet :)
Thanks for your help.
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Jonathan Weiss on 05 Aug, 2011 11:29 AM
Can you try
instead of
Also, I would make sure, that the resource is unique per app, e.g:
3 Posted by dafire on 05 Aug, 2011 11:53 AM
Ok .. it failed now because it won't find the execute action but after I put the execute block above the template block it works now.
Thanks for your help and the hint with the unique identifier.
Support Staff 4 Posted by Jonathan Weiss on 05 Aug, 2011 11:56 AM
no problem, if you encounter any other issues, don't hesitate to ask.
Jonathan Weiss closed this discussion on 05 Aug, 2011 11:56 AM.