Reputation: 1924
I have this run list: recipe-A, my-recipe
.
recipe-A
creates /etc/A
directory.
my-recipe
has these codes:
...
// create '/etc/A/file-1'
...
File.symlink('/etc/A/file-1', '/etc/A/file-2')
...
So, when my-recipe
runs, there should be /etc/A
directory already, which was created by recipe-A
. But I got this error at very first of the chef run:
================================================================================
Recipe Compile Error in ...
================================================================================
Errno::ENOENT
-------------
No such file or directory - (/etc/A/file-1, /etc/A/file-2)
I am sure that recipe-A
has not been run when this error message is shown up. But isn't it supposed for recipe-A
to run first? Why is Chef checking the existence of /etc/A
, which is created by recipe-A
while it has not been run? How can I solve this?
Upvotes: 0
Views: 262
Reputation: 37580
Don't run it as ruby code, use the link resource to create the symlink.
link "/etc/A/file-2" do
to "/etc/A/file-1"
end
I'm pretty sure that your Ruby code is already executed during the compilation phase of the chef run, that's why the code from the second recipe seems to be executed first.
Upvotes: 1