Joshua Anderson wrote:
> Case statements don't work inside of resource definitions. There are  
> three ways I can think of do what you're doing:
> 
> 1. Use multiple inline selectors. (Very long and ugly.)
> 2. Write four different definitions of the NTP service and wrap them  
> in a case statement (Not as long, but still ugly.)
> 3. Use if statements to set some variables, then use those in a single  
> NTP service definition. (Shorter, maybe less ugly.)
> 
> Here's an example of number 3:
> 
> case $lsbdistcodename {
>    "sarge": {
>      $ntp = "ntp-server"
>    }
>    default: {
>      $ntp = "ntp"
>    }
> }
> 
> if ($virtual == "physical") or ($virtual == "xen0") {
>    $ntp_enable = "true"
>    $ntp_ensure = "running"
> }
> 
> if ($virtual == "xenu") or ($virtual == "openvz") {
>    $ntp_enable = "false"
>    $ntp_ensure = "stopped"
> }
> 
> service { $ntp:
>    ensure => $ntp_ensure,
>    enable => $ntp_enable,
>    pattern => "ntpd"
> }


Thats odd, last week I had thought this was working, now monday morning is 
here and I get:

err: Could not retrieve configuration: Could not parse for environment 
production: Syntax error at '('; expected ')' at 
/etc/puppet/manifests/classes/local_services.pp:12

It looks as if theres something wrong with the conditional still


My code looks like this, which is same as yours but in a class:

class local_services {

   case $lsbdistcodename {
     "sarge": {
       $ntp = "ntp-server"
     }
     default: {
       $ntp = "ntp"
     }
   }

   if ($virtual == "physical") or ($virtual == "xen0") {
     $ntp_enable = "true"
     $ntp_ensure = "running"
   }

   if ($virtual == "xenu") or ($virtual == "openvz") {
     $ntp_enable = "false"
     $ntp_ensure = "stopped"
   }

   service { $ntp:
     ensure => $ntp_ensure,
     enable => $ntp_enable,
     pattern => "ntpd"
   }

}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to