Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issues when puppet runs as service #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions manifests/unzip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,35 @@
$refreshonly = false,
$unless = undef,
$zipfile = $name,
$provider = 'powershell',
$provider = 'dotnet',
$options = '20',
$command_template = 'windows/unzip.ps1.erb',
$timeout = 300,
$logoutput = on_failure,
) {
validate_absolute_path($destination)

if (! $creates and ! $refreshonly and ! $unless){
fail("Must set one of creates, refreshonly, or unless parameters.\n")
}

unless( $provider == 'dotnet' or $provider == 'com'){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to the old default of powershell? Should that be supported for backwards compatibility?

Also, some funky spacing in this line.

fail("Wrong provider: `${provider}', choices are: dotnet or com!\n")
}

if ($provider == 'dotnet'){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra space

$command_template = 'windows/unzip_dotnet.ps1.erb'
}else{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing space

$command_template = 'windows/unzip.ps1.erb'
}


exec { "unzip-${name}":
command => template($command_template),
creates => $creates,
refreshonly => $refreshonly,
unless => $unless,
provider => $provider,
provider => powershell,
timeout => $timeout,
logoutput => $logoutput,
}
}
25 changes: 22 additions & 3 deletions templates/unzip.ps1.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
$shell = New-Object -COMObject Shell.Application;
$zipfile = $shell.NameSpace("<%= @zipfile %>");
foreach($item in $zipfile.Items()){ $shell.NameSpace("<%= @destination %>").CopyHere($item, <%= @options %>) };
$zipFile="<%= @zipfile %>"
$dst="<%= @destination %>"

if ( ! (Test-Path $zipfile) ) {
write-error "ZIP file does not exists: `$zipFile'"
exit 1
}

if ( ! (Test-Path $dst) ) {
write-error "Missing destination folder: `$dst'"
exit 1
}

try {
$shell = New-Object -COMObject Shell.Application;
$zipfile = $shell.NameSpace("<%= @zipfile %>");
foreach($item in $zipfile.Items()){ $shell.NameSpace("<%= @destination %>").CopyHere($item, <%= @options %>) };
}
catch {
write-error $_
exit 1
}
21 changes: 21 additions & 0 deletions templates/unzip_dotnet.ps1.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$zipFile="<%= @zipfile %>"
$dst="<%= @destination %>"

if ( ! (Test-Path $zipfile) ) {
write-error "ZIP file does not exists: ``$zipFile'"
exit 1
}

if ( ! (Test-Path $dst) ) {
write-error "Missing destination folder: ``$dst'"
exit 1
}

try {
Add-Type -A System.IO.Compression.FileSystem
[IO.Compression.ZipFile]::ExtractToDirectory($zipFile, $dst)
}
catch {
write-error $_
exit 1
}