我正在使用 Opscode Tomcat 说明书以及我自己创建的说明书。我需要在/etc/default/tomcat{version} 文件的末尾附加一个循环,我已经研究过使用 partials 但我不确定如何通过我自己的 cookbook 应用它(我们公司的政策是创建我们自己的 Recipe ,将外部 Recipe 作为引用)。
我想也许 Template 资源可以做到这一点,但我也被告知 Providers 可能是解决方案。
最佳答案
您可以使用 Chef, Inc. 员工创建的 line
Recipe 来处理较小的文件更改:
https://github.com/someara/line-cookbook
例子:
append_if_no_line "make sure a line is in dangerfile" do
path "/tmp/dangerfile"
line "HI THERE I AM STRING"
end
replace_or_add "spread the love" do
path "/some/file"
pattern "Why hello there.*"
line "Why hello there, you beautiful person, you."
end
delete_lines "remove hash-comments from /some/file" do
path "/some/file"
pattern "^#.*"
end
add_to_list "add entry to a list"
path "/some/file"
pattern "People to call: "
delim [","]
entry "Bobby"
end
关于tomcat - 将文本附加到 tomcat.conf 的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30593380/