Resource "mv" in the chef

When I execute the following recipe, I get an error message. My requirement: I need to "move" only certain folders (log, tmp) from the source to another place, only if the folders are available in the source, if there is no need to move and successfully execute my resource. whenever I start the first resource with the source folders (log, tmp), it will succeed, but when the second resource is started the second time, it gives an error message because there are no folders (log, tmp) in the source. I need to successfully execute even folders (log tmp) that are not in the source. can you share yours, although by this requirement?

Below is my resource:

execute "move files" do command "mv #{node["source"]}/log tmp #{node["dest"]}" cwd node["direct"] only_if do File.exist?(node['source']) end end 

Error message:

mv: cannot stat âlogâ: no such file or directory

mv: can't stat âtmpâ: No such file or directory

0
chef
Aug 23 '16 at 16:04
source share
1 answer

Moving a file is not a converged operation in the general sense, so this is not recommended. The best approach would be to use the link resource to create symbolic links, or simply to deploy things in the format they should already be (but this may require changes on the assembly side).

+1
Aug 23 '16 at 18:09
source share



All Articles