I have a directory structure (sample data) that I want to copy from within a Chef recipe. It seems the only way to do this is to explicitly create each individual directory and file:
directory "/mnt/data/experiment1/dataset1" do
recursive true
only_if { node.chef_environment == "dev" }
end
directory "/mnt/data/experiment1/dataset2" do
recursive true
only_if { node.chef_environment == "dev" }
end
directory "/mnt/data/experiment2/dataset1" do
recursive true
only_if { node.chef_environment == "dev" }
end
directory "/mnt/data/experiment1/dataset2" do
recursive true
only_if { node.chef_environment == "dev" }
end
cookbook_file "/mnt/data/experiment1/dataset1/testfile1.txt" do
owner "atom"
group "atom"
mode "0644"
source "sampledata/experiment1/dataset1/testfile1.txt"
only_if { node.chef_environment == "dev"}
end
...
Is there a way to simply recursively copy an entire directory structure from the cookbook? Specifying the name of each file inside the recipe seems redundant and error-prone (ie, if we add a file to the tree but forget to reference it in the recipe, it won't be copied.)
I guess a hack workaround would be to work out where all the chef files get copied to on the target machine and do a cp -r
but is there something cleaner?
Or am I going about this the wrong way?