[chef] Re: Re: Re: Re: Re: RE: Order of Execution of resources in a cookbook


Chronological Thread 
  • From: Daniel DeLeo < >
  • To: , " " < >
  • Subject: [chef] Re: Re: Re: Re: Re: RE: Order of Execution of resources in a cookbook
  • Date: Mon, 10 Feb 2014 16:44:03 -0800


On Monday, February 10, 2014 at 1:24 PM, wrote:

Dan,

I tried your suggestion like this:

script =<<-EOF
$processLog = 'C:\\Temp\\Chef_PS_Log.txt'
function Date { Get-Date -Format 'yyyy/dd/MM HH:mm:ss' }
Add-Content $processLog (($date=Date) + ' ' + '----- 1. Inside
Install_IIS_Check ----')
$x = Get-WindowsFeature -name "Web-Server"
$status = 0
if($x -ne $null)
{
$installed = $x.Installed
if($installed -eq $false)
{
Add-Content $processLog (($date=Date) + ' ' + 'IIS is
not installed')
$status = 1
}
else
{
Add-Content $processLog (($date=Date) + ' ' + 'IIS is
already installed. Install_IIS step will be skipped')
$status = 0
}
}
Add-Content $processLog "`n"
return $status

EOF




powershell_script "Install_IIS" do
code <<-EOH
$processLog = 'C:\\Temp\\Chef_PS_Log.txt'
function Date { Get-Date -Format 'yyyy/dd/MM HH:mm:ss' }
Add-Content $processLog (($date=Date) + ' ' + '----- 1-1 Inside
Install_IIS ----')
Add-Content $processLog (($date=Date) + ' ' + 'IIS Server role is not
installed ')
#Install-WindowsFeature -name "Web-Server" -IncludeManagementTools
-IncludeAllSubFeature -WhatIf
Install-WindowsFeature -name "Web-Server" -IncludeManagementTools
-IncludeAllSubFeature
EOH
only_if do
cmd = powershell_out(script)
cmd.stdout.chop == '1'
end
# { x == '1' }
end


On running chef-client I get the following error:

NoMethodError
-------------
undefined method `powershell_out' for Chef::Resource::PowershellScript


Any idea if that is expected?

Thanks

-Kapil
It looks like the powershell_out helper isn’t being included into the resource DSL. I’m asking around about the best ways to deal with this. The two options that come to mind are to manually include the powershell_out module into the resource DSL, or to create a powershell_out command object by hand.

-- 
Daniel DeLeo
 




Archive powered by MHonArc 2.6.16.

§