directory resource does not create directory

Posted by Dan Tenenbaum on Stack Overflow See other posts from Stack Overflow or by Dan Tenenbaum
Published on 2014-06-12T03:21:28Z Indexed on 2014/06/12 3:24 UTC
Read the original article Hit count: 223

Filed under:
|
|
|

I have a Vagrantfile that provisions a VM by running a chef recipe. The first resource in the chef recipe is:

directory "/downloads" do
  owner "root"
  group "root"
  mode "0755"
  action :create
end

# check that it worked:
raise "/downloads doesn't exist!" unless File.exists? "/downloads"

When I run this at work, it works fine.

When I run it at home, it fails, the exception is raised when I check to see if /downloads exists.

I'm not sure why this is happening. I would expect it to behave identically, since the underlying Vagrant box is the same both at work and at home. I am a chef newb so perhaps there is something I am not understanding about the order in which the resources are run within my recipe? I would expect them to run in sequential order...

I also tried putting a notifies call inside the directory block, where I call another execute block :immediately. That works, but inside the second execute block I test to see whether /downloads has been created and it hasn't.

Clearly I'm missing something very basic.

© Stack Overflow or respective owner

Related posts about resources

Related posts about vagrant