Rubyzip installation error


#1

I am using zipfile cookbook to unzip a package on Windows 2012 R2.
I execute the cookbook through Jenkins while bootstrapping the node itself.
Post bootstrapping, when the cookbook is about to start executing, it is trying to install rubyzip on the node and throws error " failed to allocate memory".

Below is the error that I am coming across

[2017-02-03T08:31:56+00:00] INFO: Processing chef_gem[rubyzip] action install (c:/chef/cache/cookbooks/zipfile/providers/default.rb line 22)
[FATAL] failed to allocate memory
+ CategoryInfo : NotSpecified: ([FATAL] failed to allocate memory
:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : {IP Address}

Please help me in resolving this issue.


#2

I use chocolatey to install 7-zip, then the seven_zip cookbook, available via the surpermarket (Needs a depends in the metadata of what ever cookbook you call/create with this in it).

Here is the basics of what I have done in the past (Sorry i can’t help to much with your error, hence this workaround).

# Make sure chocolatey is installed
include_recipe 'chocolatey'

# Install 7zip
chocolatey '7zip' do
  action :install
end

# Extract the archive in preparation for what ever. Change the options as you see fit!
# There is a not_if statement at the end - You will also need to change this to suit your requirementsor the bloack won't run
seven_zip_archive 'oracle_rdbms_installer' do
  path 'c:\applications'
  source 'c:\applications\oracle12c_winx64.zip'
  action :extract
  not_if { ::File.directory?('C:\applications\oracle12c_winx64') == true }
end

this should achieve some similar end results based on what I assume you are trying to achieve.

Good luck!


#3

You can also use PowerShell and .NET (both already on Server 2012) to handle your ZIP files so you don’t have to rely on any external zip cookbook or rubyzip. If you have PowerShell 5.0 on Server 2012 (PS 4.0 is the default) then you can use PS 5’s native zip cmdlets, otherwise use .NET to handle the un-zipping.

Here is an example of what we use:

powershell_script 'Unzip file' do
  code '
    $ZipFile = <path to zip>
    $OutFolder = <path to output folder>
    If ($host.version.major -ge "5")
    {
      Expand-Archive -Path $ZipFile -DestinationPath $OutFolder -Force
    }
    ElseIf ($host.version.major -ge "3") 
    {
      Add-Type -AssemblyName System.IO.Compression.FileSystem
      $ZipFile = GCI ./*.zip
      [System.IO.Compression.ZipFile]::ExtractToDirectory($ZipFile, $OutFolder)
    }
  '
end

Hope this helps.