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)
$ntp_service = $ntpdaemon {
case operatingsystem {
''CentOS'' {
case operatingsystemrelease {
''5.5'' => "ntpd",
''6.0'' => "ntpd"
}
}
''RedHat'' {
case operatingsystemrelease {
''5.5'' => "ntpd",
''6.0'' => "ntpd"
}
}
''SLES'' {
case operatingsystemrelease {
''10.1'' => "ntp",
''10.2'' => "ntp",
''10.3'' => "ntp",
''11.0'' => "ntp",
''11.1'' => "ntp"
}
}
}
}
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
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) > > $ntp_service = $ntpdaemon {Hi, I believe the above line lacks a ''?''. $ntp_service = $ntpdaemon ? { 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?) HTH, Felix -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.