Hi Richie,
Using the iptables_version fact thats part of the puppetlabs firewall
module, you can tweak that to change the command to return the rpm version
as in Dan's example.
The below code will return the full version string for the sqlite rpm
Jacob
Facter.add(:sqlite_version) do
confine :kernel => :linux
setcode do
version = Facter::Util::Resolution.exec('rpm -q --qf
\'%{version}-%{release}-%{arch}\' sqlite')
if version
version.match(/^\d+.*$/).to_s
else
nil
end
end
end
On 16 November 2013 00:24, Dan White <[email protected]> wrote:
> OK. Time for a possibly silly question:
>
> How are you getting the name of the RPM into the Ruby code ?
>
>
> “Sometimes I think the surest sign that intelligent life exists elsewhere
> in the universe is that none of it has tried to contact us.”
> Bill Waterson (Calvin & Hobbes)
>
> ------------------------------
> *From: *"Richie Rees" <[email protected]>
> *To: *[email protected]
> *Sent: *Friday, November 15, 2013 8:57:29 AM
> *Subject: *Re: [Puppet Users] Problems with Fact returning the version of
> an installed RPM.
>
>
> Thanks Ygor, gold stars for you and pints of beer, unfortunately this
> still doesn't return the version to the fact. Do i have to pass the
> resulting string to a variable and then pass the variable back ?
>
>
>
> On Friday, 15 November 2013 12:46:13 UTC, Ygor wrote:
>>
>> http://www.rpm.org/wiki/Docs/QueryFormat
>>
>> rpm -qa --queryformat '%{version}\n' rpm_name
>>
>> “Sometimes I think the surest sign that intelligent life exists elsewhere
>> in the universe is that none of it has tried to contact us.”
>> Bill Waterson (Calvin & Hobbes)
>>
>> ------------------------------
>> *From: *"Richie Rees" <[email protected]>
>> *To: *[email protected]
>> *Sent: *Friday, November 15, 2013 6:31:13 AM
>> *Subject: *[Puppet Users] Problems with Fact returning the version of an
>> installed RPM.
>>
>> Hi,
>>
>> Have written what I think is a simple fact to return the version of an
>> installed RPM, but when I use the returned variable its blank so perhaps
>> someone can point me in the write direction, or somone might know a better
>> way to do this. Here is the fact :-
>>
>> require 'facter'
>> Facter.add('rpmbversion') do
>> setcode do
>> Facter::Util::Resolution.exec("rpm -qia rpm_name | grep Version | sed
>> 's/Version : //g' |cut -f1-5 -d' '")
>> end
>> end
>>
>>
>> Thanks in Advance :)
>>
>> Richie.
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/puppet-users/3c1bbea6-9333-46d3-9f4e-c49206cc284d%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/814610a1-b722-4834-8fe7-af7650f25142%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/493959620.4560965.1384525444271.JavaMail.root%40sz0126a.westchester.pa.mail.comcast.net
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/CAOQMBgzkMVEVNcv-nR9yMMAR52eC0nqUCNcCqponB45Hoq%2BuMg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.