[英]How do I copy all files that end with .txt from cookbook to node on chef?
I have a chef cookbook that has a bunch of files that end in ".txt" in my /files/default folder.我有一本厨师食谱,在我的 /files/default 文件夹中有一堆以“.txt”结尾的文件。 How can I add to my chef recipe a way to move all files that end in ".txt" from my files directory to a specific directory on my node?如何在我的厨师食谱中添加一种将所有以“.txt”结尾的文件从我的文件目录移动到我节点上的特定目录的方法?
Here is what I have:这是我所拥有的:
remote_directory "/opt/info" do
source [/*.txt/]
owner 'root'
group 'root'
mode '0640'
end
The source
property of remote_directory
resource takes a directory name in files/default
of the cookbook, and not files. remote_directory
资源的source
属性在菜谱的files/default
中采用目录名称,而不是 files。
So you should move your *.txt
files to files/default/info
.因此,您应该将*.txt
文件移动到files/default/info
。 Example contents:示例内容:
file1.txt
file2.txt
file3.txt
file4.txt
file5.txt
file6.txt
Then in your recipe specify the info
directory in which *.txt
files are present:然后在您的配方中指定存在*.txt
文件的info
目录:
remote_directory '/opt/info' do
source 'info'
owner 'root'
group 'root'
mode '0640'
end
This will copy all files from files/default/info
of your cookbook to /opt/info
on the node.这会将所有文件从您的说明书的files/default/info
复制到节点上的/opt/info
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.