= Facter Tweaks = == New facts testing == While you are writing new facts please refer to [http://docs.puppetlabs.com/guides/custom_facts.html puppetlabs documentation]. In short do something like: {{{ $ mkdir -p ~/lib/ruby/facter ; export RUBYLIB=~/lib/ruby $ cp /path/to/hardware_platform.rb $RUBYLIB/facter $ facter hardware_platform SUNW,Sun-Blade-1500 }}} == New facts distributing == To distribute your new facts to puppet clients make a module (preferably the one where you are using this fact, e.g. {{{ $ mkdir -p /etc/puppet/modules/myfirst_module/lib/facter cp myfirstfact.rb /etc/puppet/modules/myfirst_module/lib/facter }}} If you are distributing facts this way you can test them on the client by setting FACTERLIB environment variable: {{{ export FACTERLIB=/var/lib/puppet/lib/facter facter }}} == videocard fact == This ruby snippet adds a videocard fact to facter. You can use this fact to decide if you need to install any proprietary video card drivers. Place in /usr/lib/ruby/site_ruby/1.8/facter/videocard.rb {{{ #!ruby # Josko Plazonic - lifted from Josko March 14, 2011 by Thomas Uphill require 'facter' Facter.add("videocard") do confine :kernel => :linux ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin" setcode do controllers = [] lspciexists = system "/bin/bash -c 'which lspci >&/dev//null'" if $?.exitstatus == 0 output = %x{lspci} output.each {|s| controllers.push($1) if s =~ /VGA compatible controller: (.*)/ } end controllers end end }}} After installing you should be able to see the fact like so: {{{ [root@host ~]# facter |grep video videocard => Intel Corporation 82945G/GZ Integrated Graphics Controller (rev 02) [root@host ~]# }}}