Chef recipe order of execution

chef

I'm writing a recipe that compiles and installs an application from source but also changes configuration files in directories that get created when the application finishes installing. The recipe looks something like this:

bash "install inspircd from source" do
  ...
  code <<-EOH
    ....
    make && \
    make install
  EOH
end

...

# Copy over the configuration template
template "<config dir>/inspircd.conf" do
  source "inspircd.conf.erb"
  ....
end

Based on the docs, "Resources are executed in the order they appear". But it doesn't seem that Chef is executing this in the order they appear because it tries to put the template file into a directory that only gets created after the make install finishes.

Is Chef executing the recipe in parallel? Is there a way to block execution until the bash command finishes? Any help would be appreciated. Thank you.

Best Answer

It should be running in sequence. If you're getting that error, I think you may be having an issue in the bash block.

In any case, you can do a "only_if" in the template. Something like:

template "<config dir>/inspircd.conf" do
  source "inspircd.conf.erb"
  ....
  only_if "test -d <config dir>" 
end

http://wiki.opscode.com/display/chef/Resources#Resources-ConditionalExecution