0

I want to un zip / un tar a file on AIX system using CHEF. Steps i have done : 1.I have uploaded a zip file Test.zip on AIX system using Winscp. 2.Edited the default.rb using below command: execute "extract_Test_tar" do command "tar -xvf Test.zip" cwd "/var/chef/cookbooks" end 3.While uploading my cookbook it is giving me following error:

Recipe: Infy_Patrol::default * execute[extract_Test_tar] action run

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

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of tar -xvf Test.zip ----
STDOUT:
STDERR: tar: tape blocksize error
---- End output of tar -xvf Test.zip ----
Ran tar -xvf Test.zip returned 1

Resource Declaration:
---------------------
# In /.chef/local-mode-cache/cache/cookbooks/Infy_Patrol/recipes/default.rb

 10: execute "extract_Test_tar" do
 11:   command "tar -xvf Test.zip"
 12:   cwd "/var/chef/cookbooks"
 13: end

Compiled Resource:
------------------
# Declared in /.chef/local-mode-cache/cache/cookbooks/Infy_Patrol/recipes/default.rb:10:in `from_file'

execute("extract_Test_tar") do
  action [:run]
  retries 0
  retry_delay 2
  default_guard_interpreter :execute
  command "tar -xvf Test.zip"
  backup 5
  cwd "/var/chef/cookbooks"
  returns 0
  declared_type :execute
  cookbook_name "Infy_Patrol"
  recipe_name "default"
end

Running handlers: [2016-01-29T06:27:47-06:00] ERROR: Running exception handlers Running handlers complete [2016-01-29T06:27:47-06:00] ERROR: Exception handlers complete Chef Client failed. 0 resources updated in 05 seconds [2016-01-29T06:27:47-06:00] FATAL: Stacktrace dumped to /.chef/local-mode-cache/cache/chef-stacktrace.out [2016-01-29T06:27:47-06:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report [2016-01-29T06:27:47-06:00] ERROR: execute[extract_Test_tar] (Infy_Patrol::default line 10) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'

1 Answers1

-1

REPHRASING MY QUESTION.

Below are the steps I followed : 1.Logged into my AIX machine.2.Logged into Winscp. 3.created a cookbook using : knife cookbook create Test 4.Using winscp i went to the path where my cookbook is saved: /var/chef/cookbooks/Test 5.Opened recipes folder: and edited default.rb as given:

#
# Cookbook Name:: Infy_Patrol
# Recipe:: default
#
# Copyright 2016, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#

tar_extract '/var/chef/cookbooks/Test.zip' do
  action :extract_local
  target_dir '/var/chef/cookbooks'
  creates '/var/chef/cookbooks/new'
end

#Also tried the following piece of code
#execute "extract files" do
#command "tar xvf Test.tar.gz -C /var/chef/cookbooks"
#end

6.uploaded cookbook using : 
chef-client -z -r Test::default

BUT IT IS GIVING ME AN ERROR :
Error executing action `run` on resource 'execute[extract_Test_tar]
  • You might have misunderstood what word 'question' means. Examples: **Q:** How can I extract a ZIP-achive? **A:** With utility program _unzip._ **Q:** Can I use _tar_ to do this? **A:** No. **Q:** So _tar_ and _zip/unzip_ are different programs? **Q:** Yes. – Zsigmond Lőrinczy Jan 29 '16 at 17:51
  • Try to extract manually and path should be have same user privilege. ex: tar xvf Test.tar.gz -C /home/user/test – Shankar Mar 14 '17 at 09:52