Re: [Puppet Users] Puppet Windows Automation

2015-09-01 Thread Matthew Stone
do it do it do it do it! I put one together for windowsfeature and wanted to submit a PR, but I'm unseasoned at rspec and haven't been able to put together a solid block of tests. Any help or resources in that department is more than appreciated. :) On Monday, August 31, 2015 at 7:15:32 PM UT

Re: [Puppet Users] Puppet Windows Automation

2015-08-31 Thread Rob Reynolds
On Monday, August 31, 2015, Matthew Stone wrote: > 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 = ; Write-Host \"Puppet > ${thingamajig} is a $\thing\"" > > As can be seen abo

Re: [Puppet Users] Puppet Windows Automation

2015-08-31 Thread Matthew Stone
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 = ; Write-Host \"Puppet ${thingamajig} is a $\thing\"" As can be seen above, it can start looking pretty ugly, especially if the comm

Re: [Puppet Users] Puppet Windows Automation

2015-08-29 Thread Rob Reynolds
On Sat, Aug 29, 2015 at 9:22 AM, Rob Reynolds wrote: > > > On Thu, Aug 27, 2015 at 7:38 AM, Thomas Bartlett < > thomas.bartlett.1...@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

Re: [Puppet Users] Puppet Windows Automation

2015-08-29 Thread Rob Reynolds
On Thu, Aug 27, 2015 at 7:38 AM, Thomas Bartlett < thomas.bartlett.1...@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 c

Re: [Puppet Users] Puppet Windows Automation

2015-08-29 Thread Rob Reynolds
On Thu, Aug 27, 2015 at 9:26 AM, Peter Kristolaitis wrote: > 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 variable

[Puppet Users] Puppet Windows Automation

2015-08-28 Thread Fraser Goffin
Whilst there are definitely some uses cases where executing scripts in either Powershell or via an Exec resource is the way to go, in my opinion you should really be thinking of using the higher level resource abstractions. That way you don't need to deal with the implementation details and you

Re: [Puppet Users] Puppet Windows Automation

2015-08-27 Thread Peter Kristolaitis
PowerShell is largely based on the syntax of the ksh shell, so most constructs that work in ksh will work in PS as well. In this case: $FOO=(hostname) That will interpolate anywhere, not just during variable assignment, so you can do stuff like: Some-CmdLet -Host (hostname) If you're famil

Re: [Puppet Users] Puppet Windows Automation

2015-08-27 Thread Thomas Bartlett
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. On Thursday,

Re: [Puppet Users] Puppet Windows Automation

2015-08-27 Thread Peter Kristolaitis
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

[Puppet Users] Puppet Windows Automation

2015-08-27 Thread Thomas Bartlett
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 return