“mv” resource in chef

不羁的心 提交于 2020-01-16 12:04:32

问题


when am executing the below recipe am getting the error message. My requirement is I need to "Move" only certain folders(log,tmp)from source to some other location only whenever folders are available in source, if not no need to move and successfully execute my resource. whenever am executing the below resource first time with source folders(log,tmp) it will execute successfully but when to run the same resource second time it throws error message because there are no folders(log,tmp) in source. I need to successfully execute even folders(log tmp) are not present in the source. can you share yours though on 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: cannot stat âtmpâ: No such file or directory


回答1:


Moving a file is not a convergent operation in the general sense so this is not recommended. A better approach would be using a link resource to create symlinks, or just deploying things in the format they should already be in (but that might require changes on the build side).



来源:https://stackoverflow.com/questions/39105976/mv-resource-in-chef

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!