ERROR: NoMethodError: undefined method `windows_zipfile'


#1

Hi

I am trying to unzip the directory using below recipe

windows_zipfile 'C:/Software/Hello' do
   source 'C:/Software/Hello.zip'
   action :unzip
end

But I am facing below error:

[2018-08-29T21:41:44-07:00] ERROR: Remote chef-client error follows:
[2018-08-29T21:41:44-07:00] ERROR: NoMethodError: undefined method `windows_zipfile' for cookbook: install_unZIP_Hello, recipe: default :Chef::Recipe
Did you mean?  windows_pagefile

Actually I am successfully able to install 7.zip using below recipe

windows_package '7zip' do
  source 'http://www.7-zip.org/a/7z938-x64.msi'
end

but I don't know, how to use 7zip to extract zip files through a recipe?


#2

You could use the execute resource along with the 7zip command line parameters

https://sevenzip.osdn.jp/chm/cmdline/commands/extract.htm

https://docs.chef.io/resource_execute.html


#3

Once again thanks Larryc


#4

Currently, I do this. It's simple and effective

log 'Fetch binaries from repo - Start'
remote_file "Fetch the zip file" do
  path File.join(node['w2k12_oracleclient_11g'][packageAlias]['oracledir'], node['w2k12_oracleclient_11g'][packageAlias]['zip'])
  source File.join(node['w2k12_oracleclient_11g'][packageAlias]['repo_path'], node['w2k12_oracleclient_11g'][packageAlias]['zip'])
  action :create_if_missing
end
log 'Fetch binaries from repo - End'

log 'Extracting the package - Start'
execute 'Extract the downloaded package' do
  cwd "#{oracle_path}"
  command "tar -xvf #{package_name}"
  action :run
  end
log 'Extracting the package - End'

log 'Delete the zipfile - Start'
execute 'Delete zip file' do 
  cwd "#{oracle_path}"
  command "del /Q #{package_name}"
  action :run
end
log 'Delete the zipfile - End'