Hi all, 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 ---------------------------- -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 01/24/2011 02:07 PM, Jonathan Gazeley wrote:> Hi all, > > 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.htmlDefine "properly" :-) What is puppet supposed to do with this piece of information? Log it somewhere? Regards, Felix -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On 24/01/11 13:31, Felix Frank wrote:> On 01/24/2011 02:07 PM, Jonathan Gazeley wrote: >> Hi all, >> >> 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 > > Define "properly" :-) What is puppet supposed to do with this piece of > information? Log it somewhere?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 >-- ---------------------------- Jonathan Gazeley Systems Support Specialist ResNet | Wireless & VPN Team IT Services University of Bristol ---------------------------- -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
am just curious as to why do you think that would be possible? Did you use some other "puppet type" to similarly obtain information? like get the size of a file, using File type? Thanks, Mohamed. On Mon, Jan 24, 2011 at 9:15 AM, Jonathan Gazeley <jonathan.gazeley@bristol.ac.uk> wrote:> On 24/01/11 13:31, Felix Frank wrote: >> >> On 01/24/2011 02:07 PM, Jonathan Gazeley wrote: >>> >>> Hi all, >>> >>> 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 >> >> Define "properly" :-) What is puppet supposed to do with this piece of >> information? Log it somewhere? > > 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 >> > > > -- > ---------------------------- > Jonathan Gazeley > Systems Support Specialist > ResNet | Wireless & VPN Team > IT Services > University of Bristol > ---------------------------- > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Just to clarify, I do not know the answer to your question... it''s just that I would not have had that question at all, so am wondering why :) On Mon, Jan 24, 2011 at 9:21 AM, Mohamed Lrhazi <lrhazi@gmail.com> wrote:> am just curious as to why do you think that would be possible? Did you > use some other "puppet type" to similarly obtain information? like get > the size of a file, using File type?-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
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! Cheers, Jonathan [1] http://docs.puppetlabs.com/guides/types/package.html On 24/01/11 14:21, Mohamed Lrhazi wrote:> am just curious as to why do you think that would be possible? Did you > use some other "puppet type" to similarly obtain information? like get > the size of a file, using File type? > > Thanks, > Mohamed. > > On Mon, Jan 24, 2011 at 9:15 AM, Jonathan Gazeley > <jonathan.gazeley@bristol.ac.uk> wrote: >> On 24/01/11 13:31, Felix Frank wrote: >>> >>> On 01/24/2011 02:07 PM, Jonathan Gazeley wrote: >>>> >>>> Hi all, >>>> >>>> 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 >>> >>> Define "properly" :-) What is puppet supposed to do with this piece of >>> information? Log it somewhere? >> >> 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 >>> >> >> >> -- >> ---------------------------- >> Jonathan Gazeley >> Systems Support Specialist >> ResNet | Wireless& VPN Team >> IT Services >> University of Bristol >> ---------------------------- >> >> -- >> 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+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> >> >-- ---------------------------- Jonathan Gazeley Systems Support Specialist ResNet | Wireless & VPN Team IT Services University of Bristol ---------------------------- -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
----- 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.> > Cheers, > Jonathan > > > [1] http://docs.puppetlabs.com/guides/types/package.html > > On 24/01/11 14:21, Mohamed Lrhazi wrote: > > am just curious as to why do you think that would be possible? Did > > you > > use some other "puppet type" to similarly obtain information? like > > get > > the size of a file, using File type? > > > > Thanks, > > Mohamed. > > > > On Mon, Jan 24, 2011 at 9:15 AM, Jonathan Gazeley > > <jonathan.gazeley@bristol.ac.uk> wrote: > >> On 24/01/11 13:31, Felix Frank wrote: > >>> > >>> On 01/24/2011 02:07 PM, Jonathan Gazeley wrote: > >>>> > >>>> Hi all, > >>>> > >>>> 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 > >>> > >>> Define "properly" :-) What is puppet supposed to do with this > >>> piece of > >>> information? Log it somewhere? > >> > >> 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 > >>> > >> > >> > >> -- > >> ---------------------------- > >> Jonathan Gazeley > >> Systems Support Specialist > >> ResNet | Wireless& VPN Team > >> IT Services > >> University of Bristol > >> ---------------------------- > >> > >> -- > >> 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+unsubscribe@googlegroups.com. > >> For more options, visit this group at > >> http://groups.google.com/group/puppet-users?hl=en. > >> > >> > > > > > -- > ---------------------------- > Jonathan Gazeley > Systems Support Specialist > ResNet | Wireless & VPN Team > IT Services > University of Bristol > ---------------------------- > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en.-- R.I.Pienaar -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Martijn Grendelman
2011-Jan-24 15:02 UTC
Re: [Puppet Users] Check version of installed RPM
Hi,> 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. -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Jan 24, 5:07 am, Jonathan Gazeley <jonathan.gaze...@bristol.ac.uk> wrote:> Hi all, > > Is there a way to use the Package type to find the version number of an > installed RPM?Have you seen ''ralsh'', or ''puppet resource''[1]? You can use these interactively to interrogate the state of a system, ''puppet resource package foo''. I don''t recall if the common Package providers ouput more than ''ensure => absent|present". It''s up to your provider (rpm, fbsd, etc) to provide the state information in it''s instances method. I imagine many will only test presence, for speed. It should perfectly reasonable to fork and create your own copy of the provider that queries for versions etc. [1] http://docs.puppetlabs.com/guides/tools.html#puppet-resource-or-ralsh -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.