I have mixture of CentOS , 5.8, 5.7, 6.1, 6.3 , 4.7 Ubuntu, Debian, servers with me. I want all of them to have nrpe installed on them. the problem i am facing is that when i write puppet code to ensure the packe nrpe, it works fine on Centos 6+ , but when it runs on centos 5.8, the package name there is nrpe-nagio, and not nrpe.. I tried to do this in this way, but unable to perform the required checks.
package { "nrpe":
ensure => "installed",
name => $operatingsystem ? {
Ubuntu => "nagios-nrpe-server",
CentOS => "nrpe",
{
/^5/: {
package { "nagios-nrpe":
ensure => "installed", }
}
}
Debian => "nagios-nrpe-server",
}
}
How can i have nested checks for what i need?
thanks
Best Answer
Inline, nested case statements are a bad way to do this, and it's actively discouraged in Puppet (see Puppet Lint documentation).
The better way is this (I've guessed with
$::lsbdistrelease
as I don't have a RH system to-hand - you should runfacter
to determine the correct fact that gives you the major version).Explanation (links to Puppet Lint where appropriate):
::