如何使用Chef在本地移动/复制文件 [英] How to move/copy files locally with Chef
问题描述
我还没有找到可以在本地复制/移动文件的Chef资源。例如,我要下载跳船并解压缩。完成后,将所有文件复制到一个特定的文件夹中,如下所示:
I haven't yet come across a Chef resource that will copy/move files locally. For example, I want to download jetty hightide and unzip it. Once done, copy all the files into a particular folder, like this:
# mv /var/tmp/jetty-hightide-7.4.5.v20110725/* /opt/jetty/
BTW,解压缩时jettyhightide给您一个文件夹中,其余文件位于该文件夹中。因此,解压缩jetty-hightide-7.4.5.v20110725.zip -d / opt / jetty /
是没有用的,因为它将创建目录 / opt / jetty / jetty-hightide-7.4.5.v20110725 / *
而我真正想要的是 / opt / jetty / *
。因此,我正在Chef中寻找本地副本/移动资源。
BTW, jettyhightide when unzipped, gives you a folder and inside that folder rest of the files are located. Hence unzip jetty-hightide-7.4.5.v20110725.zip -d /opt/jetty/
is useless because it will create a directory /opt/jetty/jetty-hightide-7.4.5.v20110725/*
whereas what I really want is /opt/jetty/*
. Hence I am looking for a local copy/move resource in Chef.
推荐答案
我通过使用 bash
资源如下:
bash "install_jettyhightide" do
code <<-EOL
unzip /var/tmp/jetty-hightide-7.4.5.v20110725.zip -d /opt/jetty/
mv /opt/jetty/jetty-hightide-7.4.5.v20110725/* /opt/jetty/
cp /opt/jetty/bin/jetty.sh /etc/init.d/jetty
update-rc.d jetty defaults
EOL
end
但是我真的很希望厨师能做到这一点。在本地复制/移动文件将是系统管理员最需要执行的任务。
But I was really hoping for a chef way of doing it. copying/moving files locally would be the most generic task a sysadmin will need to do.
这篇关于如何使用Chef在本地移动/复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!