Hello,

I am in the process of "trying out" Puppet, and so far, it is going really 
well, and I can see a clear line of how we can use it internally.

I do have one question though with regard to the using the onlyif parameter 
of the exec command (as per here 
http://docs.puppetlabs.com/references/latest/type.html#exec).

Ideally, what I would like to do is to only run a PowerShell exec command, 
if a web page doesn't currently exist on the server (i.e. the PowerShell 
script is responsible for deploying the Web Pages (into SharePoint in this 
case) and I only want to run this step, if these pages don't already exist. 
 To that end, I have done something like this:

onlyif => '$webRequest = 
[System.Net.WebRequest]::Create("http://some-url.test.aspx";); 
$webRequest.UseDefaultCredentials = $true; try { 
if([int]$webRequest.GetResponse().StatusCode -eq "200") { exit 0; } else { 
exit 1; } } catch [System.Net.WebException] { exit 1; }'

Which, at the command line, has the correct result.  However, when I try to 
run this, I get an error saying that $webRequest is not recognised.

Which leads me to think that using variables within the onlyif is not 
supported.  Is that correct?  If so, what is the best approach for doing 
this, or am I going up the wrong path?

Thanks in advance!

Gary

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to