Skip to content

Instantly share code, notes, and snippets.

@yvovandoorn
Last active December 16, 2015 02:59
Show Gist options
  • Save yvovandoorn/5366111 to your computer and use it in GitHub Desktop.
Save yvovandoorn/5366111 to your computer and use it in GitHub Desktop.
When the file / template has a hardcoded path defined (either set via node attribute or hard coded as in the example), specifically when a colon (:) is present, the notifies parameter does not work.

Works:

script

service "Apache2.2" do
  action :nothing
end

file "./blah" do
  action :create
  notifies :restart, "service[Apache2.2]", :immediate
 end
 
 ruby_block "debug_resource" do
 block do
    puts "Updated #{resources("file[./blah]")}: #{resources("file[./blah]").updated}"
  end
end

output

Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * service[Apache2.2] action nothing (up to date)
  * file[./blah] action create
    - create new file ./blah
        (no diff)
  * service[Apache2.2] action restart
    - restart service service[Apache2.2]
  * ruby_block[debug_resource] action runUpdated file[./blah]: true

    - execute the ruby block debug_resource

Does not work

script

service "Apache2.2" do
  action :nothing
end

file "C:\\blah" do
  action :create
  notifies :restart, "service[Apache2.2]", :immediate
 end
 
 ruby_block "debug_resource" do
 block do
    puts "Updated #{resources("file[C:\\blah]")}: #{resources("file[C:\\blah]").updated}"
  end
end

output:

PS C:\chef\cache> chef-apply.bat .\doesnotwork.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * service[Apache2.2] action nothing (up to date)
  * file[C:\blah] action create
    - create new file C:/blah
        (no diff)
  * ruby_block[debug_resource] action runUpdated file[C:/blah]: true

    - execute the ruby block debug_resource
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment