versioncmp.rb example

68 views
Skip to first unread message

samra...@aim.com

unread,
Mar 11, 2014, 9:01:46 PM3/11/14
to puppet...@googlegroups.com
I looked at versioncmp example available out of box.

It is like strcmp.
I have a need to write a manifest to check for the existence of java version. If it is 1.5.0.3 or less, upgrade to 1.7.1. This should be done on 10 nodes.

Appreciate any example to accomplish this task. thanks

Nikola Petrov

unread,
Mar 21, 2014, 5:11:47 AM3/21/14
to puppet...@googlegroups.com
Create a custom fact for the java version installed. There are some
suggestions here
https://groups.google.com/forum/#!topic/puppet-users/W67dvqS-GdU
then you do something like the following:

$new_version = versioncmp($::java_version, '1.5.0.3') ? {
1 => '1.7.1',
default => $::java_version
}

package { 'jdk':
ensure => $new_version
}

note that this is not tested ;)

--
Nikola
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/8D10BA5C66CB3D1-318-35AA7%40webmail-m260.sysops.aol.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages