我可以从 Chef Recipe 中添加单个文件:
cookbook_file '/tmp/File1' do
source 'default/File1'
owner 'jenkins'
group 'jenkins'
mode '0755'
end
如何使用 for
循环添加 File1
、File2
、File3
?
我浏览了 Chef 文档,很无助且令人困惑。
最佳答案
这就是您可以只使用 Ruby 代码的地方(这可能就是 Chef 文档没有对此进行过多介绍的原因):
['File1', 'File2', 'File3'].each do |file|
cookbook_file "/tmp/#{file}" do
source "default/#{file}"
owner 'jenkins'
group 'jenkins'
mode '0755'
end
end
关于chef-infra - 如何将cookbook_file资源放入for循环中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37073250/