Puppet & Oracle Enterprise Linux – When Modules Fail

Puppet & Oracle Linux – Fixing those failing manifests!

  • OS: Oracle Enterprise Linux 6.3 / 6.4
  • Puppet: Puppet 3.1.1
  • Facter 1.6 or Higher

Puppet runs great on OEL 6, there really isn’t any pain to implementing it until you get to installing some modules – a lot of them simply don’t know what OEL or OracleLinux is. The fix however, is pretty straightforward and easy if you run current versions of facter and puppet.

First thing you want to do, is validate that you have a current version of facter that has osfamily fact.

[bmiller@puppet ~]$ facter | grep osfamily
osfamily => RedHat
[bmiller@puppet ~]$

If you have the osfamily support, you will want to edit the manifest that is failing. We will use The Foreman for an example.  The Foreman 1.1 has multiple setup files that implement the following code: (you will often find these in install.pp manifests or if you run “puppet agent -t -noop” it should show the failing manifest during a puppet run)

class apache::install {
  case $::operatingsystem {
    redhat,centos,fedora,Scientific: {
      $http_package = 'httpd'
    }
    Debian,Ubuntu: {
      $http_package = 'apache2'
    }
    default: {
      fail("${::hostname}: This module does not support operatingsystem ${::operatingsystem}")
    }
  }

  package { $http_package:
    ensure => installed,
    alias  => 'httpd'
  }
}
This code fails miserably that “OracleLinux  isn’t a supported Operating System. The fix? Instead of looking for each and every type of RedHat Distro and adding more OS Variants to check for (some have a LONG list), use facter to get the $osfamily.  It is as simple as this code snippet:
class apache::install {
  case $::osfamily {
    RedHat: {
      $http_package = 'httpd'
    }
    Debian: {
      $http_package = 'apache2'
    }
    default: {
      fail("${::hostname}: This module does not support operatingsystem ${::osfamily}")
    }
  }

  package { $http_package:
    ensure => installed,
    alias  => 'httpd'
  }
}

I’ve submitted the fixes to the foreman, so future versions can install without a hitch and I hope other developers start implementing the “osfamily” check in lieu of “operatingsystem” checks. The osfamily check makes cleaner code and happier admins :)

Hope this helps other people running into issues on OEL / Oracle Linux / OracleLinux (Or whatever they want to call it!)

About these ads

2 thoughts on “Puppet & Oracle Enterprise Linux – When Modules Fail

  1. Jim Burnett says:

    Ahh ha! Another puppetteer! In theory, Puppet could be configured to be OS independent. Can’t you define custom package managers?

    How’s the Oracle Linux treating you these days?

    • byronm says:

      I think OS Family solved a big problem with trying to implement OS checks in your DSL, but you’re right, they could go one step further and internalize the abstractions so the DSL is the same regardless of the OS. From a developers perspective I could see a positive use case for a single unified package definition so they don’t need to know the OS particulars, but from a SYSADMIN role I could see why they would be leery of yet another abstraction that means multiple ways of getting the same thing done.

      As for Oracle Linux, i’d say its probably their best kept secret. Pretty much lock step with RHEL but free fixes and if you do need support, you can get support fairly cheap or “Free” with a hardware purchase. I don’t really bother with the UEK side, but since we already run a LOT of Oracle Products, it just made sense.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 511 other followers

%d bloggers like this: