Creating dynamic resource in cookbook
Posted
by
zsong
on Stack Overflow
See other posts from Stack Overflow
or by zsong
Published on 2014-08-21T14:53:14Z
Indexed on
2014/08/21
16:20 UTC
Read the original article
Hit count: 206
Long story short, here is my code:
template "...." do
....
notifies :restart,"service[myservice_One]"
notifies :restart,"service[myservice_Two]"
end
['One', 'Two'].each do |proj|
service 'myservice_#{proj}' do
start_command "setsid /etc/init.d/my_command #{proj} start"
stop_command "setsid /etc/init.d/my_command #{proj} stop"
restart_command "setsid /etc/init.d/my_command #{proj} restart"
status_command "setsid /etc/init.d/my_command #{proj} status"
supports :status => true, :restart => true
action [:enable,:start]
end
end
I got this error:
template[...] is configured to notify resource service[celery_worker_One] with action restart, but service[celery_worker_One] cannot be found in the resource collection.
I know I can duplicate my code to make it work but how to dynamically create the services?
Thanks!
© Stack Overflow or respective owner