3

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.

  • Would you post the relevant log messages? – gWaldo Jan 17 '12 at 15:57
  • Turned out that it was probably an issue with the bash block, it all works now. – Arthur Maltson Jan 18 '12 at 20:02
2

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

  • Thanks @cjc, I think you are right, I probably did have an error in my bash block. I reran it on another server and everything executed in order. The only_if is a good test though, thanks! – Arthur Maltson Jan 18 '12 at 20:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.