Is there a way to use the Package type to find the version number of an
installed RPM?
I've consulted this page [1] and I can't see any documentation there
that says this might be possible.
I want to simply query my package manager and ask which version of a
package is installed. I do not necessarily wish to ensure it is
upgraded, etc.
I know it's possible to do this with an exec call to rpm or yum, but I
want to do it "properly" :)
[1] http://docs.puppetlabs.com/guides/types/package.html
Cheers,
Jonathan
----------------------------
Jonathan Gazeley
Systems Support Specialist
ResNet | Wireless & VPN Team
IT Services
University of Bristol
----------------------------
Define "properly" :-) What is puppet supposed to do with this piece of
information? Log it somewhere?
Regards,
Felix
I want to place the version number in a variable, where it will be used
to do some post-install config that depends on the version number :)
By "properly" I meant to avoid exec calls unless as a last resort.
Cheers,
Jonathan
>
> Regards,
> Felix
>
--
Thanks,
Mohamed.
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>
The data (the version number) is clearly there, I just need a way of
getting at it!
Cheers,
Jonathan
[1] http://docs.puppetlabs.com/guides/types/package.html
>> ResNet | Wireless& VPN Team
----- Original Message -----
> On this page [1] it says that using Package with yum as a backend is
> "versionable", i.e. "The provider is capable of interrogating the
> package database for installed version(s), and can select which out of
> a
> set of available versions of a package to install if asked."
>
> The data (the version number) is clearly there, I just need a way of
> getting at it!
The puppet model is not that the machine tells you what packages are on it
but that you tell the machine what state it should be in.
So lets say you're installing Foo then using puppet manifests you tell
the machine to install version 1.2.3. This is data in your manifests and
you should be able to use that data in other areas of your manifests if
lets say you stored it in extlookup or an external node classifier or even
node level variable.
The yum provider is versionable which means you can tell it to install version
1.2.3 of something and it will verify and ensure that version is there.
You need to think how you build machines from a different direction, you need
to think how you tell the machine its desired state rather than the machine
tell you what it is and then you make decisions based on that.
All that being said, if its just one or two packages you care about you can
simply add a fact for the package versions, but this fact will only show the
version on the next puppet run not the one during which you install said package
since the compile stage of the puppet run is happening on the master prior to
installing the package.
--
R.I.Pienaar
> All that being said, if its just one or two packages you care about you can
> simply add a fact for the package versions, but this fact will only show the
> version on the next puppet run not the one during which you install said package
> since the compile stage of the puppet run is happening on the master prior to
> installing the package.
Merely from an 'inventory' point of view, I felt the need to have facts
for reporting versions of installed packages. I wrote the following code,
that creates facts for package versions, based on a file that lists the
packages I am interested in on a particular server. This file can, of
course, be managed by puppet.
martijn:puppet> cat modules/common/lib/facter/package_versions.rb
require 'puppet'
package_list = "/etc/facter/package_versions_list"
if File.exist?(package_list)
File.readlines(package_list).each do |l|
l.strip!
@pname = ""
l.split.each do |p|
if @pname.eql? ""
@pname = p
end
pkg = Puppet::Type.type(:package).new(:name => p)
v = pkg.retrieve[pkg.property(:ensure)].to_s
if !v.eql? "purged" and !v.eql? "absent"
Facter.add("pkg_" + @pname + "_version") do
setcode do
v
end
end
end
end
end
end
martijn@server002:~> cat /etc/facter/package_versions_list
postgresql
php5-common
mysql-server mysql-server-5.1 mysql-server-5.0
Regards,
Martijn.