我使用的是Chef托管服务器、工作站和节点,并在节点上运行cookbook安装Java、更新hosts文件。我在网站上找不到解压tar文件的参考资料。能否请你在这里帮助我,或者直接到一些有信息的网站。
先谢谢你。
其实Chef里并没有内置解压tar文件的功能。你有两个选择,要么你可以使用 执行 资源来掏钱解焦,或者使用一些社区的烹饪书,如 焦油烹饪书 该 为提取焦油定义的自定义资源.
其中 execute
资源的例子,它可能看起来像
execute 'extract_some_tar' do
command 'tar xzvf somefile.tar.gz'
cwd '/directory/of/tar/here'
not_if { File.exists?("/file/contained/in/tar/here") }
end
而第三方焦油烹饪书绝对 读起来更顺口
tar_package 'http://pgfoundry.org/frs/download.php/1446/pgpool-3.4.1.tar.gz' do
prefix '/usr/local'
creates '/usr/local/bin/pgpool'
end
从Chef Client 15.0开始,有一个 archive_file
资源内置。它支持tar、gzip、bzip和zip。
archive_file 'Precompiled.zip' do
path '/tmp/Precompiled.zip'
destination '/srv/files'
end