Reputation: 125
I am trying to unzip a file using Chef execute resource
execute "unzipping_webapp" do
cwd "#{node[:config][:repo_dir]}"
command <<-EOF
unzip -o #{node[:config][:webapp_name]}
EOF
end
Also tried
execute "unzipping webapp" do
command "unzip -o #{node[:config][:webapp_name]}"
cwd "#{node[:config][:repo_dir]}"
end
I am getting an error like
================================================================================
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
When I am checking the system the file has been unzipped successfully.
I don't understand why my chef run is failing while things are executed correctly.
Has anyone faced this issue before or has a solution to it ?
Upvotes: 1
Views: 338
Reputation: 54249
The issue isn't with Chef, it is that unzip is returning a non-zero exit code, probably because of a malformed entry in the zipfile. You can try the poise-archive cookbook and see if that works any better.
Upvotes: 1