“ MV”厨师资源 [英] "mv" resource in chef

查看:90
本文介绍了“ MV”厨师资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行以下配方时收到错误消息。我的要求是,仅当源中有可用文件夹时,才需要将某些文件夹(log,tmp)从源移动到其他位置,如果不需要,则无需移动并成功执行我的资源。每当第一次使用源文件夹(log,tmp)执行以下资源时,它将成功执行,但是第二次运行同一资源时,由于源中没有文件夹(log,tmp),它会引发错误消息。即使源中不存在文件夹(log tmp),我也需要成功执行。

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?

以下是我的资源:

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

错误消息:

mv:无法统计âlogâ:没有此类文件或目录

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

mv:无法统计:没有这样的文件或目录

mv: cannot stat âtmpâ: No such file or directory

推荐答案

从一般意义上说,移动文件不是收敛的操作,因此不建议这样做。更好的方法是使用 link 资源创建符号链接,或仅以应有的格式部署事物(但这可能需要在构建方面进行更改)。

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).

这篇关于“ MV”厨师资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