Cony
Cony

Reputation: 223

Chef use "cookbook_file" as source for "windows_zipfile" resource

I'm trying to use windows_zipfile resource from the "windows" cookbook, but the file i need to unzip is located at files/default in the cookbook I'm running.

Normally I would access this file using the "cookbook_file" resource, how can I get to it with windows_zipfile resource?

I've tried:

windows_zipfile 'c:\test_app' do
    source 'files/default/test_app.zip'
    action :unzip
end

and got "File files\default\test_zpp.zip not found"

Upvotes: 3

Views: 4019

Answers (1)

Dan Stark
Dan Stark

Reputation: 806

You need to create the file locally, then run your windows_zipfile resource. You're trying to unzip a file inside your repo, not on your node. The source here is the file on the local filesystem.

cookbook_file 'c:/testapp.zip' do
  source 'files/default/test_app.zip'
end

windows_zipfile 'c:/test_app' do
  source 'c:/testapp.zip'
  action :unzip
  not_if {::File.exists?('c:/test_app')}
end

^Also, make sure you include a not_if guard to protect idempotence (so that each Chef run won't try to unzip).

This is mentioned in the windows cookbook.

Upvotes: 2

Related Questions