Changes between Version 4 and Version 5 of FacterTweaks


Ignore:
Timestamp:
Mar 14, 2011 5:09:06 PM (13 years ago)
Author:
plazonic
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FacterTweaks

    v4 v5  
    1111
    1212== New facts distributing ==
    13 To distribute your new facts to puppet clients make a module (preferably the one where you are using this fact, e.g.
     13To distribute your new facts to puppet clients make a module (preferably the one where you are using this fact), e.g.
    1414{{{
    1515$ mkdir -p /etc/puppet/modules/myfirst_module/lib/facter
     
    5353[root@host ~]#
    5454}}}
     55== Kernel versions fact ==
     56This fact requires [http://rubyforge.org/projects/ruby-rpm/ rubygem ruby-rpm].  Either install it from source or if you are using a RHEL 6 based distro (like PUIAS 6 or any other clone) please feel free to use the relevant rpm from our unsupported repo (rubygem-ruby-rpm-1.3.0-* from [http://puias.princeton.edu/data/puias/unsupported/6/ repository]):
     57{{{
     58require 'rubygems'
     59require 'rpm'
     60
     61begin
     62        Facter.architecture
     63rescue
     64        Facter.loadfacts()
     65end
     66db = RPMdb.open()
     67allkernels=db.package("kernel").collect { |x| RPM::Version.new(x[1]+"-"+x[2]) }.sort
     68db.close()
     69
     70Facter.add("kernelnewest") do
     71        confine :kernel => :linux
     72        setcode do
     73                allkernels[-1].v+"-"+allkernels[-1].r+"."+Facter.architecture
     74        end
     75end
     76
     77Facter.add("kerneloldest") do
     78        confine :kernel => :linux
     79        setcode do
     80                allkernels[0].v+"-"+allkernels[0].r+"."+Facter.architecture
     81        end
     82end
     83}}}
     84This fact provides kernelnewest and kerneloldest facts.  They can be used, together with kernelrelease fact, in puppet recipes to figure out whether the puppet client is currently running the latest kernel version as well as whether there are alternate versions of the kernel installed.  Example recipes that use this module will be posted on the [wiki:PuppetTweaks puppet recipes page].