On Jan 21, 1:55 pm, Felix Frank <felix.fr...@alumni.tu-berlin.de>
wrote:
> On 01/21/2011 07:31 PM, Jockster wrote:
>
> > I am writing my first module for ntp, I have a few different versions
> > of Linux and also releases. The code worked when I only had one flavor
> > of Linux but now I have four and possibly more flavors. My snippet
> > that doesn't work is as follows; ( I am not even sure this is the
> > route I should be going if anyone has a better way please advise.
> > Thank you in advance)

> But I'm not entirely sure this syntax is valid in variable assignments
> (which is not the same as assigning resource parameter values, is it?)

Yes, selectors are fine for variable assignment. But you seem to be
mixing a case and a selector[1]. Those are similar, but subtly
different.

I'm, *ahem*, just getting home but I think this may do what you're
after?
case $operatingsystem  {
    'CentOS','RedHat': {
        $ntp_service = $operatingsystemrelease ? {
            /5.5|6.0/     => "ntpd"
        }
    }
    'SLES': {
        $ntp_service = $operatingsystemrelease ? {
            /10.[1-3]|11.[0-1]/ => "ntp"
        }
    }
}

To reduce that further I might go for something like:
$ntp_service = $operatingsystem ? {
    /CentOS|RedHat/ => 'ntpd',
    'SLES'          => 'ntp'
}
Deal with the specific versions when you need to . Instead of '5.5' or
'6.0' why not catch all CentOS & RedHat versions?

And, if youre doing that, simply define exceptions and let the rest
fall through to a default value:
$ntp_service = $operatingsystem ? {
    'SLES'  => 'ntp',
    default => 'ntpd'
}

[1] http://docs.puppetlabs.com/guides/language_tutorial.html#selectors

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

Reply via email to