FAQ
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.

Search Discussions

  • Andrew at Jan 30, 2014 at 4:56 am
    # every package, name only.
    rpm -qa --queryformat="%{NAME}\n"

    # or more info ...
    rpm -qa --queryformat="%{NAME} - %{VERSION} - %{ARCH}\n"

    Hi Stack,

    have you tried


    package { "kernel.$architecture":
       ensure => '2.6.32-358.el6',
    }


    to make sure it doesnt find the i686 version as well ?


    Also note that a reboot is required for a newly installed kernel version to become the running version,

    Also note that yum will keep upto 2 older versions of the kernel installed as recovery boot options in the grub kernel, so there is always more than one kernel-version present on the system.




    --
    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/f787e59d-ce8e-49f0-8dd6-fc95825b75d9%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Stack Kororā at Jan 30, 2014 at 11:59 am
    Greetings,
    Thanks for the response.

    The pkginventory is already doing this inside of util/pkg.rb:

    rpm -qa --qf %{NAME}"\t"%{VERSION}-%{RELEASE}

    I am fully aware of how multiple kernels work. As stated, the kernel was
    just an example. I need/want every package installed returned to me and the
    version of the pkginventory code currently listed in the forge is
    nondeterministic on what package version is returned when multiple versions
    exist. This is the problem for me.

    We have been running our mods in production for a few days now and things
    are running well.

    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/91bc1223-9c0a-40ce-886f-cc42685f7cda%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJan 24, '14 at 4:54a
activeJan 30, '14 at 11:59a
posts3
users2
websitepuppetlabs.com

2 users in discussion

Stack Kororā: 2 posts Andrew: 1 post

People

Translate

site design / logo © 2022 Grokbase