| 55 | == Kernel versions fact == |
| 56 | This 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 | {{{ |
| 58 | require 'rubygems' |
| 59 | require 'rpm' |
| 60 | |
| 61 | begin |
| 62 | Facter.architecture |
| 63 | rescue |
| 64 | Facter.loadfacts() |
| 65 | end |
| 66 | db = RPMdb.open() |
| 67 | allkernels=db.package("kernel").collect { |x| RPM::Version.new(x[1]+"-"+x[2]) }.sort |
| 68 | db.close() |
| 69 | |
| 70 | Facter.add("kernelnewest") do |
| 71 | confine :kernel => :linux |
| 72 | setcode do |
| 73 | allkernels[-1].v+"-"+allkernels[-1].r+"."+Facter.architecture |
| 74 | end |
| 75 | end |
| 76 | |
| 77 | Facter.add("kerneloldest") do |
| 78 | confine :kernel => :linux |
| 79 | setcode do |
| 80 | allkernels[0].v+"-"+allkernels[0].r+"."+Facter.architecture |
| 81 | end |
| 82 | end |
| 83 | }}} |
| 84 | This 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]. |