That is a good idea! I was suggesting something like this:
# ---------- 1. Install IIS Role, if not already installed ---------- script =<<-EOF
$x = Get-WindowsFeature -name "Web-Server" $status = 0 if($x -ne $null) { $installed = $x.Installed if($installed -eq $false) { $status = 1 } else { $status = 0 }
} return $status
EOF
cmd = powershell_out(script)
x = cmd.stdout.chop
powershell_script "Install_IIS" do code <<-EOH
Install-WindowsFeature -name "Web-Server" -IncludeManagementTools -IncludeAllSubFeature
EOH only_if { x == '1' } end
-Kapil
From: Adam Edwards [mailto:
Seems like you can do this without powershell_out – you can coerce powershell to return an exit code using the exit command in powershell – here’s an example:
not_if 'powershell -noninteractive -noprofile -command "exit [int32]((Get-ExecutionPolicy) -eq 'RemoteSigned')"'
The above guard will cause the resource to not execute if powershell’s execution policy is set to remotesigned.
Somewhat related, here is a proposal to make it easier to use powershell and other script resources in guard expressions:
https://github.com/opscode/chef-rfc/blob/adamed/resource-guard/rfc0001-resource-guard.md
-Adam
Chef resources do not return a value (as far as I know). You will have to use “powershell_out” to check for certain condition and based on what it returns you can trigger the iis_config resource.
-Kapil
From: Kenneth Barry [
">mailto:
]
Can I use powershell to check the settings, but if the powershell indicates they are different than what they should be, have the iis cookbook sections run again? Something like powershell_script "checking setting #1" (check if settings are the same) iis_config only do this is "checking setting #1" returned false. This is more of a capability/syntax question.
On Fri, Feb 21, 2014 at 11:54 AM, Kapil Shardha < " target="_blank"> > wrote:
This email and any accompanying documents may contain privileged or otherwise confidential information of, and/or is the property of Education Management Solutions, Inc. If you are not the intended recipient, please immediately advise the sender by reply email & delete the message & any attachments without using, copying or disclosing the contents. Thank you. |
Archive powered by MHonArc 2.6.16.