文件中的 Chef 属性
Chef attributes in files
我在
下有一个文件
cookbooks/recipe/files/default/file
我需要在其中添加默认属性 <%= node['hostname'] %>
。
我知道我可以将文件放在 templates/
下面,但我需要它放在 files/
下面。
我让上面定义的属性起作用,Chef 没有解析它看起来像的文件。由于在节点上,文件以原始文本形式出现。
如何解决?由于相同的变量适用于 templates/
下的文件,有什么区别?
tl;dr 你不能。
不同的正是你遇到的。 cookbook_file
resource copies the original file from the cookbook, while the template
passes it through the Erubis 模板引擎。
您不能使用 file
资源来做到这一点。只需使用 template
资源(并将其移至 templates/
)。当您决定必须使文件参数化时,此过程是完全正常的。我不相信你的论点"I need it to be under files/
"。动一下就可以了
我在
下有一个文件cookbooks/recipe/files/default/file
我需要在其中添加默认属性 <%= node['hostname'] %>
。
我知道我可以将文件放在 templates/
下面,但我需要它放在 files/
下面。
我让上面定义的属性起作用,Chef 没有解析它看起来像的文件。由于在节点上,文件以原始文本形式出现。
如何解决?由于相同的变量适用于 templates/
下的文件,有什么区别?
tl;dr 你不能。
不同的正是你遇到的。 cookbook_file
resource copies the original file from the cookbook, while the template
passes it through the Erubis 模板引擎。
您不能使用 file
资源来做到这一点。只需使用 template
资源(并将其移至 templates/
)。当您决定必须使文件参数化时,此过程是完全正常的。我不相信你的论点"I need it to be under files/
"。动一下就可以了