User versioncmp to compare strings

Use versioncmp, otherwise with puppet 4 (as on Fedora 22) you get "A
String is not comparable to a non String".

We also inverted the versioncmp check for the version variable, the
main reason for this was to reduce complexity of the versioncmp code.

Additionally, defining 0 to be the latest version didn't really make
sense.  So, changing it to use 'latest' means better code readability.

Change-Id: Ic8b0fd2a19cbb90e1d57e3025a3d2513ebada2e2
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Ian Wienand 2015-07-17 15:41:14 +10:00 committed by Paul Belanger
parent 3651901d10
commit 0798386517
3 changed files with 7 additions and 8 deletions

View File

@ -36,7 +36,7 @@ class jenkins::cgroups {
# Starting with Ubuntu Quantal (12.10) cgroup-bin dropped its upstart jobs.
if $::osfamily == 'Debian' {
if $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease >= '12.10' {
if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '12.10') >= 0 {
file { '/etc/init/cgconfig.conf':
ensure => present,

View File

@ -7,7 +7,7 @@ class jenkins::params {
'RedHat': {
#yum groupinstall "Development Tools"
# common packages
if ($::operatingsystem == 'Fedora') and ($::operatingsystemrelease >= 21) {
if ($::operatingsystem == 'Fedora') and (versioncmp($::operatingsystemrelease, '21') >= 0) {
$jdk_package = 'java-1.8.0-openjdk-devel'
} else {
$jdk_package = 'java-1.7.0-openjdk-devel'
@ -17,7 +17,7 @@ class jenkins::params {
# FIXME: No Maven packages on RHEL
#$maven_package = 'maven'
$cgroups_package = 'libcgroup'
if ($::operatingsystem == 'Fedora') and ($::operatingsystemrelease >= 19) {
if ($::operatingsystem == 'Fedora') and (versioncmp($::operatingsystemrelease, '19') >= 0) {
$cgroups_tools_package = 'libcgroup-tools'
$cgconfig_require = [
Package['cgroups'],

View File

@ -18,19 +18,18 @@
#
define jenkins::plugin(
$version=0,
$version='latest',
$pin=false,
) {
$plugin = "${name}.hpi"
$plugin_dir = '/var/lib/jenkins/plugins'
$plugin_parent_dir = '/var/lib/jenkins'
if ($version != 0) {
if ($version == 'latest') {
$base_url = 'http://updates.jenkins-ci.org/latest'
} else {
$base_url = "http://updates.jenkins-ci.org/download/plugins/${name}/${version}"
}
else {
$base_url = 'http://updates.jenkins-ci.org/latest'
}
if (!defined(File[$plugin_dir])) {
file {