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

suggestions #1

Closed
rismoney opened this issue Feb 1, 2013 · 10 comments
Closed

suggestions #1

rismoney opened this issue Feb 1, 2013 · 10 comments

Comments

@rismoney
Copy link

rismoney commented Feb 1, 2013

well this is interesting - great job getting it out here.

A few things I was thinking about:

Number1:
Handle x64 vs x86. We should launch \sysnative\WindowsPowershell\v1.0\powershell.exe if it exists to get 64bit posh. Otherwise launch
\system32\WindowsPowershell\v1.0\powershell.exe. Otherwise launch
powershell.exe based w/o path (assume default)

Number2:
I have not looked at the exec type specifics- does it allow switches? Specifically for powershell, we should be able to launch it with different switches both user controlled and some defaults. Defaults are probably powershell.exe -inputformat none -nologo, -noninteractive, -noprofile, -executionpolicy remotesigned?

Number3:
I am not sure if this is possible- but could we use heredoc to specify a multiline command and generate a file based on it, and run that? I was thinking something like:

command => <<-EOD
$blah="foo"
$write-host $blah
EOD

or maybe use an erb and pass it to command?

Then- I think I'd want all commands executed as a script block (enclosed in curly braces)
usage:

powershell.exe -command "& {@resource[:command]}" ?

I welcome you thoughts!

@ferventcoder
Copy link
Contributor

These are all awesome suggestions! I'll work with Josh on these over the next few months.

@rismoney
Copy link
Author

do I know you from somewhere? ;)

I think he addressed the first one, which was the breaking one. I am typically writing get and set ps1 files, deploying them as file resources and avoiding this #2 & 3

I have found complex quoting scenarios to be darn maddening to figure out sometimes. ruby escape characters, double quoting single, backslash for regex and backticks between ruby and powershell or ruby cmd and powershell in the default provider are hard

@ferventcoder
Copy link
Contributor

newb question (both ruby and puppet), but what about delimited strings i.e. q%{}?

As in

command => %q{$blah="foo"  
write-host '\ hey look'
$write-host $blah}

@rismoney
Copy link
Author

yea, you are intertwining ruby with the DSL... they don't meld like that.
Though in the new ver it might align with http://docs.puppetlabs.com/puppet/3/reference/lang_experimental_3_2.html

@joshcooper
Copy link
Contributor

Using a template may help (for now): command => template('foo.ps1.erb')

Henrik is working on adding heredoc support to puppet: http://projects.puppetlabs.com/issues/19886, and should be rolled into the future parser soonish.

One the main problems though is that powershell variable assignments, e.g. $blah =, are interpolated by puppet, so you have to escape it \$blah =

@rismoney
Copy link
Author

The heredoc support is awesome! great news.

template is a good workaround.

@ferventcoder
Copy link
Contributor

Cool. :)

@joshcooper
Copy link
Contributor

@rismoney It sounds like there are two remaining issues, overriding powershell arguments, and heredoc support. The latter is a relatively known quantity and should be possible once the parser supports it.

About the former, there is no good way to pass provider specific options without altering the type: http://projects.puppetlabs.com/issues/4113. Since exec is a core type, this would have implications beyond powershell. Thoughts?

@rismoney
Copy link
Author

Agreed, lets move on.

@cyberious
Copy link
Contributor

@joshcooper can we close this, or should we move it to Jira?

@Iristyle Iristyle closed this as completed Jun 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants