[chef] Re: Powershell terminate chef-run


Chronological Thread 
  • From: Galen Emery < >
  • To:
  • Subject: [chef] Re: Powershell terminate chef-run
  • Date: Wed, 6 May 2015 10:53:06 -0700

I would use the chef reboot resource.

In short, put a guard on the powershell_script resource similar to your if statement[0]

And then I'd use a notifies[1] for the reboot resource[2]


[0]https://docs.chef.io/resource_common.html#guards

This will end the chef run cleanly, rather than throwing an error at the end of the powershell.



On Wed, May 6, 2015 at 1:37 AM, Simon Hawkins < " target="_blank"> > wrote:

Hi All,

 

I have a “Restart-computer -force” command as part of a powershell script inside a chef recipe, how do I terminate the chef-run at this point?

 

I have something like this:

 

  if ($computer_name -eq $new_name) {

 

     Write-host "Not changing the name as it is already set"

 

                … code here….

 

    

if ((gwmi win32_computersystem).partofdomain -eq $true) {

        write-host "I am domain joined, aborting!"

 

     }

 

     Else {

 

      Add-Computer -DomainName $domain -Credential $cred -force

 

      Restart-Computer -force --- how do I terminate the chef-run here?

 

     }

 

  }

 

  else {

 

      code here…..              

       

        Restart-Computer –force -- how do I terminate the chef-run here?

 

  }

 

EOH

 

Cheers,

Simon


Disclaimer

This message is intended only for the use of the person(s) ("Intended Recipient") to whom it is addressed. It may contain information which is privileged and confidential. Accordingly any dissemination, distribution, copying or other use of this message or any of its content by any person other than the Intended Recipient may constitute a breach of civil or criminal law and is strictly prohibited. If you are not the Intended Recipient, please contact the sender as soon as possible.

Totaljobs Group Limited Registered Office: Bluefin Building, 110 Southwark Street, London, SE1 0TA, UK Registered in England and Wales under company no. 4269861








Archive powered by MHonArc 2.6.16.

§