Correction: actually, in the example below, the workaround must be inverted, so a "!” needs to be added:
powershell –command "exit [int32](!(get-executionpolicy) -eq 'remotesigned'))" -Adam
David, I have a branch in progress that adds this feature to powershell_script (if I understand you correctly). See the doc at https://github.com/opscode/chef-rfc/blob/adamed/resource-guard/rfc0001-resource-guard.md -- it has a link to a branch.
Is this the behavior you'd like to see?
# What if guards evaluated powershell script code that powershell # evaluates as a boolean type as the actual boolean value of the guard # itself? You can avoid extra script code to translate the boolean into # a process exit code that results in the right true / false behavior # for the guard powershell_script "set execution policy" do code "set-executionpolicy remotesigned" not_if "(get-executionpolicy) -eq 'remotesigned'" # Like I barely left Ruby -- wow! end
The current workaround for the example above is to use an _expression_ like powershell –command "exit [int32](get-executionpolicy) -eq 'remotesigned')"
in the not_if above. It basically forces the script to convert a Boolean data type to an integer that is then returned as the process exit code, which is interpreted by Chef as a Boolean value.
-Adam
-----Original Message-----
I work with Chef on Windows node and find myself writing a lot of Chef guards for the powershell_script resource. I was wondering if there was a Chef resource that returned a boolean value that I could use here. Thank you, David Williams
________________________________ CONFIDENTIALITY NOTICE: This electronic mail may contain information that is privileged, confidential, and/or otherwise protected from disclosure to anyone other than its intended recipient(s). Any dissemination or use of this electronic mail or its contents by persons other than the intended recipient(s) is strictly prohibited. If you have received this communication in error, please notify the sender immediately by reply e-mail so that we may correct our internal records. Please then delete the original message. Thank you. |
Archive powered by MHonArc 2.6.16.