Skip to content

Instantly share code, notes, and snippets.

@jumanjiman
Created February 15, 2012 22:14
Show Gist options
  • Save jumanjiman/1839393 to your computer and use it in GitHub Desktop.
Save jumanjiman/1839393 to your computer and use it in GitHub Desktop.
generate a facter fact for every package on a host
IO.popen("/bin/rpm -qa --qf='%{name} '").read.split(' ').each do |package|
Facter.add("yum_#{package}_version") do
setcode do
puts IO.popen("/bin/rpm -q --qf=\'%|epoch?{%{epoch}}:{0}|:%{version}-%{release}.%{arch}\' #{package}").read
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment