Skip to content

Commit

Permalink
Merge pull request #731 from blkperl/convert_versions_to_string
Browse files Browse the repository at this point in the history
(MODULES-910) Convert @apache_version to a string
  • Loading branch information
igalic committed May 19, 2014
2 parents ef9e6c8 + 0aa6b0f commit 81069bc
Show file tree
Hide file tree
Showing 26 changed files with 59 additions and 59 deletions.
10 changes: 5 additions & 5 deletions manifests/default_mods.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
case $::osfamily {
'redhat', 'freebsd': {
::apache::mod { 'log_config': }
if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
# Lets fork it
::apache::mod { 'systemd': }
::apache::mod { 'unixd': }
Expand Down Expand Up @@ -47,7 +47,7 @@
::apache::mod { 'usertrack': }
::apache::mod { 'version': }

if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
::apache::mod { 'authn_core': }
}
else {
Expand Down Expand Up @@ -114,7 +114,7 @@
::apache::mod { 'auth_basic': }
::apache::mod { 'authn_file': }

if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
# authz_core is needed for 'Require' directive
::apache::mod { 'authz_core':
id => 'authz_core_module',
Expand All @@ -135,7 +135,7 @@
} elsif $mods {
::apache::default_mods::load { $mods: }

if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
# authz_core is needed for 'Require' directive
::apache::mod { 'authz_core':
id => 'authz_core_module',
Expand All @@ -145,7 +145,7 @@
::apache::mod { 'filter': }
}
} else {
if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
# authz_core is needed for 'Require' directive
::apache::mod { 'authz_core':
id => 'authz_core_module',
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
validate_bool($service_enable)

$valid_mpms_re = $apache_version ? {
2.4 => '(event|itk|peruser|prefork|worker)',
'2.4' => '(event|itk|peruser|prefork|worker)',
default => '(event|itk|prefork|worker)'
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/event.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

case $::osfamily {
'redhat': {
if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
apache::mpm{ 'event':
apache_version => $apache_version,
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/pagespeed.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
){

$_lib = $::apache::apache_version ? {
2.4 => 'mod_pagespeed_ap24.so',
'2.4' => 'mod_pagespeed_ap24.so',
default => undef
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/prefork.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

case $::osfamily {
'redhat': {
if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
::apache::mpm{ 'prefork':
apache_version => $apache_version,
}
Expand Down
4 changes: 2 additions & 2 deletions manifests/mod/ssl.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

case $::osfamily {
'debian': {
if $apache_version >= 2.4 and $::operatingsystem == 'Ubuntu' {
if versioncmp($apache_version, '2.4') >= 0 and $::operatingsystem == 'Ubuntu' {
$ssl_mutex = 'default'
} elsif $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease == '10.04' {
$ssl_mutex = 'file:/var/run/apache2/ssl_mutex'
Expand All @@ -33,7 +33,7 @@

::apache::mod { 'ssl': }

if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
::apache::mod { 'socache_shmcb': }
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/worker.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

case $::osfamily {
'redhat': {
if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
::apache::mpm{ 'worker':
apache_version => $apache_version,
}
Expand Down
6 changes: 3 additions & 3 deletions manifests/mpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$_path = "${lib_path}/${_lib}"
$_id = "mpm_${mpm}_module"

if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
file { "${mod_dir}/${mpm}.load":
ensure => file,
path => "${mod_dir}/${mpm}.load",
Expand All @@ -37,7 +37,7 @@
notify => Service['httpd'],
}

if $apache_version >= 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
file { "${::apache::mod_enable_dir}/${mpm}.load":
ensure => link,
target => "${::apache::mod_dir}/${mpm}.load",
Expand All @@ -47,7 +47,7 @@
}
}

if $apache_version < 2.4 {
if versioncmp($apache_version, '2.4') < 0 {
package { "apache2-mpm-${mpm}":
ensure => present,
}
Expand Down
10 changes: 5 additions & 5 deletions manifests/version.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
case $::osfamily {
'RedHat': {
if ($::operatingsystem == 'Fedora' and $distrelease >= 18) or ($::operatingsystem != 'Fedora' and $distrelease >= 7) {
$default = 2.4
$default = '2.4'
} else {
$default = 2.2
$default = '2.2'
}
}
'Debian': {
if $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease >= 13.10 {
$default = 2.4
$default = '2.4'
} else {
$default = 2.2
$default = '2.2'
}
}
'FreeBSD': {
$default = 2.2
$default = '2.2'
}
default: {
fail("Class['apache::version']: Unsupported osfamily: ${::osfamily}")
Expand Down
4 changes: 2 additions & 2 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
}
}
if ! $ip_based {
if ! defined(Apache::Namevirtualhost[$nvh_addr_port]) and $ensure == 'present' and $apache_version < 2.4 {
if ! defined(Apache::Namevirtualhost[$nvh_addr_port]) and $ensure == 'present' and (versioncmp($apache_version, '2.4') < 0) {
::apache::namevirtualhost { $nvh_addr_port: }
}
}
Expand Down Expand Up @@ -429,7 +429,7 @@
directoryindex => $directoryindex,
}

if $apache_version == 2.4 {
if versioncmp($apache_version, '2.4') >= 0 {
$_directory_version = {
require => 'all granted',
}
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/apache_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class { 'apache': httpd_dir => '/tmp', service_ensure => stopped }
end
end

if $apache_version >= 2.4
if $apache_version == '2.4'
describe file($conf_file) do
it { should be_file }
it { should contain 'IncludeOptional "/tmp/root/*.conf"' }
Expand Down
12 changes: 6 additions & 6 deletions spec/acceptance/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
$suphp_configpath = 'undef'

if (_operatingsystem == 'Fedora' and _operatingsystemrelease >= 18) or (_operatingsystem != 'Fedora' and _operatingsystemrelease >= 7)
$apache_version = 2.4
$apache_version = '2.4'
else
$apache_version = 2.2
$apache_version = '2.2'
end
when 'Debian'
$confd_dir = '/etc/apache2/mods-available'
Expand All @@ -35,9 +35,9 @@
$suphp_configpath = '/etc/php5/apache2'

if _operatingsystem == 'Ubuntu' and _operatingsystemrelease >= 13.10
$apache_version = 2.4
$apache_version = '2.4'
else
$apache_version = 2.2
$apache_version = '2.2'
end
when 'FreeBSD'
$confd_dir = '/usr/local/etc/apache22/Includes'
Expand All @@ -50,8 +50,8 @@
$package_name = 'apache22'
$error_log = 'http-error.log'

$apache_version = 2.2
$apache_version = '2.2'
else
$apache_version = 0
$apache_version = '0'
end

4 changes: 2 additions & 2 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class { 'apache': }
pp = <<-EOS
class { 'apache': }
if $apache::apache_version >= 2.4 {
if versioncmp($apache::apache_version, '2.4') >= 0 {
$_files_match_directory = { 'path' => '(\.swp|\.bak|~)$', 'provider' => 'filesmatch', 'require' => 'all denied', }
} else {
$_files_match_directory = { 'path' => '(\.swp|\.bak|~)$', 'provider' => 'filesmatch', 'deny' => 'from all', }
Expand Down Expand Up @@ -211,7 +211,7 @@ class { 'apache': }
pp = <<-EOS
class { 'apache': }
if $apache::apache_version >= 2.4 {
if versioncmp($apache::apache_version, '2.4') >= 0 {
$_files_match_directory = { 'path' => 'private.html$', 'provider' => 'filesmatch', 'require' => 'all denied' }
} else {
$_files_match_directory = { 'path' => 'private.html$', 'provider' => 'filesmatch', 'deny' => 'from all' }
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@

context "with Apache version < 2.4" do
let :params do
{ :apache_version => 2.2 }
{ :apache_version => '2.2' }
end

it { should contain_file("/etc/apache2/apache2.conf").with_content %r{^Include "/etc/apache2/conf\.d/\*\.conf"$} }
end

context "with Apache version >= 2.4" do
let :params do
{ :apache_version => 2.4 }
{ :apache_version => '2.4' }
end

it { should contain_file("/etc/apache2/apache2.conf").with_content %r{^IncludeOptional "/etc/apache2/conf\.d/\*\.conf"$} }
Expand Down Expand Up @@ -279,15 +279,15 @@

context "with Apache version < 2.4" do
let :params do
{ :apache_version => 2.2 }
{ :apache_version => '2.2' }
end

it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^Include "/etc/httpd/conf\.d/\*\.conf"$} }
end

context "with Apache version >= 2.4" do
let :params do
{ :apache_version => 2.4 }
{ :apache_version => '2.4' }
end

it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^IncludeOptional "/etc/httpd/conf\.d/\*\.conf"$} }
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/mod/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
context "with Apache version < 2.4" do
let :params do
{
:apache_version => 2.2,
:apache_version => '2.2',
}
end

Expand All @@ -44,7 +44,7 @@
context "with Apache version >= 2.4" do
let :params do
{
:apache_version => 2.4,
:apache_version => '2.4',
}
end

Expand All @@ -68,7 +68,7 @@
context "with Apache version >= 2.4" do
let :params do
{
:apache_version => 2.4,
:apache_version => '2.4',
}
end

Expand Down
4 changes: 2 additions & 2 deletions spec/classes/mod/itk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
context "with Apache version < 2.4" do
let :params do
{
:apache_version => 2.2,
:apache_version => '2.2',
}
end

Expand All @@ -31,7 +31,7 @@
context "with Apache version >= 2.4" do
let :params do
{
:apache_version => 2.4,
:apache_version => '2.4',
}
end

Expand Down
8 changes: 4 additions & 4 deletions spec/classes/mod/prefork_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
context "with Apache version < 2.4" do
let :params do
{
:apache_version => 2.2,
:apache_version => '2.2',
}
end

Expand All @@ -31,7 +31,7 @@
context "with Apache version >= 2.4" do
let :params do
{
:apache_version => 2.4,
:apache_version => '2.4',
}
end

Expand All @@ -58,7 +58,7 @@
context "with Apache version < 2.4" do
let :params do
{
:apache_version => 2.2,
:apache_version => '2.2',
}
end

Expand All @@ -71,7 +71,7 @@
context "with Apache version >= 2.4" do
let :params do
{
:apache_version => 2.4,
:apache_version => '2.4',
}
end

Expand Down
8 changes: 4 additions & 4 deletions spec/classes/mod/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
context "with Apache version < 2.4" do
let :params do
{
:apache_version => 2.2,
:apache_version => '2.2',
}
end

Expand All @@ -31,7 +31,7 @@
context "with Apache version >= 2.4" do
let :params do
{
:apache_version => 2.4,
:apache_version => '2.4',
}
end

Expand All @@ -58,7 +58,7 @@
context "with Apache version < 2.4" do
let :params do
{
:apache_version => 2.2,
:apache_version => '2.2',
}
end

Expand All @@ -71,7 +71,7 @@
context "with Apache version >= 2.4" do
let :params do
{
:apache_version => 2.4,
:apache_version => '2.4',
}
end

Expand Down
Loading

0 comments on commit 81069bc

Please sign in to comment.