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


Chronological Thread 
  • From: Kapil Shardha < >
  • To: Daniel DeLeo < >, " " < >
  • Subject: [chef] RE: Re: Re: Re: Re: RE: Order of Execution of resources in a cookbook
  • Date: Tue, 11 Feb 2014 13:57:27 +0000
  • Accept-language: en-US

Dan,

 

Thanks for your suggestions. Can you elaborate on your suggestion on how to manually include the powershell_out module into the resource DSL or how to create a powershell_out command object?

 

I am relatively new to Chef so please bear with my questions.

 

Appreciate your help!

 

-Kapil

 

 

 

From: Daniel DeLeo [mailto: On Behalf Of Daniel DeLeo
Sent: Monday, February 10, 2014 7:44 PM
To: Kapil Shardha;
Subject: Re: [chef] Re: Re: Re: Re: RE: Order of Execution of resources in a cookbook

 

 

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

 

 




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.

§