Skip to content

Commit 5b2a524

Browse files
committed
Use operatingsystemmajrelease fact
This fact was introduced in Facter 1.7 which by now can be assumed. By now it's already deprecated in favor of $facts['os']['release']['major'] but the rest of the module isn't converted so this keeps it consistent. CentOS 8 stream doesn't have a minor version and the previous comparison code failed. There are a lot more odd cases with facts, but I don't want to touch too much code.
1 parent b54431d commit 5b2a524

File tree

7 files changed

+29
-31
lines changed

7 files changed

+29
-31
lines changed

manifests/default_mods.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
if versioncmp($apache_version, '2.4') >= 0 {
1818
# Lets fork it
1919
# Do not try to load mod_systemd on RHEL/CentOS 6 SCL.
20-
if ( !($::osfamily == 'redhat' and versioncmp($::operatingsystemrelease, '7.0') == -1) and !($::operatingsystem == 'Amazon') ) {
20+
if ( !($::osfamily == 'redhat' and versioncmp($::operatingsystemmajrelease, '7') == -1) and !($::operatingsystem == 'Amazon') ) {
2121
if ($use_systemd) {
2222
::apache::mod { 'systemd': }
2323
}

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@
551551
default => '(event|itk|prefork|worker)'
552552
}
553553

554-
if $::osfamily == 'RedHat' and $apache::version::distrelease == '7' {
554+
if $::osfamily == 'RedHat' and $facts['operatingsystemmajrelease'] == '7' {
555555
# On redhat 7 the ssl.conf lives in /etc/httpd/conf.d (the confd_dir)
556556
# when all other module configs live in /etc/httpd/conf.modules.d (the
557557
# mod_dir). On all other platforms and versions, ssl.conf lives in the

manifests/mod/fastcgi.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
class apache::mod::fastcgi {
77
include apache
8-
if ($::osfamily == 'Redhat' and versioncmp($::operatingsystemrelease, '7.0') >= 0) {
8+
if ($::osfamily == 'Redhat' and versioncmp($::operatingsystemmajrelease, '7') >= 0) {
99
fail('mod_fastcgi is no longer supported on el7 and above.')
1010
}
1111
if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '18.04') >= 0) {

manifests/mod/proxy_html.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
}
2222
case $::operatingsystem {
2323
'Ubuntu': {
24-
$loadfiles = $apache::params::distrelease ? {
24+
$loadfiles = $facts['operatingsystemmajrelease'] ? {
2525
'10' => ['/usr/lib/libxml2.so.2'],
2626
default => ["/usr/lib/${gnu_path}-linux-gnu/libxml2.so.2"],
2727
}
2828
}
2929
'Debian': {
30-
$loadfiles = $apache::params::distrelease ? {
30+
$loadfiles = $facts['operatingsystemmajrelease'] ? {
3131
'6' => ['/usr/lib/libxml2.so.2'],
3232
default => ["/usr/lib/${gnu_path}-linux-gnu/libxml2.so.2"],
3333
}

manifests/params.pp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
$server_root = "${httpd_root}/etc/httpd"
6262
$conf_dir = "${httpd_dir}/conf"
6363
$confd_dir = "${httpd_dir}/conf.d"
64-
$mod_dir = $apache::version::distrelease ? {
64+
$mod_dir = $facts['operatingsystemmajrelease'] ? {
6565
'7' => "${httpd_dir}/conf.modules.d",
6666
default => "${httpd_dir}/conf.d",
6767
}
@@ -107,11 +107,11 @@
107107
$mime_support_package = 'mailcap'
108108
$mime_types_config = '/etc/mime.types'
109109
$docroot = "${httpd_root}/var/www/html"
110-
$alias_icons_path = $apache::version::distrelease ? {
110+
$alias_icons_path = $facts['operatingsystemmajrelease'] ? {
111111
'7' => "${httpd_root}/usr/share/httpd/icons",
112112
default => '/var/www/icons',
113113
}
114-
$error_documents_path = $apache::version::distrelease ? {
114+
$error_documents_path = $facts['operatingsystemmajrelease'] ? {
115115
'7' => "${httpd_root}/usr/share/httpd/error",
116116
default => '/var/www/error'
117117
}
@@ -172,7 +172,7 @@
172172
# Amazon Linux 2 uses the /conf.modules.d/ dir
173173
$mod_dir = "${httpd_dir}/conf.modules.d"
174174
} else {
175-
$mod_dir = $apache::version::distrelease ? {
175+
$mod_dir = $facts['operatingsystemmajrelease'] ? {
176176
'7' => "${httpd_dir}/conf.modules.d",
177177
'8' => "${httpd_dir}/conf.modules.d",
178178
default => "${httpd_dir}/conf.d",
@@ -200,7 +200,7 @@
200200
$suphp_addhandler = 'php5-script'
201201
$suphp_engine = 'off'
202202
$suphp_configpath = undef
203-
$php_version = $apache::version::distrelease ? {
203+
$php_version = $facts['operatingsystemmajrelease'] ? {
204204
'8' => '7', # RedHat8
205205
default => '5', # RedHat5, RedHat6, RedHat7
206206
}
@@ -211,21 +211,21 @@
211211
'auth_gssapi' => 'mod_auth_gssapi',
212212
'auth_mellon' => 'mod_auth_mellon',
213213
'auth_openidc' => 'mod_auth_openidc',
214-
'authnz_ldap' => $apache::version::distrelease ? {
214+
'authnz_ldap' => $facts['operatingsystemmajrelease'] ? {
215215
'7' => 'mod_ldap',
216216
'8' => 'mod_ldap',
217217
default => 'mod_authz_ldap',
218218
},
219219
'authnz_pam' => 'mod_authnz_pam',
220-
'fastcgi' => $apache::version::distrelease ? {
220+
'fastcgi' => $facts['operatingsystemmajrelease'] ? {
221221
'5' => 'mod_fastcgi',
222222
'6' => 'mod_fastcgi',
223223
default => undef,
224224
},
225225
'fcgid' => 'mod_fcgid',
226226
'geoip' => 'mod_geoip',
227227
'intercept_form_submit' => 'mod_intercept_form_submit',
228-
'ldap' => $apache::version::distrelease ? {
228+
'ldap' => $facts['operatingsystemmajrelease'] ? {
229229
'5' => undef,
230230
'6' => undef,
231231
default => 'mod_ldap',
@@ -239,7 +239,7 @@
239239
# https://www.phusionpassenger.com/library/install/apache/install/oss/el7/
240240
'passenger' => 'mod_passenger',
241241
'perl' => 'mod_perl',
242-
'php5' => $apache::version::distrelease ? {
242+
'php5' => $facts['operatingsystemmajrelease'] ? {
243243
'5' => 'php53',
244244
default => 'php',
245245
},
@@ -252,7 +252,7 @@
252252
# See http://wiki.aaf.edu.au/tech-info/sp-install-guide
253253
'shibboleth' => 'shibboleth',
254254
'ssl' => 'mod_ssl',
255-
'wsgi' => $apache::version::distrelease ? {
255+
'wsgi' => $facts['operatingsystemmajrelease'] ? {
256256
'8' => 'python3-mod_wsgi', # RedHat8
257257
default => 'mod_wsgi', # RedHat5, RedHat6, RedHat7
258258
},
@@ -264,7 +264,7 @@
264264
}
265265
$mod_libs = {
266266
'nss' => 'libmodnss.so',
267-
'wsgi' => $apache::version::distrelease ? {
267+
'wsgi' => $facts['operatingsystemmajrelease'] ? {
268268
'8' => 'mod_wsgi_python3.so',
269269
default => 'mod_wsgi.so',
270270
},
@@ -278,12 +278,12 @@
278278
$mime_support_package = 'mailcap'
279279
$mime_types_config = '/etc/mime.types'
280280
$docroot = '/var/www/html'
281-
$alias_icons_path = $apache::version::distrelease ? {
281+
$alias_icons_path = $facts['operatingsystemmajrelease'] ? {
282282
'7' => '/usr/share/httpd/icons',
283283
'8' => '/usr/share/httpd/icons',
284284
default => '/var/www/icons',
285285
}
286-
$error_documents_path = $apache::version::distrelease ? {
286+
$error_documents_path = $facts['operatingsystemmajrelease'] ? {
287287
'7' => '/usr/share/httpd/error',
288288
'8' => '/usr/share/httpd/error',
289289
default => '/var/www/error'
@@ -790,7 +790,7 @@
790790
$verify_command = '/usr/sbin/apachectl -t'
791791
}
792792

793-
if $::osfamily == 'RedHat' and versioncmp($::operatingsystemrelease, '8.0') >= 0 {
793+
if $::osfamily == 'RedHat' and versioncmp($facts['operatingsystemmajrelease'], '8') >= 0 {
794794
$ssl_protocol = ['all'] # Implementations of the SSLv2 and SSLv3 protocol versions have been removed from OpenSSL (and hence mod_ssl) because these are no longer considered secure. For additional documentation https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/deploying_different_types_of_servers/setting-apache-web-server_deploying-different-types-of-servers
795795
} else {
796796
$ssl_protocol = ['all', '-SSLv2', '-SSLv3']

manifests/version.pp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,23 @@
66
Optional[String] $scl_httpd_version = undef,
77
Optional[String] $scl_php_version = undef,
88
) {
9-
# This will be 5 or 6 on RedHat, 6 or wheezy on Debian, 12 or quantal on Ubuntu, etc.
10-
$osr_array = split($::operatingsystemrelease,'[\/\.]')
11-
$distrelease = $osr_array[0]
12-
if ! $distrelease {
13-
fail("Class['apache::version']: Unparsable \$::operatingsystemrelease: ${::operatingsystemrelease}")
14-
}
15-
169
case $::osfamily {
1710
'RedHat': {
1811
if $scl_httpd_version {
1912
$default = $scl_httpd_version
2013
}
2114
elsif ($::operatingsystem == 'Amazon') {
2215
$default = '2.2'
23-
} elsif ($::operatingsystem == 'Fedora' and versioncmp($distrelease, '18') >= 0) or ($::operatingsystem != 'Fedora' and versioncmp($distrelease, '7') >= 0) {
16+
} elsif ($::operatingsystem == 'Fedora' and versioncmp($facts['operatingsystemmajrelease'], '18') >= 0) or ($::operatingsystem != 'Fedora' and versioncmp($facts['operatingsystemmajrelease'], '7') >= 0) {
2417
$default = '2.4'
2518
} else {
2619
$default = '2.2'
2720
}
2821
}
2922
'Debian': {
30-
if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '13.10') >= 0 {
23+
if $::operatingsystem == 'Ubuntu' and versioncmp($facts['operatingsystemmajrelease'], '13.10') >= 0 {
3124
$default = '2.4'
32-
} elsif $::operatingsystem == 'Debian' and versioncmp($distrelease, '8') >= 0 {
25+
} elsif $::operatingsystem == 'Debian' and versioncmp($facts['operatingsystemmajrelease'], '8') >= 0 {
3326
$default = '2.4'
3427
} else {
3528
$default = '2.2'
@@ -42,7 +35,7 @@
4235
$default = '2.4'
4336
}
4437
'Suse': {
45-
if ($::operatingsystem == 'SLES' and versioncmp($::operatingsystemrelease, '12') >= 0) or ($::operatingsystem == 'OpenSuSE' and versioncmp($::operatingsystemrelease, '42') >= 0) {
38+
if ($::operatingsystem == 'SLES' and versioncmp($facts['operatingsystemmajrelease'], '12') >= 0) or ($::operatingsystem == 'OpenSuSE' and versioncmp($facts['operatingsystemmajrelease'], '42') >= 0) {
4639
$default = '2.4'
4740
} else {
4841
$default = '2.2'

spec/spec_helper_local.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
osfamily: 'RedHat',
6666
operatingsystem: 'Fedora',
6767
operatingsystemrelease: '17',
68+
operatingsystemmajrelease: '17',
6869
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
6970
}
7071
end
@@ -78,6 +79,7 @@
7879
osfamily: 'RedHat',
7980
operatingsystem: 'Fedora',
8081
operatingsystemrelease: '21',
82+
operatingsystemmajrelease: '21',
8183
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
8284
}
8385
end
@@ -91,6 +93,7 @@
9193
osfamily: 'RedHat',
9294
operatingsystem: 'Fedora',
9395
operatingsystemrelease: '28',
96+
operatingsystemmajrelease: '28',
9497
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
9598
}
9699
end
@@ -104,6 +107,7 @@
104107
osfamily: 'RedHat',
105108
operatingsystem: 'Fedora',
106109
operatingsystemrelease: 'Rawhide',
110+
operatingsystemmajrelease: 'Rawhide',
107111
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
108112
}
109113
end
@@ -142,7 +146,8 @@
142146
kernel: 'Linux',
143147
osfamily: 'Gentoo',
144148
operatingsystem: 'Gentoo',
145-
operatingsystemrelease: '3.16.1-gentoo',
149+
operatingsystemrelease: '2.7',
150+
operatingsystemmajrelease: '2.7',
146151
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin',
147152
}
148153
end

0 commit comments

Comments
 (0)