Windows system standard program for unzip-ing archives?


#1

Folks,

So, I’ve been trying to write some cross-platform Chef code for a customer, and one of the things we need to do is to take a zip archive of a package written in Java, and deploy that. The zip archive is completely self-contained, we don’t need to install it as an OS-level package or anything – we just need to un-zip it into an appropriate directory structure, and then run the appropriate included .sh or .BAT files.

This worked fine on RHEL5. But I was astonished to find that there is apparently no standard tool to handle this kind of thing on Win2k3 or Win2k8.

Am I missing something obvious here? I mean, I can install a package easily enough, but this is a … sensitive … customer, and there might have to be a lengthy delay in getting that approved through the change control board.

Any and all ideas or thoughts would be appreciated. Thanks!


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu


#2

Hi brad, I’m on the way to the office holiday party but .net most likely
has an archive class to handle zip, and powershell can use .net classes. I
could swear chefs windows client handles zip via a ruby gem though… Maybe
its in the windows or artifact cookbook. I unzip quite a few things
myself on windows with chef.

-Greg
On Nov 21, 2014 6:54 PM, “Brad Knowles” brad@shub-internet.org wrote:

Folks,

So, I’ve been trying to write some cross-platform Chef code for a
customer, and one of the things we need to do is to take a zip archive of a
package written in Java, and deploy that. The zip archive is completely
self-contained, we don’t need to install it as an OS-level package or
anything – we just need to un-zip it into an appropriate directory
structure, and then run the appropriate included .sh or .BAT files.

This worked fine on RHEL5. But I was astonished to find that there is
apparently no standard tool to handle this kind of thing on Win2k3 or
Win2k8.

Am I missing something obvious here? I mean, I can install a package
easily enough, but this is a … sensitive … customer, and there might
have to be a lengthy delay in getting that approved through the change
control board.

Any and all ideas or thoughts would be appreciated. Thanks!


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu


#3

The windows cookbook has a resource called windows_zipfile that can unzip
files for you. One issue with that is that it downloads external software
called 7zip to do this, so it requires that your nodes have Internet access
at the time the execute a recipe (at least the first time). You can read
about it here:
https://github.com/opscode-cookbooks/windows/blob/master/README.md.

If you’re using PowerShell 4.0 or higher, PowerShell’s DSC feature has an
Archive resource built in which does this and it can be accessed via
Chef’s dsc_script resource. See the reference to “Archive” at
https://docs.getchef.com/resource_dsc_script.html which shows a sample that
unzips a file.

As Greg mentions, .net has some facility to do this, and since you can
access .net assemblies from PowerShell, there is a way to do this via
PowerShell which can easily be accessed from Chef (e.g. the
powershell_script resource).

-Adam

From: Greg Zapp [mailto:greg.zapp@gmail.com]
Sent: Thursday, November 20, 2014 10:10 PM
To: chef@lists.opscode.com
Subject: [chef] Re: Windows system standard program for unzip-ing
archives?

Hi brad, I’m on the way to the office holiday party but .net most likely
has an archive class to handle zip, and powershell can use .net classes. I
could swear chefs windows client handles zip via a ruby gem though… Maybe
its in the windows or artifact cookbook. I unzip quite a few things
myself on windows with chef.

-Greg

On Nov 21, 2014 6:54 PM, “Brad Knowles” brad@shub-internet.org wrote:

Folks,

So, I’ve been trying to write some cross-platform Chef code for a customer,
and one of the things we need to do is to take a zip archive of a package
written in Java, and deploy that. The zip archive is completely
self-contained, we don’t need to install it as an OS-level package or
anything – we just need to un-zip it into an appropriate directory
structure, and then run the appropriate included .sh or .BAT files.

This worked fine on RHEL5. But I was astonished to find that there is
apparently no standard tool to handle this kind of thing on Win2k3 or
Win2k8.

Am I missing something obvious here? I mean, I can install a package
easily enough, but this is a … sensitive … customer, and there might
have to be a lengthy delay in getting that approved through the change
control board.

Any and all ideas or thoughts would be appreciated. Thanks!


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu


#4

Use the DSC Archive. However, You need Powershell 4.0 installed on the boxes to use the dsc_script resource which will work on 2008/2012

The last example shows the code for using Archive via dsc_script. https://docs.getchef.com/resource_dsc_script.html

You will need another option for Windows 2003 servers.

