小编Dan*_*aum的帖子

执行 redux 的 Chef 配方顺序

鉴于以下配方:

ruby_block "block1" do
    block do
        puts "in block1"
    end
    action :create
end


remote_file "/tmp/foo" do
    puts "in remote_file"
    source "https://yahoo.com"
end
Run Code Online (Sandbox Code Playgroud)

我希望 ruby​​_block 首先运行(因为它首先出现)然后是 remote_file。

我想使用 ruby​​_block 来确定要下载的 remote_file 的 URL,因此顺序很重要。

如果不是我的 puts() 语句,我会假设这些语句按预期顺序运行,因为日志说:

==> default: [2014-06-12T17:49:19+00:00] INFO: ruby_block[block1] called
==> default: [2014-06-12T17:49:19+00:00] INFO: remote_file[/tmp/foo] created file /tmp/foo
==> default: [2014-06-12T17:49:20+00:00] INFO: remote_file[/tmp/foo] updated file contents /tmp/foo
Run Code Online (Sandbox Code Playgroud)

但除此之外,我的 puts() 语句如下:

==> default: in remote_file
==> default: in block1
Run Code Online (Sandbox Code Playgroud)

如果您认为资源按预期顺序运行,请考虑以下方法:

ruby_block "block1" do
    block do
        node.default['test'] = {}
        node.default['test']['foo'] ='https://google.com' …
Run Code Online (Sandbox Code Playgroud)

chef

11
推荐指数
2
解决办法
1万
查看次数

标签 统计

chef ×1