Wed, 14 Mar 2007
Playing with Facter
I'm on-call tonight so I invested some time in facter, "A
cross-platform Ruby library for retrieving facts from operating
systems." While facter is an interesting command line program
(its extension mechanism is quite nice) its main claim to fame is that
it's used by puppet (which I'm slowly evaluating as a CFEngine
replacement) to determine facts about a machine.
While the docs are a little light on the ground the tgz contains a couple
of examples and after some playing around I think I've got a basic Linux
Bonding fact ready. For your viewing pleasure, the
Facter Linux Network
Bonding custom fact. It's not amazingly powerful or complex but it does
seem to do what I want and it gave me a reason to look around the Ruby
Dir class so it's not all bad. I've mostly put it up to show
how easy it is for someone with very little ruby knowledge to extend
facter.
Note: I also discovered that you can't do a confine :bonding =>
:true, facter works on literal string values, not on true or false.
Like this post? - Digg Me! | Add to del.icio.us! | reddit this!
Posted: 2007/03/14 23:20 | /ruby | Permanent link to this entry | This entry + same date
Mon, 12 Mar 2007
daemon_percentages.rb and Ruby Autovivification
Both Jim Weirich and
Ben Summers were kind enough to
email me about my Daemon
Logging Percentages and Playing with Ruby Idioms post. They sent
me an explanation on how to do the hash assignment in a way I find much
nicer, so with no more delays I present - Option 4:
tally = Hash.new(0)
tally[daemon] += 1
It really is that simple - and I still missed it by a mile. I've updated the script to use this and I wanted to say thank you for the pointer, so thank you both.
Like this post? - Digg Me! | Add to del.icio.us! | reddit this!
Posted: 2007/03/12 21:06 | /ruby | Permanent link to this entry | This entry + same date

