- From: Madhurranjan Mohaan <
>
- To:
- Subject: [chef] Re: power shell and chef
- Date: Wed, 22 Feb 2012 09:28:49 +0530
- Authentication-results: mr.google.com; spf=pass (google.com: domain of
designates 10.216.131.234 as permitted sender)
; dkim=pass
Some samples with the "windows_batch" resources:
not_if { Registry.key_exists?('HKLM\\SOFTWARE\\Microsoft\\<your registry entry> ') }
not_if { File.exists?("C:\\etc\\<something.txt>") }
I had problems with the Services bit , but with powershell you can get it to work using a Here Doc to get over a quotes within quotes problem . Eg, when you have to check for databases in sql server using "EXEC sp_databases" , you might have to add this in a here doc and use that in your only_if or not_if . What doesn't work is not_if " sqlcmd -S Localhost "Exec sp_databases" | grep <instance name> " but using the here doc in here would work well.
Also with powershell , in the not_if or only_if , you'll have to use "powershell.exe" -- for eg , not_if "powershell.exe <your command>" but a normal windows command line would work well.
Hope that helps.
On Wed, Feb 22, 2012 at 7:20 AM, Sascha Bates
<
">
> wrote:
Can anyone point me to some example chef code using not_if/only_if on windows/powershell blocks? I have some ideas but I'm not sure they're very good. I need to set up a service and make sure I don't kick off a reboot or anything crazy every time chef runs.
Learning powershell syntax at the same time I'm wrangling chef for windows is not advised, but really, who am I kidding? When would I have bothered otherwise?
Sascha
Archive powered by MHonArc 2.6.16.