diff options
author | Kartik Null Cating-Subramanian <ksubramanian@chef.io> | 2015-05-06 13:46:19 -0400 |
---|---|---|
committer | Kartik Null Cating-Subramanian <ksubramanian@chef.io> | 2015-06-09 14:20:31 -0400 |
commit | dbd585a41bd359cd13f901abf194bc8c93537a29 (patch) | |
tree | 0c6f981e3490a9f043f681e58841bfada9914db7 /distro | |
parent | 9373653bffa521234d207c44055e6ee494c988cf (diff) | |
download | chef-dbd585a41bd359cd13f901abf194bc8c93537a29.tar.gz |
Add a chef powershell module that wraps ruby invocations.
Diffstat (limited to 'distro')
-rw-r--r-- | distro/powershell/chef.psm1 | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/distro/powershell/chef.psm1 b/distro/powershell/chef.psm1 new file mode 100644 index 0000000000..cdcaed55bb --- /dev/null +++ b/distro/powershell/chef.psm1 @@ -0,0 +1,34 @@ +function chef-client { + <# + .SYNOPSIS + A chef-client is an agent that runs locally on every node that is under management by Chef. + .DESCRIPTION + When a chef-client is run, it will perform all of the steps that are required to bring the node into the expected state, including: + + Registering and authenticating the node with the Chef server + Building the node object + Synchronizing cookbooks + Compiling the resource collection by loading each of the required cookbooks, including recipes, attributes, and all other dependencies + Taking the appropriate and required actions to configure the node + Looking for exceptions and notifications, handling each as required + .EXAMPLE + chef-client --help + #> + [CmdletBinding()] + param ( + [parameter(ValueFromRemainingArguments=$true)] $All + ) + + # Take each input string, escape any \ ' or " character in it and then surround it with "s. + # This is to defeat the second-level parsing performed by the MSVCRT argument parser used + # by ruby which only understands \ ' and ". + # + # This is a fuster cluck. Don't touch this unless you are sure you understand regexes. + # The \\ is to request a literal \ match in a regex. + # The "" is to inject a literal " character in a PS string surrounded by "s. + # The replacement pattern must be '\$1' and not "\$1" because $1 is not a real variable + # that needs substituting - it's a capture group that's interpreted by the regex engine. + # \ in the replacement pattern does not need to be escaped - it is literally substituted. + $Transformed = $All | foreach { '"' + ( $_ -replace "([\\'""])",'\$1' ) + '"' } + & "ruby.exe" "chef-client" $Transformed +}
\ No newline at end of file |