成功运行时,Chef执行资源错误

时间:2016-12-01 03:07:23

标签: chef

我正在尝试使用Chef execute resource

解压缩文件
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 个答案:

答案 0 :(得分:1)

问题不在于Chef,而是unzip返回非零退出代码,可能是因为zipfile中的条目格式错误。您可以尝试poise-archive食谱,看看它是否有效。