[chef] RE: Re: RE: Re: RE: RE: Re: RE: RE: RE: Re: RE: Re: Idempotent IIS


Chronological Thread 
  • From: Adam Edwards < >
  • To:
  • Subject: [chef] RE: Re: RE: Re: RE: RE: Re: RE: RE: RE: Re: RE: Re: Idempotent IIS
  • Date: Tue, 25 Feb 2014 11:13:42 -0800

Kenneth, I think there is a quoting issue in the argument for –filter – I couldn’t execute that when I pasted your command into PowerShell. Using single quotes instead of double quotes did the trick, i.e.

 

[int32]((get-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST"  -filter 'system.webServer/httpCompression/ "gzip"]' -name "dynamicCompressionLevel").value -eq 4)

 

worked on my system. In general, quoting is something to be mindful of when mixing languages in this way (i.e. Ruby and PowerShell). Using here documents can help, though it is less concise.

 

-Adam

 

 

From: Kenneth Barry [mailto: "> ]
Sent: Tuesday, February 25, 2014 10:26 AM
To: ">
Subject: [chef] Re: RE: Re: RE: RE: Re: RE: RE: RE: Re: RE: Re: Idempotent IIS

 

What am I doing wrong?

I expect the sode block to "not [run] if" the value of the setting is current '4'.

When I run this code


powershell_script "testDynamicCompressionLevel" do
    code <<-EOB
        Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/httpCompression/ 'gzip']" -name "dynamicCompressionLevel" -value 4
    EOB
    not_if 'powershell -noninteractive -noprofile -command "exit [int32]((get-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST"  -filter "system.webServer/httpCompression/ "gzip"]" -name "dynamicCompressionLevel").value -eq 4)"'
end

on  machine 1 the powershell command in the not_if evaluated to false (because its set to 0) I run this command from the prompt on the machine locally.

upon chef-client i get the following lines:

[2014-02-25T13:23:16-05:00] INFO: powershell_script[testDynamicCompressionLevel] ran successfully

    - execute "powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned -InputFormat None -File
"C:/Users/kbarry-x/AppData/Local/Temp/chef-script20140225-2672-jjmxxc.ps1"

and not the setting is '4', so the test evaluates as true

but when I chef-client again i get the same results, instead of a "skipped due to not_if"

 




Archive powered by MHonArc 2.6.16.

§