Search code examples
chef-infra7zipcookbook

How to resolve error with 7zip not getting installed using chef-client version 14.6.47


I am getting below error

Recipe: 7zip::default[0m
amazon-ebs:   * windows_zipfile[c:/dirname/] action unzip
amazon-ebs:     [0m
amazon-ebs:     ================================================================================[0m
amazon-ebs:     [31mError executing action `unzip` on resource 'windows_zipfile[c:/dirname/]'[0m
amazon-ebs:     ================================================================================[0m
amazon-ebs:
amazon-ebs: [0m    NameError[0m
amazon-ebs:     ---------[0m
amazon-ebs:     undefined local variable or method `source' for #<#<Class:0x0000000003f01f60>:0x0000000006da13c0>[0m

and below is my code related 7zip cookbook recipe.

windows_zipfile 'c:/dirname/' do
  source "#{node[:packages][:ziputil]}"
  action :unzip
  not_if {::File.exists?('c:/dirname/7za.exe')}
end

and source URI is: http://downloads.sourceforge.net/sevenzip/7za920.zip

I have tried updating the the chef-client version to versions like 14.2.0 & 15.1.36 but that didn't helped?

Can someone please suggest? Do we need to update something else?


Solution

  • The windows_zipfile resource seems to come from the windows cookbook from Supermarket. This seems to be deprecated. Since you are now on chef-client > 15, you can use archive_file resource. Something like below should work:

    remote_file 'C:/Users/Public/7za920.zip' do
      source 'http://downloads.sourceforge.net/sevenzip/7za920.zip'
      action :create
    end
    
    archive_file 'C:/Users/Public/7za920.zip' do
      destination 'C:/Users/Public/7zip'
      action :extract
    end
    

    You can replace the path and attributes as per your requirement.

    There is also a windows_package resource which can directly install an MSI, which can be downloaded from https://www.7-zip.org/download.html.