简体   繁体   English

厨师:运行清单中的最后一个配方似乎先运行

[英]Chef: last recipe in run list seems to be run first

I have this run list: recipe-A, my-recipe . 我有这个运行清单: recipe-A, my-recipe

recipe-A creates /etc/A directory. recipe-A创建/etc/A目录。

my-recipe has these codes: my-recipe具有以下代码:

...
// 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 . 因此,当my-recipe运行时,应该已经有/etc/A目录,该目录由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. 当出现此错误消息时,我确定recipe-A尚未运行。 But isn't it supposed for recipe-A to run first? 但是,不是应该首先运行recipe-A吗? Why is Chef checking the existence of /etc/A , which is created by recipe-A while it has not been run? Chef为什么要检查/etc/A的存在,它是由recipe-A在未运行时创建的? How can I solve this? 我该如何解决?

Don't run it as ruby code, use the link resource to create the symlink. 不要将其作为ruby代码运行,请使用链接资源创建符号链接。

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. 我很确定您的Ruby代码已经在Chef运行的编译阶段中执行了,这就是第二个食谱中的代码似乎首先执行的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM