From 4b0d5b04319abfcdd5ef3a80b31f7728900f358e Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Sat, 18 Mar 2017 23:16:30 +0100 Subject: [PATCH] Attempt to fix version comparisons Use versioncmp function instead of string comparison. Thanks olasd. --- modules/acpi/manifests/init.pp | 2 +- modules/apache2/manifests/init.pp | 2 +- modules/apache2/manifests/site.pp | 2 +- modules/apache2/templates/default-debian.org.erb | 2 +- modules/apache2/templates/puppet-config.erb | 2 +- modules/bacula/manifests/client.pp | 2 +- modules/debian_org/manifests/apt.pp | 4 ++-- modules/debian_org/manifests/init.pp | 2 +- modules/debian_org/templates/dsa-puppet-stuff.cron.erb | 2 +- modules/ferm/manifests/init.pp | 4 ++-- modules/ferm/templates/ferm.conf.erb | 2 +- modules/monit/manifests/init.pp | 2 +- .../templates/obsolete-packages-ignore.d-hostspecific.erb | 2 +- modules/samhain/templates/samhainrc.erb | 2 +- modules/ssh/manifests/init.pp | 2 +- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/acpi/manifests/init.pp b/modules/acpi/manifests/init.pp index f2c621b32..2a4fc1563 100644 --- a/modules/acpi/manifests/init.pp +++ b/modules/acpi/manifests/init.pp @@ -1,6 +1,6 @@ class acpi { if ! ($::debarchitecture in ['kfreebsd-amd64', 'kfreebsd-i386']) { - if ($::lsbmajdistrelease >= '8') { + if (versioncmp($::lsbmajdistrelease, '8') >= 0) { package { 'acpid': ensure => purged } diff --git a/modules/apache2/manifests/init.pp b/modules/apache2/manifests/init.pp index 19400ad6d..b0bde4134 100644 --- a/modules/apache2/manifests/init.pp +++ b/modules/apache2/manifests/init.pp @@ -105,7 +105,7 @@ class apache2 { apache2::module { 'mpm_prefork': ensure => absent } apache2::module { 'mpm_worker': } } - if $::lsbmajdistrelease > '7' { + if versioncmp($::lsbmajdistrelease, '7') > 0 { file { '/etc/apache2/mods-available/mpm_worker.conf': content => template('apache2/mpm_worker.erb'), } diff --git a/modules/apache2/manifests/site.pp b/modules/apache2/manifests/site.pp index ff1ee20e1..6d5ec55f3 100644 --- a/modules/apache2/manifests/site.pp +++ b/modules/apache2/manifests/site.pp @@ -46,7 +46,7 @@ define apache2::site ( } } - if $::lsbmajdistrelease <= '7' { + if versioncmp($::lsbmajdistrelease, '7') <= 0 { $symlink = "/etc/apache2/sites-enabled/${name}" } else { $symlink = "/etc/apache2/sites-enabled/${name}.conf" diff --git a/modules/apache2/templates/default-debian.org.erb b/modules/apache2/templates/default-debian.org.erb index dff8a4ffe..0c9eff39a 100644 --- a/modules/apache2/templates/default-debian.org.erb +++ b/modules/apache2/templates/default-debian.org.erb @@ -10,7 +10,7 @@ CustomLog /var/log/apache2/access.log privacy DocumentRoot /srv/www/default.debian.org/htdocs - <% if @lsbmajdistrelease > '7' -%> + <% if scope.call_function('versioncmp', [@lsbmajdistrelease, '7']) > 0 -%> Require all granted diff --git a/modules/apache2/templates/puppet-config.erb b/modules/apache2/templates/puppet-config.erb index 7edde691c..7c38884a5 100644 --- a/modules/apache2/templates/puppet-config.erb +++ b/modules/apache2/templates/puppet-config.erb @@ -4,7 +4,7 @@ # this is a list that seems suitable as of 2014-10, when running wheezy. It # probably requires re-visiting regularly. - <% if @lsbmajdistrelease <= '7' -%> + <% if scope.call_function('versioncmp', [@lsbmajdistrelease, '7']) <= 0 -%> SSLCipherSuite ECDH+AESGCM:ECDH+AES256:ECDH+AES128:ECDH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!eNULL:!LOW:!MD5:!EXP:!RC4:!SEED:!DSS <% else -%> SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!eNULL:!LOW:!MD5:!EXP:!RC4:!SEED:!DSS diff --git a/modules/bacula/manifests/client.pp b/modules/bacula/manifests/client.pp index 05234fc9b..2918a7938 100644 --- a/modules/bacula/manifests/client.pp +++ b/modules/bacula/manifests/client.pp @@ -50,7 +50,7 @@ class bacula::client inherits bacula { require => Package['bacula-fd'], notify => Service['bacula-fd'], } - if ($::lsbmajdistrelease >= '9' and $systemd) { + if (versioncmp($::lsbmajdistrelease, '9') >= 0 and $systemd) { file { '/etc/systemd/system/bacula-fd.service.d': ensure => directory, mode => '0755', diff --git a/modules/debian_org/manifests/apt.pp b/modules/debian_org/manifests/apt.pp index 9fc02a0b2..948f606ea 100644 --- a/modules/debian_org/manifests/apt.pp +++ b/modules/debian_org/manifests/apt.pp @@ -3,7 +3,7 @@ # Stuff common to all debian.org servers # class debian_org::apt { - if $::lsbmajdistrelease <= '7' { + if versioncmp($::lsbmajdistrelease, '7') <= 0 { $mungedcodename = $::lsbdistcodename } elsif ($::debarchitecture in ['kfreebsd-amd64', 'kfreebsd-i386']) { $mungedcodename = "${::lsbdistcodename}-kfreebsd" @@ -11,7 +11,7 @@ class debian_org::apt { $mungedcodename = $::lsbdistcodename } - if $::lsbmajdistrelease <= '8' { + if versioncmp($::lsbmajdistrelease, '8') <= 0 { $fallbackmirror = 'http://cdn-fastly.deb.debian.org/debian/' } else { $fallbackmirror = 'http://deb.debian.org/debian/' diff --git a/modules/debian_org/manifests/init.pp b/modules/debian_org/manifests/init.pp index a8c176f38..a7ff786d8 100644 --- a/modules/debian_org/manifests/init.pp +++ b/modules/debian_org/manifests/init.pp @@ -43,7 +43,7 @@ class debian_org { source => 'puppet:///modules/debian_org/basic-ssh_known_hosts' } - if ($::lsbmajdistrelease >= '8') { + if versioncmp($::lsbmajdistrelease, '8') >= 0 { $rubyfs_package = 'ruby-filesystem' } else { $rubyfs_package = 'libfilesystem-ruby1.9' diff --git a/modules/debian_org/templates/dsa-puppet-stuff.cron.erb b/modules/debian_org/templates/dsa-puppet-stuff.cron.erb index 48fab729d..60f2f5aaf 100644 --- a/modules/debian_org/templates/dsa-puppet-stuff.cron.erb +++ b/modules/debian_org/templates/dsa-puppet-stuff.cron.erb @@ -5,7 +5,7 @@ SHELL=/bin/bash @hourly root [ ! -d /var/cache/dsa ] || touch /var/cache/dsa/cron.alive -<% if @lsbmajdistrelease <= '7' -%> +<% if scope.call_function('versioncmp', [@lsbmajdistrelease, '7']) <= 0 -%> 34 */4 * * * root if [ -x /usr/sbin/puppetd ]; then sleep $(( $RANDOM \% 7200 )); if [ -x /usr/bin/timeout ]; then TO="timeout --kill-after=900 3600"; else TO=""; fi; tmp="$(tempfile)"; egrep -v '^(#|$)' /etc/dsa/cron.ignore.dsa-puppet-stuff > "$tmp" && $TO /usr/sbin/puppetd -o --no-daemonize 2>&1 | egrep --text -v -f "$tmp"; rm -f "$tmp"; fi <% else -%> 34 */4 * * * root if [ -x /usr/bin/puppet ]; then sleep $(( $RANDOM \% 7200 )); if [ -x /usr/bin/timeout ]; then TO="timeout --kill-after=900 3600"; else TO=""; fi; tmp="$(tempfile)"; egrep -v '^(#|$)' /etc/dsa/cron.ignore.dsa-puppet-stuff > "$tmp" && $TO /usr/bin/puppet agent --onetime --no-daemonize 2>&1 | egrep --text -v -f "$tmp"; rm -f "$tmp"; fi diff --git a/modules/ferm/manifests/init.pp b/modules/ferm/manifests/init.pp index 869a3d660..23dfc2a79 100644 --- a/modules/ferm/manifests/init.pp +++ b/modules/ferm/manifests/init.pp @@ -16,7 +16,7 @@ class ferm { package { 'ferm': ensure => installed } - if ($::lsbmajdistrelease >= '8') { + if (versioncmp($::lsbmajdistrelease, '8') >= 0) { package { 'ulogd2': ensure => installed } @@ -92,7 +92,7 @@ class ferm { content => template('ferm/interfaces.conf.erb'), notify => Service['ferm'], } - if ($::lsbmajdistrelease >= '8') { + if (versioncmp($::lsbmajdistrelease, '8') >= 0) { augeas { 'logrotate_ulogd2': context => '/files/etc/logrotate.d/ulogd2', changes => [ diff --git a/modules/ferm/templates/ferm.conf.erb b/modules/ferm/templates/ferm.conf.erb index 5d63f8d0f..b8a6b692e 100644 --- a/modules/ferm/templates/ferm.conf.erb +++ b/modules/ferm/templates/ferm.conf.erb @@ -7,7 +7,7 @@ @include 'conf.d/'; -<% if @lsbmajdistrelease >= '8' -%> +<% if scope.call_function('versioncmp', [@lsbmajdistrelease, '8']) >= 0 -%> domain (ip ip6) { table filter { chain log_and_reject { diff --git a/modules/monit/manifests/init.pp b/modules/monit/manifests/init.pp index 977f1847c..999cdfb3d 100644 --- a/modules/monit/manifests/init.pp +++ b/modules/monit/manifests/init.pp @@ -7,7 +7,7 @@ # include monit # class monit { - if $::lsbmajdistrelease <= '7' { + if versioncmp($::lsbmajdistrelease, '7') <= 0 { package { 'monit': ensure => installed } diff --git a/modules/nagios/templates/obsolete-packages-ignore.d-hostspecific.erb b/modules/nagios/templates/obsolete-packages-ignore.d-hostspecific.erb index 8f815826f..a1265ffe8 100644 --- a/modules/nagios/templates/obsolete-packages-ignore.d-hostspecific.erb +++ b/modules/nagios/templates/obsolete-packages-ignore.d-hostspecific.erb @@ -14,7 +14,7 @@ when "sibelius.debian.org" then ignore << %w{tivs when /(storace|backuphost).debian.org/ then ignore << %w{postgresql-client-9.1} end -if @lsbmajdistrelease <= '8' +if scope.call_function('versioncmp', [@lsbmajdistrelease, '8']) <= 0 case @fqdn when /(acker|aagaard).debian.org/ then ignore << %w{qemu-efi} end diff --git a/modules/samhain/templates/samhainrc.erb b/modules/samhain/templates/samhainrc.erb index 018a05ebe..93116acea 100644 --- a/modules/samhain/templates/samhainrc.erb +++ b/modules/samhain/templates/samhainrc.erb @@ -835,7 +835,7 @@ SyslogSeverity=alert # # SetDefault = no -<% if @lsbmajdistrelease >= '9' -%> +<% if scope.call_function('versioncmp', [@lsbmajdistrelease, '9']) >= 0 -%> [PortCheck] PortCheckActive=0 <% end -%> diff --git a/modules/ssh/manifests/init.pp b/modules/ssh/manifests/init.pp index fc576f82f..56537e43d 100644 --- a/modules/ssh/manifests/init.pp +++ b/modules/ssh/manifests/init.pp @@ -37,7 +37,7 @@ class ssh { content => template('ssh/authorized_keys.erb'), } - if ($::lsbmajdistrelease >= '8') { + if (versioncmp($::lsbmajdistrelease, '8') >= 0) { if ! $has_etc_ssh_ssh_host_ed25519_key { exec { 'create-ed25519-host-key': command => 'ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -q -P "" -t ed25519', -- 2.20.1