Chef infra Chef在成功运行时执行资源错误

Chef infra Chef在成功运行时执行资源错误,chef-infra,Chef Infra,我正在尝试使用Chef execute资源解压文件 execute "unzipping_webapp" do cwd "#{node[:config][:repo_dir]}" command <<-EOF unzip -o #{node[:config][:webapp_name]} EOF end 我得到了一个错误,就像 ====================================================================

我正在尝试使用Chef execute资源解压文件

execute "unzipping_webapp" do
  cwd "#{node[:config][:repo_dir]}"
  command <<-EOF
    unzip -o #{node[:config][:webapp_name]}
  EOF
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
当我检查系统时,文件已成功解压缩

我不明白为什么我的厨师运行失败,而事情是正确的执行


以前是否有人遇到过此问题或有解决方案?

问题不在于Chef,而是unzip返回了一个非零的退出代码,可能是因为zipfile中的条目格式错误。您可以试试这本食谱,看看效果是否更好。

当我尝试使用命令行直接在实例上解压时,效果很好。当我用chef运行它时,它失败了。当你说“工作正常”时,你真的在检查
$?
以确保它为0吗?是的,你是对的。它给出1。此外,poise archive cookbook也完成了这项工作。谢谢所以有两种方法可以解决这个问题。一个是使用第三方cookbook解压,另一个是在chef的execute资源中,我可以添加0,1作为值的returns属性。1在成功运行但出现一些警告时使用。用于诊断解压输出,或者您可以修复zip文件以不生成警告:)
================================================================================
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