Both of these work, indeed it would appear using a similar approach (powershell using .Copyhere). However both of them appear to require that the source zip file is located on a local drive. The reidmv/unzip README says this :-
source
The fully-qualified path to the zip file to extract. This file must already exist on the system; that is, it cannot be a remote URL. You can use pget or another resource
The zip file that I want to use is on a network share (actually while I'm testing its a sync folder in Vagrant, but will be on a network share when I move beyond this stage). When I use that location in the source, the module doesn't fail or error, it just doesn't unzip any of the files. If I move the file locally it works correctly. The same behaviours is true for the counsel/puppet-windows module.
Is this a constraint of powershell or is there something else at play here ?
Is there another way that I can unzip a file that is not located on the local machine (I would prefer not to have to install 7zip or similar if possible, but I will if that's the only way) ?
Here is the command used in the reidmv/unzip module (it's wrapped into an Exec resource) :-
exec { "unzip $source to $dest":
command => "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path '$dest')).Copyhere(\$sh.namespace((Convert-Path '$source')).items(), 16",
creates => $creates,
provider => powershell
}
Hi Fraser,
The requirement that the file be local is just a constraint of how the unzip module works right now. This is a very simple module. In practice, that means that if your file is remote you either need to use something like lwf/remote_file to first ensure that a local copy exists, or alternatively you could use a larger more complicated module such as nanliu/archive, which provides a larger more complex type that can directly retrieve and unzip remote files.
Example using reidmv/unzip and lwf/remote_file together:
remote_file { 'jboss-native.zip':
ensure => present,
path => 'C:/jboss/jboss-native-2.0.10-windows-x64-ssl.zip',
source => 'http://downloads.jboss.org/jbossnative/2.0.10.GA/jboss-native-2.0.10-windows-x64-ssl.zip',
require => File['C:/jboss/jboss-as-7.1.1.Final'],
} ->
unzip { 'jboss-native':
source => 'C:/jboss/jboss-native-2.0.10-windows-x64-ssl.zip',
destination => 'C:/jboss/jboss-as-7.1.1.Final',
creates => 'C:/jboss/jboss-as-7.1.1.Final/bin/jbosssvc.exe',
}
Example using nanliu/archive:
archive { 'jboss-native':
ensure => present,
extract => true,
extract_path => 'C:/jboss/jboss-as-7.1.1.Final',
source => 'http://downloads.jboss.org/jbossnative/2.0.10.GA/jboss-native-2.0.10-windows-x64-ssl.zip',
creates => 'C:/jboss/jboss-as-7.1.1.Final/bin/jbosssvc.exe',
cleanup => true,
}
I don't typically use archive myself since it's a little bit more heavyweight and when I used it last it required 7zip and some ruby gems installed to operate correctly but I like to mention it in case it works for people.
unzip itself could likely be extended to be able to use remote sources if someone were to upgrade the powershell snippet that is used to perform the extraction. I don'tnticipate adding that anytime soon myself but pull requests definitely welcome! :-)
Hope that helps,
~Reid
- Show quoted text -