Chef infra 如何在chef模板中包含静态文件内容

Chef infra 如何在chef模板中包含静态文件内容,chef-infra,chef-recipe,Chef Infra,Chef Recipe,我有一个模板,它试图包含文件夹中的.conf文件。我的模板abc.conf.erb中有以下行 include /tmp/config.d/*.conf 在/tmp/config.d中,我有多个.conf文件。我想获取目录中所有.conf文件的内容,并在abc.conf文件中包含语句。我也试过了 include=/tmp/config.d/*.conf 当我运行配方时,模板中只写了相同的include。这是配方的源代码 template '/tmp/config.d/abc.conf' do

我有一个模板,它试图包含文件夹中的
.conf
文件。我的模板abc.conf.erb中有以下行

include /tmp/config.d/*.conf
在/tmp/config.d中,我有多个
.conf
文件。我想获取目录中所有.conf文件的内容,并在abc.conf文件中包含语句。我也试过了

include=/tmp/config.d/*.conf
当我运行配方时,模板中只写了相同的include。这是配方的源代码

template '/tmp/config.d/abc.conf' do
  source 'abc.conf.erb'
end

厨师对此没有什么特别的要求。您必须使用普通的Ruby文件API自己构建它。

您可以读取模板文件中该目录中的文件内容,例如:

<% Dir["/tmp/config.d/*.conf"].each do |f| -%>
<%= ::File.read(f) %>
<% end %>

这应该将
config.d
中的所有
.conf
文件内容合并到一个文件中