Facter Strings to integer.

1,302 views
Skip to first unread message

Paul.S...@barcap.com

unread,
Mar 18, 2013, 12:16:41 PM3/18/13
to puppet...@googlegroups.com
Hello,

If I want to do something like this:-

if $::lsbdistrelease >= 6.3 {
  SOMETHING
}

Do I have to convert lsbdistrelease from a string to a number with an inline template or some such ?

Thanks
Paul

Alessandro Ogier

unread,
Mar 18, 2013, 12:25:21 PM3/18/13
to puppet...@googlegroups.com
Hi, you can use versioncmp(), it's a builtin function

http://docs.puppetlabs.com/references/latest/function.html#versioncmp



ciao,
--
Alessandro Ogier
Specialista Reti e Sistemi - Area Ricerca
Direzione ICT Gruppo IEO/CCM

Istituto Europeo di Oncologia
Via Serio, 15 - 20139 Milan, Italy
P +39 02 94375269
E alessand...@ieo.eu
W http://www.ieo.it

尹川51web

unread,
Mar 18, 2013, 8:49:08 PM3/18/13
to puppet...@googlegroups.com
thanks ,that's help me, too!




--
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 post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.





--
尹川
成都世纪东方网络通信有限公司
手机:18628014224
QQ:254113859

jcbollinger

unread,
Mar 19, 2013, 11:23:03 AM3/19/13
to puppet...@googlegroups.com

Generally speaking, yes.  All fact values are strings, and the language docs specify that the behavior of the <, <=, >=, and > operators is undefined for strings.  For this particular case, however, Alessandro Ogier's suggestion to use the versioncmp() function is an excellent one.  Not only is it easy to use, but it still does what you (probably) want when you compare against, say, version 6.11.


John

Reply all
Reply to author
Forward
0 new messages