[Prev] Thread [Next]  |  [Prev] Date [Next]

[Puppet Users] Re: Problem with Custom Facter jcbollinger Tue Feb 21 07:01:58 2012

On Feb 20, 7:14 pm, Nathan Powell <[EMAIL PROTECTED]> wrote:
> On Mon, Feb 20, 2012 at 5:33 PM, Matt Mencel <[EMAIL PROTECTED]> wrote:
> > I am trying to write a custom facter for CentOS/RHEL that tells me how many
> > updates are found on a run of 'yum check-update'
> Sorry I replied hastily.  After replying I thought about what you're
> trying to do.  You don't need all those gyrations to get this data
> Tested quickly on RHEL6 and CentOS5:
> `sudo yum check-update -q`.split(/\n/).reject{|i| i == ""}.length


`yum -q check-update | grep '\\w' | wc --lines`.chomp

sudo is not needed to run yum queries, and avoiding sudo when you
don't need it is good practice.  Personally, I find that command a lot
more legible than the Ruby split / reject / length business, too,
though YMMV.

Also, I think you need to set the timeout inside your setcode block,
not outside.  Only that way can you be sure that you'll have the
desired timeout when the fact actually runs.  (Otherwise, you might
get the timeout that some other fact sets.)


You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at