From 2b53d345bc4042bc477732809e3f32f3c070fd08 Mon Sep 17 00:00:00 2001 From: Adam Henry Lewenberg <adamhl@stanford.edu> Date: Fri, 1 Dec 2017 14:21:08 -0800 Subject: [PATCH] fix numerical comparisons of lsbmajdistrelease --- manifests/cron.pp | 2 +- manifests/ipmi.pp | 9 +++------ manifests/ntp.pp | 4 ++-- manifests/os/centos.pp | 6 +++--- manifests/os/redhat.pp | 10 +++++----- manifests/os/redhat/el7.pp | 6 +++--- manifests/os/redhat/syslog.pp | 8 ++++---- manifests/os/ubuntu.pp | 2 +- manifests/pam/debian.pp | 4 ++-- manifests/portmap.pp | 4 ++-- manifests/rpm.pp | 20 ++++++++++---------- manifests/ssh/hostbased.pp | 2 +- manifests/ssh/package.pp | 8 ++++---- manifests/syslog.pp | 2 +- manifests/vmguest.pp | 6 +++--- manifests/xinetd/service.pp | 2 +- manifests/yumtools/yum_puppet_lock.pp | 4 ++-- 17 files changed, 48 insertions(+), 51 deletions(-) diff --git a/manifests/cron.pp b/manifests/cron.pp index d0df03d..e8a343a 100644 --- a/manifests/cron.pp +++ b/manifests/cron.pp @@ -25,7 +25,7 @@ class base::cron( } elsif ($::osfamily == 'RedHat') { $crond = 'crond' - if ($::lsbmajdistrelease == '6') { + if ($lsbmajdistrelease == '6') { # OL6 appears to be stuck with cronie-anacron if ($::operatingsystem == 'OracleLinux') { package { 'cronie-anacron': ensure => present } diff --git a/manifests/ipmi.pp b/manifests/ipmi.pp index 8f27835..12f46dc 100644 --- a/manifests/ipmi.pp +++ b/manifests/ipmi.pp @@ -51,10 +51,7 @@ class base::ipmi ( # default. But, if we are re-enabling we need to recover a file that # we deleted. We then have to trigger systemd to load modules. # - # Note: we add 0 to $::lsbmajdistrelease to make the numerical - # comparison work (this way, the code works in both Puppet 3 and - # Puppet 4). - if (($::operatingsystem == 'Debian') and (0 + $::lsbmajdistrelease >= 8)) { + if (($::operatingsystem == 'Debian') and (Integer($lsbmajdistrelease) >= 8)) { exec { 'Re-create /usr/lib/modules-load.d/ipmievd.conf': command => '/usr/bin/apt-get install --reinstall ipmitool', creates => '/usr/lib/modules-load.d/ipmievd.conf', @@ -132,7 +129,7 @@ class base::ipmi ( } # For RHEL 5 and earlier, the client is a separate package - if $::lsbmajdistrelease <= 5 { + if Integer($lsbmajdistrelease) <= 5 { package { 'OpenIPMI-tools': ensure => present, } @@ -233,7 +230,7 @@ class base::ipmi ( } # For Debian 8+, make sure modules are not re-loaded on startup - if $::operatingsystem == 'Debian' and $::lsbmajdistrelease >= 8 { + if $::operatingsystem == 'Debian' and Integer($lsbmajdistrelease) >= 8 { file { '/usr/lib/modules-load.d/ipmievd.conf': ensure => absent, } diff --git a/manifests/ntp.pp b/manifests/ntp.pp index 0b4a6c9..ee96cbf 100644 --- a/manifests/ntp.pp +++ b/manifests/ntp.pp @@ -38,9 +38,9 @@ class base::ntp { }, notify => Service['ntpd'], } - # On RHEL 8, we expect that systemd-timesync will be present, and not + # On RHEL 8, we expect that systemd-timesync will be present, and not # masked by NTP's installation. So, disbale the service. - if ( $::lsbmajdistrelease == 8 ) { + if ( Integer($lsbmajdistrelease) == 8 ) { service { 'systemd-timesyncd': ensure => stopped, enable => false, diff --git a/manifests/os/centos.pp b/manifests/os/centos.pp index 2ebbb6c..52dbbf7 100644 --- a/manifests/os/centos.pp +++ b/manifests/os/centos.pp @@ -1,6 +1,6 @@ # # Rules specific to CentOS systems. Very thin class because with -# minor edits to redhat.pp, little additional config is needed +# minor edits to redhat.pp, little additional config is needed class base::os::centos { # redhat.pp can handle most of the heavy lifting for CentOS @@ -31,8 +31,8 @@ class base::os::centos { # CentOS repo rpm gpg key base::rpm::import { 'centos-rpmkey': - url => "/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-${::lsbmajdistrelease}", - signature => $::lsbmajdistrelease ? { + url => "/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-${lsbmajdistrelease}", + signature => $lsbmajdistrelease ? { '5' => 'gpg-pubkey-e8562897-459f07a4', '6' => 'gpg-pubkey-c105b9de-4e0fd3a3', '7' => 'gpg-pubkey-f4a80eb5-53a7ff4b', diff --git a/manifests/os/redhat.pp b/manifests/os/redhat.pp index 2d4d64a..42f11d9 100644 --- a/manifests/os/redhat.pp +++ b/manifests/os/redhat.pp @@ -33,7 +33,7 @@ class base::os::redhat { } # RHEL RPM GPG Key stuff - case $::lsbmajdistrelease { + case $lsbmajdistrelease { # RHEL4 '4': { # CentOS repo handled in centos.pp @@ -56,13 +56,13 @@ class base::os::redhat { if ($::operatingsystem == 'RedHat') { base::rpm::import { 'redhat-rpmkey': url => '/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release', - signature => $::lsbmajdistrelease ? { + signature => $lsbmajdistrelease ? { '5' => 'gpg-pubkey-37017186-45761324', '6' => 'gpg-pubkey-fd431d51-4ae0493b', }; } } - if ($::lsbmajdistrelease != '7') { + if ($lsbmajdistrelease != '7') { base::rpm::import { 'dag-rpmkey': url => '/usr/share/doc/rpmforge-release-0.3.6/RPM-GPG-KEY-rpmforge-dag', @@ -76,12 +76,12 @@ class base::os::redhat { } # EL7 has its own class - if ($::lsbmajdistrelease == '7') { + if ($lsbmajdistrelease == '7') { include base::os::redhat::el7 } # RHEL4 and 5 need links to krb utils - case $::lsbmajdistrelease { + case $lsbmajdistrelease { '4','5': { file { '/usr/bin/kinit': diff --git a/manifests/os/redhat/el7.pp b/manifests/os/redhat/el7.pp index 797570d..aaf3b56 100644 --- a/manifests/os/redhat/el7.pp +++ b/manifests/os/redhat/el7.pp @@ -5,7 +5,7 @@ # - Disable firewalld in favor of iptables class base::os::redhat::el7 { - if ($::lsbmajdistrelease == '7') { + if ($lsbmajdistrelease == '7') { # dependencies to run the stanford-* tools $el7_deps = [ 'perl-Config-Simple', 'perl-Crypt-PasswdMD5', @@ -23,7 +23,7 @@ class base::os::redhat::el7 { # remove versions of AFS cell configs installed by openafs-* # Due to an encoding 'bug' in Puppet, Puppet cannot checksum the AFS - # cell configs provided by openafs* because Puppet encodes via ASCII + # cell configs provided by openafs* because Puppet encodes via ASCII # and chokes on a unicode character in the provided file exec { 'workaround_bytelock_afs_error': path => "/usr/bin:/usr/sbin:/bin:/sbin", @@ -86,5 +86,5 @@ and all contents are provided by modules/base/os/redhat/el7.pp. Removing files in this directory will trigger restarts of critical system services.\n", } - } + } } diff --git a/manifests/os/redhat/syslog.pp b/manifests/os/redhat/syslog.pp index 9ac73a6..55e8eac 100644 --- a/manifests/os/redhat/syslog.pp +++ b/manifests/os/redhat/syslog.pp @@ -1,4 +1,4 @@ -# Since some production RHEL6 hosts (e.g. zm01) have +# Since some production RHEL6 hosts (e.g. zm01) have # overrides to the syslog.conf file, that part of this # class is being left commented out for now. # @@ -13,19 +13,19 @@ class base::os::redhat::syslog inherits base::syslog { # assuming only affected on RHEL6 for now - if ($::lsbmajdistrelease == '6') { + if ($lsbmajdistrelease == '6') { Base::Syslog::Config::Rsyslog['/etc/rsyslog.conf'] { use_v5 => 'true', use_syslog_conf => 'true', use_default => 'false', } - + # if these files happen to be present, rsyslog will really # complain upon restart $rsyslog_files = [ '/etc/rsyslog.d/20-templates.conf', '/etc/rsyslog.d/95-default.conf', '/etc/rsyslog.d/postfix.conf' ] - file { $rsyslog_files: ensure => absent } + file { $rsyslog_files: ensure => absent } # uncomment to enforce a 'sane' global syslog.conf #Base::Syslog::Config::Syslog['/etc/syslog.conf'] { diff --git a/manifests/os/ubuntu.pp b/manifests/os/ubuntu.pp index 79760b8..5a4d1a7 100644 --- a/manifests/os/ubuntu.pp +++ b/manifests/os/ubuntu.pp @@ -11,7 +11,7 @@ class base::os::ubuntu inherits base::os::debian { } # Triggered on Ubuntu to start the supervise process. Only on 14.10 and below. - if ($::lsbmajdistrelease < 15) { + if (Integer($lsbmajdistrelease) < 15) { include base::daemontools file { '/etc/init/supervise.conf': diff --git a/manifests/pam/debian.pp b/manifests/pam/debian.pp index 90f6423..3dff911 100644 --- a/manifests/pam/debian.pp +++ b/manifests/pam/debian.pp @@ -10,7 +10,7 @@ class base::pam::debian( package { 'libpam-afs-session': ensure => present } # Starting with Debian jessie, pam-auth-update manages the common PAM files. - if ($::lsbmajdistrelease < 8) { + if (Integer($lsbmajdistrelease) < 8) { file { '/etc/pam.d/common-auth': source => 'puppet:///modules/base/pam/etc/pam.d/common-auth', @@ -30,7 +30,7 @@ class base::pam::debian( package { 'libpam-afs-session': ensure => absent } # Starting with Debian jessie, pam-auth-update manages the common PAM files. - if ($::lsbmajdistrelease < 8) { + if (Integer($lsbmajdistrelease) < 8) { file { '/etc/pam.d/common-auth': ensure => absent } diff --git a/manifests/portmap.pp b/manifests/portmap.pp index 771c7bd..b624928 100644 --- a/manifests/portmap.pp +++ b/manifests/portmap.pp @@ -11,7 +11,7 @@ class base::portmap { 'RedHat': { include base::xinetd - case $::lsbmajdistrelease { + case $lsbmajdistrelease { '6','7': { package { 'rpcbind': ensure => present } service { 'rpcbind': ensure => running } @@ -37,7 +37,7 @@ class base::portmap { # Ubuntu 11.10 switched to "rpcbind" like EL6 package { 'rpcbind': ensure => present } service { 'portmap': ensure => running } - } else { + } else { case $::lsbdistcodename { 'squeeze': { package { 'portmap': ensure => present } diff --git a/manifests/rpm.pp b/manifests/rpm.pp index 4f565e7..e2ed0bb 100644 --- a/manifests/rpm.pp +++ b/manifests/rpm.pp @@ -18,12 +18,12 @@ class base::rpm::openafs { '4' => '1.6.2', default => '1.6.5', } - base::rpm::yumrepo { "openafs-${openafsver}-EL${::lsbmajdistrelease}.repo": } + base::rpm::yumrepo { "openafs-${openafsver}-EL${lsbmajdistrelease}.repo": } } # rpm class. applied to every RHEL system via basenode (os module) class base::rpm { - + case $::osfamily { 'RedHat': { include base::rpm::openafs @@ -38,9 +38,9 @@ class base::rpm { } # Apply to all RHEL releases - base::rpm::yumrepo { "dag-EL${::lsbmajdistrelease}.repo": } - base::rpm::yumrepo { "stanford-priv-EL${::lsbmajdistrelease}.repo": } - base::rpm::yumrepo { "stanford-EL${::lsbmajdistrelease}.repo": } + base::rpm::yumrepo { "dag-EL${lsbmajdistrelease}.repo": } + base::rpm::yumrepo { "stanford-priv-EL${lsbmajdistrelease}.repo": } + base::rpm::yumrepo { "stanford-EL${lsbmajdistrelease}.repo": } # puppetlabs repo now being mirrored on yum.stanford.edu file { '/etc/yum.repos.d/puppet-mirror.repo': ensure => present, @@ -58,7 +58,7 @@ class base::rpm { require => Package['newsyslog']; } - case $::lsbmajdistrelease { + case $lsbmajdistrelease { # RHEL4 '4': { include base::up2date @@ -68,9 +68,9 @@ class base::rpm { } # RHEL5+ default: { - # EL6/7 includes this plugin by default - if ($::lsbmajdistrelease == '5') { - package { 'yum-downloadonly': + # EL6/7 includes this plugin by default + if ($lsbmajdistrelease == '5') { + package { 'yum-downloadonly': ensure => installed, } } @@ -99,7 +99,7 @@ class base::rpm { } # only RHEL4 and RHEL5 use rpmpkgs log - if ($::lsbmajdistrelease == '4' or $::lsbmajdistrelease == '5') { + if ($lsbmajdistrelease == '4' or $lsbmajdistrelease == '5') { # rotate /var/log/rpmpkgs weekly file { '/etc/newsyslog.weekly/rpmpkgs': source => 'puppet:///modules/base/rpm/etc/newsyslog.weekly/rpmpkgs', diff --git a/manifests/ssh/hostbased.pp b/manifests/ssh/hostbased.pp index 80ad945..0443ac1 100644 --- a/manifests/ssh/hostbased.pp +++ b/manifests/ssh/hostbased.pp @@ -3,7 +3,7 @@ # authentication.) class base::ssh::hostbased inherits base::ssh::pubkey { - if ($::osfamily == 'RedHat') and ($::lsbmajdistrelease >= 6) { + if ($::osfamily == 'RedHat') and (Integer($lsbmajdistrelease) >= 6) { fail("ssh::new::hostbased should not be used with RHEL 6 or later") } diff --git a/manifests/ssh/package.pp b/manifests/ssh/package.pp index 3ee3363..b634ac8 100644 --- a/manifests/ssh/package.pp +++ b/manifests/ssh/package.pp @@ -12,10 +12,10 @@ class base::ssh::package ( $sshd_package = 'openssh-server' # Debian wheezy is the oldest supported version - if ($::lsbmajdistrelease < 7) { + if (Integer($lsbmajdistrelease) < 7) { fail('pam_duo requires at least Debian wheezy') } - elsif ($::lsbmajdistrelease == 7) { + elsif (Integer($lsbmajdistrelease) == 7) { # On wheezy, pin the backported openssh file { '/etc/apt/preferences.d/openssh': ensure => present, @@ -28,7 +28,7 @@ class base::ssh::package ( $sshd_package = 'openssh-server' # Ubuntu trusty is the oldest supported version - if ($::lsbmajdistrelease < 14) { + if (Integer($lsbmajdistrelease) < 14) { fail('pam_duo requires at least Ubuntu trusty') } } @@ -39,7 +39,7 @@ class base::ssh::package ( $sshd_package = 'openssh-server' # RHEL/CentOS 7 is the oldest supported version - if ($::lsbmajdistrelease < 7) { + if (Integer($lsbmajdistrelease) < 7) { fail('pam_duo requires at least RHEL/CentOS 7') } } diff --git a/manifests/syslog.pp b/manifests/syslog.pp index e6a5115..73dc2ff 100644 --- a/manifests/syslog.pp +++ b/manifests/syslog.pp @@ -44,7 +44,7 @@ class base::syslog( } # RHEL4/5 are ancient and use syslog, everything modern uses rsyslog - if ( $::osfamily == 'RedHat' and $::lsbmajdistrelease < 6 ) { + if ( $::osfamily == 'RedHat' and Integer($lsbmajdistrelease) < 6 ) { service { 'syslog': ensure => running } } else { file { '/etc/rsyslog.d': diff --git a/manifests/vmguest.pp b/manifests/vmguest.pp index 744ee89..6b451e7 100644 --- a/manifests/vmguest.pp +++ b/manifests/vmguest.pp @@ -46,8 +46,8 @@ class base::vmguest( # we do not the rebundled version by this name package { 'VMwareTools': ensure => absent } # VMWare recommends open-vm-tools for EL7 - if ($::lsbmajdistrelease != '7') { - base::rpm::yumrepo { "vmware-tools-EL${::lsbmajdistrelease}.repo": } + if ($lsbmajdistrelease != '7') { + base::rpm::yumrepo { "vmware-tools-EL${lsbmajdistrelease}.repo": } base::rpm::import { 'vmware-tools-dsa': url => @@ -61,7 +61,7 @@ class base::vmguest( package { 'vmware-tools-esx-nox': ensure => present, require => [ - Base::Rpm::Yumrepo["vmware-tools-EL${::lsbmajdistrelease}.repo"], + Base::Rpm::Yumrepo["vmware-tools-EL${lsbmajdistrelease}.repo"], Base::Rpm::Import['vmware-tools-dsa'], Base::Rpm::Import['vmware-tools-rsa'], Package['VMwareTools'] diff --git a/manifests/xinetd/service.pp b/manifests/xinetd/service.pp index 00e55a7..64abf0c 100644 --- a/manifests/xinetd/service.pp +++ b/manifests/xinetd/service.pp @@ -12,7 +12,7 @@ define base::xinetd::service( # Used for the file suffix. case $::osfamily { Debian: { $os = $::osfamily } - RedHat: { $os = "${::operatingsystem}${::lsbmajdistrelease}" } + RedHat: { $os = "${::operatingsystem}${lsbmajdistrelease}" } } case $ensure { diff --git a/manifests/yumtools/yum_puppet_lock.pp b/manifests/yumtools/yum_puppet_lock.pp index 3d5a12a..62740e5 100644 --- a/manifests/yumtools/yum_puppet_lock.pp +++ b/manifests/yumtools/yum_puppet_lock.pp @@ -7,11 +7,11 @@ class base::yumtools::yum_puppet_lock ( $puppet_version = '3.7.2-1' ) { base::yumtools::versionlock { - "0:puppet-${puppet_version}.el${::lsbmajdistrelease}*": + "0:puppet-${puppet_version}.el${lsbmajdistrelease}*": ensure => present, } base::yumtools::versionlock { - "1:facter-${facter_version}.el${::lsbmajdistrelease}*": + "1:facter-${facter_version}.el${lsbmajdistrelease}*": ensure => present, } } -- GitLab