Aloha,
Dylan
On Nov 20, 2014, at 7:53 PM, Bradford L Knowles <brad@shub-internet.orgmailto:brad@shub-internet.org> wrote:

Folks,

So, I’ve been trying to write some cross-platform Chef code for a customer, and one of the things we need to do is to take a zip archive of a package written in Java, and deploy that. The zip archive is completely self-contained, we don’t need to install it as an OS-level package or anything – we just need to un-zip it into an appropriate directory structure, and then run the appropriate included .sh or .BAT files.

This worked fine on RHEL5. But I was astonished to find that there is apparently no standard tool to handle this kind of thing on Win2k3 or Win2k8.

Am I missing something obvious here? I mean, I can install a package easily enough, but this is a … sensitive … customer, and there might have to be a lengthy delay in getting that approved through the change control board.

Any and all ideas or thoughts would be appreciated. Thanks!


Brad Knowles <brad@shub-internet.orgmailto:brad@shub-internet.org>
LinkedIn Profile: http://tinyurl.com/y8kpxu


#5

On Nov 21, 2014, at 12:30 AM, Dylan K. Grafmyre dylan@techpartnershawaii.com wrote:

Use the DSC Archive. However, You need Powershell 4.0 installed on the boxes to use the dsc_script resource which will work on 2008/2012

The last example shows the code for using Archive via dsc_script. https://docs.getchef.com/resource_dsc_script.html

You will need another option for Windows 2003 servers.

The suggestion from the client is to use WinRar, which should give us a solution that will work for both Win2k3 and Win2k8. For the moment, I’m assuming that this is either pre-installed on the machines we’re using, or we can install this from an internal company-approved location.

I would prefer to use standard system-provided resources to handle this kind of thing, but I have a stronger preference to use the same solution on all the Windows variants we have to support. I don’t mind installing additional tools, so long as they’re coming from appropriate security-approved sources.

But is there something else that I’m obviously missing?

Thanks!


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu


#6

You could use the Shell.Application COM object to extract the zip file (works on all versions).

Here’s some sample PowerShell. You’d want to parameterize and maybe toss in some error handling, but that should get you going.

$shell = new-object -com shell.application
$zip = $shell.NameSpace(“C:\somearchive.zip”)
foreach($item in $zip.items())
{
$shell.Namespace(“C:\temp\somearchive”).copyhere($item)
}

Steve

Steven Murawski
Community Manager @ Chef
Microsoft MVP - PowerShell
http://stevenmurawski.com

On November 21, 2014 at 9:34:20 AM, Brad Knowles (brad@shub-internet.org) wrote:

On Nov 21, 2014, at 12:30 AM, Dylan K. Grafmyre dylan@techpartnershawaii.com wrote:

Use the DSC Archive. However, You need Powershell 4.0 installed on the boxes to use the dsc_script resource which will work on 2008/2012

The last example shows the code for using Archive via dsc_script. https://docs.getchef.com/resource_dsc_script.html

You will need another option for Windows 2003 servers.

The suggestion from the client is to use WinRar, which should give us a solution that will work for both Win2k3 and Win2k8. For the moment, I’m assuming that this is either pre-installed on the machines we’re using, or we can install this from an internal company-approved location.

I would prefer to use standard system-provided resources to handle this kind of thing, but I have a stronger preference to use the same solution on all the Windows variants we have to support. I don’t mind installing additional tools, so long as they’re coming from appropriate security-approved sources.

But is there something else that I’m obviously missing?

Thanks!


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu


#7

We took a little little different approach. We just implemented an LWRP
that uses the rubyzip gem http://rubygems.org/gems/rubyzip. In our case its
cross platform. Sadly, I’m not at liberty to share it, but the gem makes
working with zips “not to bad”


#8

On Nov 21, 2014, at 9:43 AM, David Petzel davidpetzel@gmail.com wrote:

We took a little little different approach. We just implemented an LWRP that uses the rubyzip gem http://rubygems.org/gems/rubyzip. In our case its cross platform. Sadly, I’m not at liberty to share it, but the gem makes working with zips “not to bad”

I went looking for a Ruby gem based solution, but the only thing I found was “unzipMe”, which is most definitely NOT cross-platform. But I hadn’t found anything else obvious.

I don’t mind writing some code, so this sounds like a potential solution that I definitely need to take a deeper look into. Thanks!


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu


#9

On Nov 21, 2014, at 9:38 AM, Steven Murawski steven.murawski@gmail.com wrote:

You could use the Shell.Application COM object to extract the zip file (works on all versions).

Here’s some sample PowerShell. You’d want to parameterize and maybe toss in some error handling, but that should get you going.

$shell = new-object -com shell.application
$zip = $shell.NameSpace(“C:\somearchive.zip”)
foreach($item in $zip.items())
{
$shell.Namespace(“C:\temp\somearchive”).copyhere($item)
}

That looks like a pretty simple solution that I definitely need to take a look at. I’ve already done a lot of parameterization anyway, so this would be good re-use.

Thanks everyone! I now have three different solutions that I should be able to use on both Win2k3 and Win2k8, and I just need to take a stab at a bit of testing to see which one we’re likely to go with.

Thanks again!


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu


#10

We’ve also used the rubyzip gem, then used windows_zipfile. No extra code writing required and it didn’t install 7zip either (using windows 1.30.0).

In the recipe, we had:

            chef_gem "rubyzip" do
                action :install
            end

            require 'zip'

then use the windows_zipfile resource as normal.

Thanks
Tom

-----Original Message-----
From: Brad Knowles [mailto:brad@shub-internet.org]
Sent: 21 November 2014 15:47
To: chef@lists.opscode.com
Cc: Bradford L Knowles
Subject: [chef] Re: Windows system standard program for unzip-ing archives?

On Nov 21, 2014, at 9:43 AM, David Petzel davidpetzel@gmail.com wrote:

We took a little little different approach. We just implemented an LWRP that uses the rubyzip gem http://rubygems.org/gems/rubyzip. In our case its cross platform. Sadly, I’m not at liberty to share it, but the gem makes working with zips “not to bad”

I went looking for a Ruby gem based solution, but the only thing I found was “unzipMe”, which is most definitely NOT cross-platform. But I hadn’t found anything else obvious.

I don’t mind writing some code, so this sounds like a potential solution that I definitely need to take a deeper look into. Thanks!


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu

HBVB trading as Bauer Corporate Services (BCS) is a division of the Bauer Media
Group the largest consumer publisher in the UK, and second largest commercial
radio broadcaster. BCS provides financial services and manages and develops IT
systems on which our UK publishing, broadcast, digital and partner businesses depend.

The information in this email is intended only for the addressee(s) named above.
Access to this email by anyone else is unauthorised. If you are not the intended
recipient of this message any disclosure, copying, distribution or any action
taken in reliance on it is prohibited and may be unlawful. HBVB do not warrant that
any attachments are free from viruses or other defects and accept no liability for
any losses resulting from infected email transmissions.

Please note that any views expressed in this email may be those of the originator
and do not necessarily reflect those of this organisation.

HBVB is registered in England; Registered address is
1 Lincoln Court, Lincoln Road, Peterborough, PE1 2RF.

Registration number 8453545


#11

On Fri, Nov 21, 2014 at 1:27 AM, Adam Edwards adamed@getchef.com wrote:

The windows cookbook has a resource called windows_zipfile that can unzip
files for you. One issue with that is that it downloads external software
called 7zip to do this, so it requires that your nodes have Internet access
at the time the execute a recipe (at least the first time). You can read
about it here:
https://github.com/opscode-cookbooks/windows/blob/master/README.md.

Actually, it uses the ‘zip’ Rubygem, not 7-zip, so if you’re cool with
getting a gem “approved” then that’s a pretty lightweight way of
solving this problem.

  • Julian


[ Julian C. Dunn jdunn@aquezada.com * Sorry, I’m ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]


#12

On Nov 21, 2014, at 4:45 PM, Julian C. Dunn jdunn@aquezada.com wrote:

Actually, it uses the ‘zip’ Rubygem, not 7-zip, so if you’re cool with
getting a gem “approved” then that’s a pretty lightweight way of
solving this problem.

Yeah, I don’t think we have a problem with rubygems. I had already used the scp ruby gem so that I could download certain binary files from an existing central server, instead of having to stand up a separate http or http server for the repo, and having to get approval for new holes being punched in firewalls, etc…

So, this is the method I’ve chosen to go with, at least for the moment.

My next trick is that Java isn’t pre-installed on all these machines, so now I need to handle that situation as well. And I can’t use the standard windows_package resource (at least, not easily), because I need to handle the case where a different version of Java may already be installed.

So, we’re getting a copy of the Java installation package put up on the central server into the “binary files repo”, where we can scp it down to the Windows machines that need it and then install the package in a separate location.

When it rains, it pours – eh? :wink:


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu