Stack Kororā
2014-Jan-24 04:54 UTC
[Puppet Users] ody/pkginventory problem / How do _you_ get a listing of all packages installed on a system?
Greetings, I am using ody/pkginventory [http://forge.puppetlabs.com/ody/pkginventory] as a way of getting information about what rpms are installed on a system. I am using this module over `puppet resource package` for two reasons: 1) Having it as a fact helps some of the other things we are doing and I don't know if-it's-possible/how to get the results of a `puppet resource package` as a fact and 2) I can't seem to figure out how to query the puppetmaster puppetdb (using curl) and pull back a full listing of installed packages on a node but I _can_ get the facts this way. We made a few small modifications to this package to add the Scientific and SLES OS's (which both OS's work just fine; just need to make the change in both pkg.rb files) and rolled out this module to our dev environment. That is when I noticed a "problem". I realize I can get the "kernel" fact, I am just using the "kernel" package as an example as it is reproducible on many systems. The information I am really after is other packages which have the same problem. $ uname -r 2.6.32-431.1.2.el6.x86_64 $ facter -p | grep "pkg_kernel " pkg_kernel => 2.6.32-358.el6 $ puppet resource package kernel package { 'kernel': ensure => '2.6.32-358.el6', } $ rpm -qa | grep "^kernel-2" kernel-2.6.32-358.el6.x86_64 kernel-2.6.32-431.1.2.el6.x86_64 The problem is that neither the resource nor the module are returning the actual running kernel. In reality, I would like to know every package. My co-worker (who is a bit more familiar with Ruby then I am) made the following changes to lib/facter/pkg.rb: require 'facter/util/pkg' counter_hash = {} Facter::Util::Pkg.package_list.each do |key, value| if counter_hash[:"#{key}"].nil? counter_hash[:"#{key}"] = value else counter_hash[:"#{key}"] << ", #{value}" end end counter_hash.each do |key, value| Facter.add(:"pkg_#{key}") { setcode { value } } end This produces an output of : pkg_kernel => 2.6.32-358.el6, 2.6.32-431.1.2.el6 Much more desirable. So the question for this group is, before I roll this out to all my system does anyone have a better solution or suggestion on accomplishing this task? What I have after my co-workers mod works, but I am really curious how/if others are retrieving a list of all packages installed on a system. Thanks! -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/1570cc12-741a-40f3-bd3d-1cfbf5dbeb62%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.