Ramu
Ramu

Reputation: 111

Chef recipe to unzip a file

I'm looking for Chef recipe to unzip a file which I downloaded to a Windows 2012 EC2 instance. I'm using the below one. The Zip file (Try.Zip) is saved in C:\data directory and I wish to unzip it to the same folder.

zipfile 'C:\data\Try.zip' do into 'C:\data\' end

Upvotes: 1

Views: 7331

Answers (3)

Gagan Burde
Gagan Burde

Reputation: 328

You can use batch as resource and used to extract file

batch 'extracting any zip' do
  code <<-EOH
  tar -xvf pathofzipfile
  EOH
  action :run
end

Upvotes: 0

Ramu
Ramu

Reputation: 111

I was able to use windows_zipfile command to unzip the file and save in the C:/foldername location using the below Chef resource definition:

windows_zipfile 'C:/foldername' do
   source 'https://location/filename.zip'
   action :unzip
   overwrite true
end

You can find more information about this resource in Chef documentation

Upvotes: 1

Szymon
Szymon

Reputation: 1525

Use the seven_zip cookbook. Example from readme fits your 'issue'.

Upvotes: 0

Related Questions