--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7b4f140b-05fd-4477-b8bc-62e14f54da70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/4b7bba85-c64c-4ff1-abe0-ef8b9ec56590%40googlegroups.com.
Regards
Fraser.
We solve this issue by doing (kind of ugly) stuff like this in our modules:
unless => 'if ( ! ( Get-Service mcollectived ) ) { exit 1 }',
If you don't like that syntax, you may be able to use the $? or $LastExitCode variables that get set by PowerShell (I haven't tested this, however). Both of those have non-obvious gotchas. A good writeup on error handling in PS (not Puppet-specific) is here: http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/12/powershell-error-handling-and-why-you-should-care.aspx
- Peter
On 08/27/2015 08:38 AM, Thomas Bartlett wrote:
Hi Guys,--
So I've been working with puppet on windows and I think my approach is all wrong. I've been using the puppetlabs/powershell module to run commands, however I'm having difficulty with exit codes. Primarily puppet expects exit codes to denote success/failure, whereas powershell is returning objects (and giving a 0 exit code regardless of result).
I'm automating the install of old bits of software, so getting meaningful answers out of the installers is pretty difficult, this means that the scripts are a bit ugly and not very idempotent. Typically I have to check a log file to find out if the install actually worked.
Are there any examples out there of windows puppet automation that makes heavy use of the powershell module?
Cheers,
Tom
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7b4f140b-05fd-4477-b8bc-62e14f54da70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/55DF1E29.40409%40alter3d.ca.
Hi Guys,
So I've been working with puppet on windows and I think my approach is all wrong. I've been using the puppetlabs/powershell module to run commands, however I'm having difficulty with exit codes. Primarily puppet expects exit codes to denote success/failure, whereas powershell is returning objects (and giving a 0 exit code regardless of result).
I'm automating the install of old bits of software, so getting meaningful answers out of the installers is pretty difficult, this means that the scripts are a bit ugly and not very idempotent. Typically I have to check a log file to find out if the install actually worked.
Are there any examples out there of windows puppet automation that makes heavy use of the powershell module?
Cheers,
Tom
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7b4f140b-05fd-4477-b8bc-62e14f54da70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Thu, Aug 27, 2015 at 7:38 AM, Thomas Bartlett <thomas.bar...@gmail.com> wrote:Hi Guys,
So I've been working with puppet on windows and I think my approach is all wrong. I've been using the puppetlabs/powershell module to run commands, however I'm having difficulty with exit codes. Primarily puppet expects exit codes to denote success/failure, whereas powershell is returning objects (and giving a 0 exit code regardless of result).
I'm automating the install of old bits of software, so getting meaningful answers out of the installers is pretty difficult, this means that the scripts are a bit ugly and not very idempotent. Typically I have to check a log file to find out if the install actually worked.If you are automating the install of software, you should look at using either the built-in package resource
or one of the Windows package providers, e.g. Chocolatey[1]. It also has a pre-built, ready to go internal package server[2] so you can put your packages somewhere in your network.Lastly, if you are looking at the Chocolatey route, note that the provider is almost finished with the install of choco on the machine[3] and using it as a provider for packages in the same run.[4][4] https://cloud.githubusercontent.com/assets/63502/9509913/cadaf9ee-4c2a-11e5-9ca8-042b79cac217.png--
Are there any examples out there of windows puppet automation that makes heavy use of the powershell module?
Cheers,
Tom
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7b4f140b-05fd-4477-b8bc-62e14f54da70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Rob ReynoldsDeveloper, Puppet LabsPuppetConf 2015 is coming to Portland, Oregon! Join us October 5-9.Register now to take advantage of the Final Countdown discount —save $149!
For instances like this, I've usually smashed everything into a one-liner using the powershell provider. So...something along the lines of:
command => " \$thing = <result of your query>; Write-Host \"Puppet ${thingamajig} is a $\thing\""
As can be seen above, it can start looking pretty ugly, especially if the commands you are executing are a bit longwinded. You can get a lot more power out of writing custom types/providers and it make for a lot cleaner looking manifest, but there aren't a lot of publicly available windows-specific ones in the wild right now.
I think most people tend to steer towards DSC for that and hope for the best.
On Thursday, August 27, 2015 at 9:06:13 AM UTC-7, Thomas Bartlett wrote:Nice one, I'll give that a go. You don't happen to know how I can set a variable to equal the result of a powershell command do you? I need to use the hostname of the machine as a parameter for another command. At the minute I'm using hard-coding which is obviously a cardinal sin.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/137c1e96-4285-4a6c-a43a-d7d243fe70e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.