From 7511cdaeaba8adc9afbadfaa60d65fe77abccdfa Mon Sep 17 00:00:00 2001 From: Justin Lambert Date: Thu, 4 Dec 2014 03:32:21 -0700 Subject: [PATCH] MODULES-1554: update error docs and icons path for RHEL7-based systems --- manifests/init.pp | 3 -- manifests/mod/alias.pp | 7 +++- manifests/params.pp | 8 +++- spec/classes/mod/alias_spec.rb | 68 ++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 spec/classes/mod/alias_spec.rb diff --git a/manifests/init.pp b/manifests/init.pp index 32966b86f..a8084131f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -242,21 +242,18 @@ 'debian': { $pidfile = "\${APACHE_PID_FILE}" $error_log = 'error.log' - $error_documents_path = '/usr/share/apache2/error' $scriptalias = '/usr/lib/cgi-bin' $access_log_file = 'access.log' } 'redhat': { $pidfile = 'run/httpd.pid' $error_log = 'error_log' - $error_documents_path = '/var/www/error' $scriptalias = '/var/www/cgi-bin' $access_log_file = 'access_log' } 'freebsd': { $pidfile = '/var/run/httpd.pid' $error_log = 'httpd-error.log' - $error_documents_path = '/usr/local/www/apache22/error' $scriptalias = '/usr/local/www/apache22/cgi-bin' $access_log_file = 'httpd-access.log' } diff --git a/manifests/mod/alias.pp b/manifests/mod/alias.pp index ee017b490..0e019abbd 100644 --- a/manifests/mod/alias.pp +++ b/manifests/mod/alias.pp @@ -1,9 +1,14 @@ class apache::mod::alias( $apache_version = $apache::apache_version ) { + $ver24 = versioncmp($apache_version, 2.4) >= 0 + $icons_path = $::osfamily ? { 'debian' => '/usr/share/apache2/icons', - 'redhat' => '/var/www/icons', + 'redhat' => $ver24 ? { + true => '/usr/share/httpd/icons', + default => '/var/www/icons', + }, 'freebsd' => '/usr/local/www/apache22/icons', } apache::mod { 'alias': } diff --git a/manifests/params.pp b/manifests/params.pp index 616102fa6..7e19d99fa 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -105,7 +105,11 @@ $mime_support_package = 'mailcap' $mime_types_config = '/etc/mime.types' $docroot = '/var/www/html' - if $::osfamily == 'RedHat' { + $error_documents_path = $::apache::version::distrelease ? { + '7' => '/usr/share/httpd/error', + default => '/var/www/error' + } + if $::osfamily == "RedHat" { $wsgi_socket_prefix = '/var/run/wsgi' } else { $wsgi_socket_prefix = undef @@ -219,6 +223,7 @@ 'base_rules/modsecurity_crs_59_outbound_blocking.conf', 'base_rules/modsecurity_crs_60_correlation.conf' ] + $error_documents_path = '/usr/share/apache2/error' # # Passenger-specific settings @@ -335,6 +340,7 @@ $mime_types_config = '/usr/local/etc/mime.types' $wsgi_socket_prefix = undef $docroot = '/usr/local/www/apache22/data' + $error_documents_path = '/usr/local/www/apache22/error' } else { fail("Class['apache::params']: Unsupported osfamily: ${::osfamily}") } diff --git a/spec/classes/mod/alias_spec.rb b/spec/classes/mod/alias_spec.rb new file mode 100644 index 000000000..503575af6 --- /dev/null +++ b/spec/classes/mod/alias_spec.rb @@ -0,0 +1,68 @@ +require 'spec_helper' + +describe 'apache::mod::alias', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS", :compile do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :lsbdistcodename => 'squeeze', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :operatingsystemrelease => '6', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + it { is_expected.to contain_apache__mod("alias") } + it { is_expected.to contain_file("alias.conf").with(:content => /Alias \/icons\/ "\/usr\/share\/apache2\/icons\/"/) } + end + context "on a RedHat 6-based OS", :compile do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '6', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + it { is_expected.to contain_apache__mod("alias") } + it { is_expected.to contain_file("alias.conf").with(:content => /Alias \/icons\/ "\/var\/www\/icons\/"/) } + end + context "on a RedHat 7-based OS", :compile do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '7', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + it { is_expected.to contain_apache__mod("alias") } + it { is_expected.to contain_file("alias.conf").with(:content => /Alias \/icons\/ "\/usr\/share\/httpd\/icons\/"/) } + end + context "on a FreeBSD OS", :compile do + let :facts do + { + :id => 'root', + :kernel => 'FreeBSD', + :osfamily => 'FreeBSD', + :operatingsystem => 'FreeBSD', + :operatingsystemrelease => '9', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + it { is_expected.to contain_apache__mod("alias") } + it { is_expected.to contain_file("alias.conf").with(:content => /Alias \/icons\/ "\/usr\/local\/www\/apache22\/icons\/"/) } + end +end