Re: [Puppet Users] Problem with Custom Facter

2012-02-21 Thread Matt Mencel
Hi Nathan,

Excellent!  Thanks for the tip.

Matt



On Mon, Feb 20, 2012 at 5:33 PM, Matt Mencel m...@techminer.net 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

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] Problem with Custom Facter

2012-02-20 Thread Matt Mencel
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'

Facter.add(:cis_yum_check) do
  timeout = 300
  setcode do
File.open(/tmp/yum_check-update, 'w') { |f| f.write(`/usr/bin/yum
check-update`) }
back_arr = []
f = `cat /tmp/yum_check-update`
f.lines.reverse_each { |line| back_arr  line }
#{back_arr.index(\n)} updates
  end
end

The output I get back in my fact reports only contains a string with 
 updates in it, so no number.  However, if I paste the code inside the
setcode block into a test.rb scriptit works just fine.

Can anyone tell me why I'm not getting the number in my fact?

Thanks,
Matt

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Problem with Custom Facter

2012-02-20 Thread Nathan Powell
On Mon, Feb 20, 2012 at 5:33 PM, Matt Mencel m...@techminer.net wrote:
 The output I get back in my fact reports only contains a string with 
  updates in it, so no number.  However, if I paste the code inside the
 setcode block into a test.rb scriptit works just fine.

Are you testing this code on the same version of EL that you are
deploying to?  AFACT #lines wasn't added until 1.8.7 and if you are
deploying to EL5 you don't have that.


-- 
Nathan Powell
Linux System Administrator

Where else would you rather be than right here, right now?
~ Marv Levy

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Problem with Custom Facter

2012-02-20 Thread Nathan Powell
On Mon, Feb 20, 2012 at 5:33 PM, Matt Mencel m...@techminer.net 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

-- 
Nathan Powell
Linux System Administrator

Where else would you rather be than right here, right now?
~ Marv Levy

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.