Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
None
-
-
2
-
Windows 2016-08-10
Description
If I write the following powershell script:
fail.ps1 |
Exit 1
|
and the following piece of Puppet code:
test.pp |
exec { 'should not run':
|
command => 'Write-Host hello',
|
onlyif => '& C:\Users\Administrator\Desktop\fail.ps1',
|
provider => 'powershell',
|
}
|
I would expect that my exec statement would not run because the onlyif returns an exit code of 1, but it does in fact run the command given. However if i do this:
test.pp |
exec { 'should not run':
|
command => 'Write-Host hello',
|
onlyif => 'Exit 1',
|
provider => 'powershell',
|
}
|
It works as expected (the exec does not get run)
There must be something wrong with the way the exit codes are passed through. It is important to note that this was introduced in version 2.0.0 as per this support ticket: https://puppetlabs.zendesk.com/agent/tickets/18988
Attachments
Issue Links
- is supported by
-
MODULES-3588 Document the best way to handle exit codes in ps1 scripts
-
- Resolved
-
- relates to
-
MODULES-3709 PowerShell module 2.x - Does not Respect Timeout
-
- Resolved
-
- links to