Skip to content

Commit 4043488

Browse files
committed
os_version_gte implemented
1 parent f9f0773 commit 4043488

12 files changed

+46
-59
lines changed

manifests/mod/dav_svn.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Class['::apache::mod::dav'] -> Class['::apache::mod::dav_svn']
55
include ::apache
66
include ::apache::mod::dav
7-
if($::operatingsystem == 'SLES' and $::operatingsystemmajrelease < '12'){
7+
unless stdlib::os_version_gte('SLES', '12') {
88
package { 'subversion-server':
99
ensure => 'installed',
1010
provider => 'zypper',

manifests/mod/fcgid.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$options = {},
33
) {
44
include ::apache
5-
if ($::osfamily == 'RedHat' and $::operatingsystemmajrelease == '7') or $::osfamily == 'FreeBSD' {
5+
if stdlib::os_version_gte('RedHat', '7') or $::osfamily == 'FreeBSD' {
66
$loadfile_name = 'unixd_fcgid.load'
77
$conf_name = 'unixd_fcgid.conf'
88
} else {

spec/acceptance/default_mods_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class { 'apache':
1919
end
2020
end
2121

22-
unless fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12'
22+
unless stdlib::os_version_gte('SLES', '12')
2323
describe 'no default mods and failing' do
2424
before :all do
2525
pp = <<-PP

spec/acceptance/mod_dav_svn_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper_acceptance'
22
require_relative './version.rb'
33

4-
describe 'apache::mod::dav_svn class', unless: (fact('operatingsystem') == 'OracleLinux' && fact('operatingsystemmajrelease') == '7') do
4+
describe 'apache::mod::dav_svn class', unless: stdlib::os_version_gte('OracleLinux', '7') do
55
authz_svn_load_file = case fact('osfamily')
66
when 'Debian'
77
if fact('operatingsystemmajrelease') == '16.04' || fact('operatingsystemmajrelease') == '9'

spec/acceptance/mod_fcgid_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'apache::mod::fcgid class', if: ((fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') != '5') &&
4-
!(fact('operatingsystem') == 'OracleLinux' && fact('operatingsystemmajrelease') == '7')) do
3+
describe 'apache::mod::fcgid class', if: (stdlib::os_version_gte('RedHat', '6') &&
4+
!(stdlib::os_version_gte('OracleLinux', '7'))) do
55
context 'default fcgid config' do
66
pp = <<-MANIFEST
77
class { 'epel': } # mod_fcgid lives in epel

spec/acceptance/mod_pagespeed_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
# Only run the test on centos 7, this is to cut down on the different types of setup
55
# required. Installing the dependancies are highly prone to failure.
6-
describe 'apache::mod::pagespeed class', if: ((fact('operatingsystem') == 'CentOS') &&
7-
(fact('operatingsystemmajrelease') == '7')) do
6+
describe 'apache::mod::pagespeed class', if: stdlib::os_version_gte('CentOS', '7') do
87
context 'default pagespeed config' do
98
pp = <<-MANIFEST
109
yumrepo { 'mod-pagespeed':

spec/acceptance/mod_passenger_spec.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,8 @@ class { 'apache::mod::passenger': }
130130
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
131131
it { is_expected.not_to contain '/PassengerRuby/' }
132132
when 'Debian'
133-
case fact('operatingsystemmajrelease')
134-
when '8'
135-
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
136-
it { is_expected.not_to contain '/PassengerRuby/' }
137-
when '9'
138-
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
139-
it { is_expected.not_to contain '/PassengerRuby/' }
140-
else
141-
# Includes wheezy
142-
# This may or may not work on Debian releases other than the above
143-
it { is_expected.to contain %(PassengerRuby "#{passenger_ruby}) }
144-
it { is_expected.not_to contain '/PassengerDefaultRuby/' }
145-
end
133+
it { is_expected.to contain %(PassengerDefaultRuby "#{passenger_default_ruby}") }
134+
it { is_expected.not_to contain '/PassengerRuby/' }
146135
end
147136
end
148137
# rubocop:enable RSpec/RepeatedExample

spec/acceptance/mod_php_spec.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# exit codes are documented at https://askubuntu.com/a/365912. Default for docker images is 101
1515
shell("if [ -a '/usr/sbin/policy-rc.d' ]; then sed -i 's/^exit.*/exit 0/' /usr/sbin/policy-rc.d; fi")
1616
end
17-
if fact('operatingsystemmajrelease') == '18.04'
17+
if stdlib::os_Version_gte('Ubuntu', '18.04')
1818
# apache helper script has a bug which prevents the installation of certain apache modules
1919
# https://bugs.launchpad.net/ubuntu/+source/php7.2/+bug/1771934
2020
# https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/1782806
@@ -54,13 +54,13 @@ class { 'apache::mod::php': }
5454
it { is_expected.to be_running }
5555
end
5656

57-
if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04') ||
58-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
59-
describe file("#{$mod_dir}/php7.0.conf") do
57+
if stdlib:os_version_gte('Ubuntu', '18.04')
58+
describe file("#{$mod_dir}/php7.2.conf") do
6059
it { is_expected.to contain 'DirectoryIndex index.php' }
6160
end
62-
elsif fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04'
63-
describe file("#{$mod_dir}/php7.2.conf") do
61+
elsif stdlib::os_version_gte('Ubuntu', '16.04') ||
62+
stdlib::os_version_gte('Debian', '9')
63+
describe file("#{$mod_dir}/php7.0.conf") do
6464
it { is_expected.to contain 'DirectoryIndex index.php' }
6565
end
6666
else
@@ -147,18 +147,19 @@ class {'apache::mod::php':
147147
it 'succeeds in puppeting php' do
148148
apply_manifest(pp, catch_failures: true)
149149
end
150-
if (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '16.04') ||
151-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9')
152-
describe file("#{$mod_dir}/php7.0.conf") do
153-
it { is_expected.to contain '# somecontent' }
154-
end
155-
elsif fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04'
150+
151+
if stdlib:os_version_gte('Ubuntu', '18.04')
156152
describe file("#{$mod_dir}/php7.2.conf") do
157-
it { is_expected.to contain '# somecontent' }
153+
it { is_expected.to contain 'DirectoryIndex index.php' }
154+
end
155+
elsif stdlib::os_version_gte('Ubuntu', '16.04') ||
156+
stdlib::os_version_gte('Debian', '9')
157+
describe file("#{$mod_dir}/php7.0.conf") do
158+
it { is_expected.to contain 'DirectoryIndex index.php' }
158159
end
159160
else
160161
describe file("#{$mod_dir}/php5.conf") do
161-
it { is_expected.to contain '# somecontent' }
162+
it { is_expected.to contain 'DirectoryIndex index.php' }
162163
end
163164
end
164165
end

spec/acceptance/mod_proxy_html_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
require_relative './version.rb'
33

44
# Don't run proxy_html tests on RHEL7 because the yum repos are missing packages required by it.
5-
describe 'apache::mod::proxy_html class', unless: (fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') == '7') do
5+
describe 'apache::mod::proxy_html class', unless: stdlib::os_version_gte('RedHat', '7') do
66
context 'default proxy_html config' do
7-
if fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') =~ %r{(5|6)}
7+
if stdlib::os_version_gte('RedHat', '5')
88
it 'adds epel' do
99
pp = "class { 'epel': }"
1010
apply_manifest(pp, catch_failures: true)

spec/acceptance/mod_security_spec.rb

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
require 'spec_helper_acceptance'
22
require_relative './version.rb'
33

4-
describe 'apache::mod::security class', unless: (fact('osfamily') == 'Debian' && (fact('lsbdistcodename') == 'squeeze' ||
5-
fact('lsbdistcodename') == 'lucid' || fact('lsbdistcodename') == 'precise' ||
6-
fact('lsbdistcodename') == 'wheezy')) || (fact('operatingsystem') == 'SLES' && fact('operatingsystemrelease') < '11') do
4+
describe 'apache::mod::security class', unless: (fact('operatingsystem') == 'SLES' && fact('operatingsystemrelease') < '11') do
75
context 'default mod_security config' do
86
if fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') =~ %r{(5|6)}
97
pp_one = "class { 'epel': }"
108
it 'adds epel' do
119
apply_manifest(pp_one, catch_failures: true)
1210
end
13-
elsif fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') == '7'
11+
elsif stdlib::os_version_gte('RedHat', '7')
1412
pp_two = <<-MANIFEST
1513
ini_setting { 'obsoletes':
1614
path => '/etc/yum.conf',
@@ -75,9 +73,9 @@ class { 'apache::mod::security': }
7573
end
7674
end
7775

78-
unless fact('operatingsystem') == 'SLES' ||
79-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
80-
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
76+
unless fact('operatingsystem') == 'SLES' ||
77+
stdlib::os_version_gte('Debian', '9') ||
78+
stdlib::os_version_gte('Ubuntu', '18.04')
8179
it 'blocks query with SQL' do
8280
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
8381
end
@@ -116,9 +114,9 @@ class { 'apache::mod::security': }
116114
it { is_expected.to contain 'mod_security2.c' }
117115
end
118116

119-
unless fact('operatingsystem') == 'SLES' ||
120-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
121-
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
117+
unless fact('operatingsystem') == 'SLES' ||
118+
stdlib::os_version_gte('Debian', '9') ||
119+
stdlib::os_version_gte('Ubuntu', '18.04')
122120
it 'blocks query with SQL' do
123121
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
124122
end
@@ -181,8 +179,8 @@ class { 'apache::mod::security': }
181179
end
182180

183181
unless fact('operatingsystem') == 'SLES' ||
184-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
185-
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
182+
stdlib::os_version_gte('Debian', '9') ||
183+
stdlib::os_version_gte('Ubuntu', '18.04')
186184
it 'blocks query with SQL' do
187185
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
188186
end
@@ -249,8 +247,8 @@ class { 'apache::mod::security': }
249247
end
250248

251249
unless fact('operatingsystem') == 'SLES' ||
252-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
253-
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
250+
stdlib::os_version_gte('Debian', '9') ||
251+
stdlib::os_version_gte('Ubuntu', '18.04')
254252
it 'blocks query with SQL' do
255253
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
256254
end
@@ -317,8 +315,8 @@ class { 'apache::mod::security': }
317315
end
318316

319317
unless fact('operatingsystem') == 'SLES' ||
320-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
321-
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
318+
stdlib::os_version_gte('Debian', '9') ||
319+
stdlib::os_version_gte('Ubuntu', '18.04')
322320
it 'blocks query with SQL' do
323321
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
324322
end
@@ -385,8 +383,8 @@ class { 'apache::mod::security': }
385383
end
386384

387385
unless fact('operatingsystem') == 'SLES' ||
388-
(fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '9') ||
389-
(fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') == '18.04')
386+
stdlib::os_version_gte('Debian', '9') ||
387+
stdlib::os_version_gte('Ubuntu', '18.04')
390388
it 'blocks query with SQL' do
391389
shell '/usr/bin/curl -A beaker -f modsec.example.com:80?SELECT%20*FROM%20mysql.users', acceptable_exit_codes: [22]
392390
end

0 commit comments

Comments
 (0)