From 07983865176636bc52c92d27021a9f5639f14ea1 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 17 Jul 2015 15:41:14 +1000 Subject: [PATCH] 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 --- manifests/cgroups.pp | 2 +- manifests/params.pp | 4 ++-- manifests/plugin.pp | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifests/cgroups.pp b/manifests/cgroups.pp index e379c60..d878d79 100644 --- a/manifests/cgroups.pp +++ b/manifests/cgroups.pp @@ -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, diff --git a/manifests/params.pp b/manifests/params.pp index 12a2a60..e5a411c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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'], diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 03bb4c5..ac1be8c 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -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 {