Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
up vote 3 down vote accepted

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 run facter to determine the correct fact that gives you the major version).

$nrpe_package = $::osfamily ? {
  'Debian' => 'nagios-nrpe-server'
  'RedHat' => $::lsbdistrelease ? {
    '5'     => 'nagios-nrpe',
    default => 'nrpe',
  default => 'nrpe',

package { 'nrpe':
  ensure => installed,
  name   => $nrpe_package,

Explanation (links to Puppet Lint where appropriate):

share|improve this answer

You can use facter and some if/else conditions to tell Puppet which class you want to apply to each version of CentOS.

Example :

(Just use your OS version instead of the OS in the example provided).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.