- From: "Julian C. Dunn" <
>
- To: "
" <
>
- Subject: [chef] Re: NOT_IF and ONLY_IF validation problem.
- Date: Wed, 20 Aug 2014 10:40:24 -0400
On Wed, Aug 20, 2014 at 8:16 AM, Carlos Camacho
<
>
wrote:
>
Hello!
>
>
Im runing this simple recipe block to create a web app in IIS
>
>
powershell_script "create_site_my_site" do
>
code "New-webapppool -name 'My_Web_App'; New-Website -Name
>
'My_Web_App' -applicationpool 'My_Web_App' -Port '80' -IPAddress *
>
-PhysicalPath 'c:\webs\My_Web_App' "
>
action :run
>
not_if "get-website | where-object { $_.name -eq 'My_Web_App' }"
>
end
>
>
>
The problem here its that the NOT_IF part its allways True
>
>
>
PS C:\Users\carlos>
>
PS C:\Users\carlos> get-website | where-object { $_.name -eq 'asdfasdfasdf'
>
}
>
PS C:\Users\carlos> echo $lastexitcode
>
1
>
PS C:\Users\carlos> get-website | where-object { $_.name -eq 'My_Web_App' }
>
>
Name ID State Physical Path
>
Bindings
>
---- -- ----- -------------
>
--------
>
My_Web_App 6 Stopped c:\webs\My_Web_App http *:80:
>
>
https *:443:
>
>
PS C:\Users\carlos.camacho> echo $lastexitcode
>
1
>
>
Now, my question is about how to return True or False in the NOT_IF
>
depending on my code return value ??
Use the convert_boolean_return attribute in the powershell_script
resource to do the right thing. See the documentation for information
about what that does & why.
http://docs.getchef.com/resource_powershell_script.html
I imagine that this will become the default when :guard_interpreter
becomes :powershell by default for powershell_script.
- Julian
--
[ Julian C. Dunn
<
>
* Sorry, I'm ]
[ WWW:
http://www.aquezada.com/staff/julian * only Web 1.0 ]
[
gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]
Archive powered by MHonArc 2.6.16.