You should get acquainted with the anatomy of a chef . It has 2 stages: compilation and execution.
No action is taken in the recipe resources at the compilation stage - each resource being evaluated is just taken and placed in the Resource Collection . However, only regular Ruby code outside of resources is evaluated.
At the execution stage, he actually evaluates the collection of resources . But by this time all your registration messages have already been printed.
If you need to run ruby ββcode (including Chef logging) at runtime, there is a special Ruby Block resource for it
ruby_block "Add logging step3" do block do Chef::Log.info('step3') end action :create end
Another way could be: actually start the resource at the compilation stage:
bash "do_wget" do code "wget somefile" action :nothing end.run_action :run
Action: nothing is set so as not to run this resource twice (once at each stage).
Draco ater
source share