2016-12-01 70 views
1

我试图用厨师执行资源厨师执行资源的错误,同时运行成功

execute "unzipping_webapp" do 
    cwd "#{node[:config][:repo_dir]}" 
    command <<-EOF 
    unzip -o #{node[:config][:webapp_name]} 
    EOF 
end 

要解压的文件也试过

execute "unzipping webapp" do 
    command "unzip -o #{node[:config][:webapp_name]}" 
    cwd "#{node[:config][:repo_dir]}" 
end 

我得到了如下的错误

================================================================================ 
Error executing action `run` on resource 'execute[unzipping_webapp]' 
================================================================================ 

Mixlib::ShellOut::ShellCommandFailed 
------------------------------------ 
Expected process to exit with [0], but received '1' 
---- Begin output of  unzip -o webapp.zip 
---- 
STDOUT: Archive: webapp.zip 
warning: skipped "../" path component(s) in ../webapp/ 
creating: webapp/ 
warning: skipped "../" path component(s) in ../webapp/bower.json 
inflating: webapp/bower.json  
warning: skipped "../" path component(s) in ../webapp/bower_components/ 
creating: webapp/bower_components/ 
warning: skipped "../" path component(s) in ../webapp/bower_components/bootstrap/.bower.json 
inflating: webapp/bower_components/bootstrap/.bower.json 
warning: skipped "../" path component(s) in ../webapp/bower_components/bootstrap/bower.json 
inflating: webapp/bower_components/bootstrap/bower.json 
. 
.More files 
. 
warning: skipped "../" path component(s) in ../webapp/js/ 
creating: webapp/js/ 
warning: skipped "../" path component(s) in ../webapp/js/app.js 
extracting: webapp/js/app.js 
STDERR: 
---- End output of  unzip -o webapp.zip 
---- 
Ran   unzip -o webapp.zip 
returned 1 

当我检查系统时,文件已成功解压缩。

我不明白为什么我的厨师运行失败,而正确执行的东西。

有没有人遇到过这个问题或有解决办法吗?

回答

1

这个问题与Chef不一样,它是unzip返回一个非零的退出代码,可能是因为zipfile中的格式不正确。你可以试试poise-archive食谱,看看它是否更好。

+0

当我试图使用命令行直接解压缩实例时,它工作正常。当我与厨师一起运行时,它是失败的 –

+0

当你说“工作正常”时,你是否真的在检查'$?'以确保它是0? – coderanger

+0

是的,你是对的。它给出了1.还有poise-archive食谱做的工作。谢谢 ! –

相关问题