What will i do:
Configure the configuration in the "intermediate" location, if it is a change, a stop notification, file copying, service start.
Something along the line:
service "my_service" do action :nothing end template "/staging/conf1" do [... usual attributes ...] notifies :stop,"service[my_service]",:immediately end template "/staging/conf2" do [... usual attributes ...] notifies :stop,"service[my_service]",:immediately end remote_file "/opt/my_service/etc/conf1" do source "/staging/conf1" notifies :start,"service[my_service]"
My personal taste goes into a cycle on hashes of determining files / templates for this type of parameters with the same resources as:
node['my_namespace']['conf_files']['conf1'] = "template1" node['my_namespace']['conf_files']['conf2'] = "template2"
and then going through
node['my_namespace']['conf_files'].each do |cfgfile,tmplname| template "/staging/#{cfgfile}" do source tmplname notifies :stop,"service[my_service]",:immediately end remote_file "/opt/my_service/etc/#{cfgfile}" do source "/staging/#{cfgfile}" notifies :start,"service[my_service]" end end
For more complex use cases, you can use a hash instead of a single value.
If more than 2 resources are involved (executing certain commands for the conf file to check it before replacing the actual one, etc.), the definition may correspond.
Another may be to do all the intermediate work in load_current_resource LWRP, but I can go too far for the described use case.
source share