From bd890c22ba2d8ee1b929052056ca310d2d26bdc0 Mon Sep 17 00:00:00 2001 From: Steven Merrill Date: Sat, 16 Aug 2014 22:50:37 -0400 Subject: [PATCH] Add apache::conf_dir, use it instead of params. This is another change needed to make the httpd24 Software Collection work on RHELish boxes. Fix mod_systemd on RHEL/CentOS 6. Puppet < 3.0 does not have unless. Try another fix for Puppet 2.7 / Facter 1.7. Add README and tests for ::apache::conf_dir. --- README.md | 4 ++++ manifests/default_mods.pp | 5 ++++- manifests/init.pp | 5 +++-- manifests/mod.pp | 2 +- manifests/mod/mime_magic.pp | 2 +- spec/classes/apache_spec.rb | 12 ++++++++++++ 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index eaf36b14ab..e6828afed8 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,10 @@ You may establish a default vhost in this class, the `vhost` class, or both. You Configures the behavior of the module templates, package names, and default mods by setting the Apache version. Default is determined by the class `apache::version` using the OS family and release. It should not be configured manually without special reason. +#####`conf_dir` + +Changes the location of the configuration directory the main configuration file is placed in. Defaults to '/etc/httpd/conf' on RedHat, '/etc/apache2' on Debian, and '/usr/local/etc/apache22' on FreeBSD. + #####`confd_dir` Changes the location of the configuration directory your custom configuration files are placed in. Defaults to '/etc/httpd/conf' on RedHat, '/etc/apache2' on Debian, and '/usr/local/etc/apache22' on FreeBSD. diff --git a/manifests/default_mods.pp b/manifests/default_mods.pp index 03696f3d7c..80cca7046c 100644 --- a/manifests/default_mods.pp +++ b/manifests/default_mods.pp @@ -11,7 +11,10 @@ ::apache::mod { 'log_config': } if versioncmp($apache_version, '2.4') >= 0 { # Lets fork it - ::apache::mod { 'systemd': } + # Do not try to load mod_systemd on RHEL/CentOS 6 SCL. + if !($::osfamily == 'redhat' and versioncmp($::operatingsystemrelease, '7.0') == -1) { + ::apache::mod { 'systemd': } + } ::apache::mod { 'unixd': } } } diff --git a/manifests/init.pp b/manifests/init.pp index 709c507da9..1c9c758618 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -36,6 +36,7 @@ $timeout = '120', $httpd_dir = $::apache::params::httpd_dir, $server_root = $::apache::params::server_root, + $conf_dir = $::apache::params::conf_dir, $confd_dir = $::apache::params::confd_dir, $vhost_dir = $::apache::params::vhost_dir, $vhost_enable_dir = $::apache::params::vhost_enable_dir, @@ -219,7 +220,7 @@ content => template('apache/ports_header.erb') } - if $::apache::params::conf_dir and $::apache::params::conf_file { + if $::apache::conf_dir and $::apache::params::conf_file { case $::osfamily { 'debian': { $docroot = '/var/www' @@ -276,7 +277,7 @@ # - $server_tokens # - $server_signature # - $trace_enable - file { "${::apache::params::conf_dir}/${::apache::params::conf_file}": + file { "${::apache::conf_dir}/${::apache::params::conf_file}": ensure => file, content => template($conf_template), notify => Class['Apache::Service'], diff --git a/manifests/mod.pp b/manifests/mod.pp index aa5ea3f3bd..2795578ec8 100644 --- a/manifests/mod.pp +++ b/manifests/mod.pp @@ -64,7 +64,7 @@ $package_before = $::osfamily ? { 'freebsd' => [ File[$_loadfile_name], - File["${::apache::params::conf_dir}/${::apache::params::conf_file}"] + File["${::apache::conf_dir}/${::apache::params::conf_file}"] ], default => File[$_loadfile_name], } diff --git a/manifests/mod/mime_magic.pp b/manifests/mod/mime_magic.pp index 9de8bc4bc6..c276268e4d 100644 --- a/manifests/mod/mime_magic.pp +++ b/manifests/mod/mime_magic.pp @@ -1,5 +1,5 @@ class apache::mod::mime_magic ( - $magic_file = "${::apache::params::conf_dir}/magic" + $magic_file = "${::apache::conf_dir}/magic" ) { apache::mod { 'mime_magic': } # Template uses $magic_file diff --git a/spec/classes/apache_spec.rb b/spec/classes/apache_spec.rb index c647226329..198f1138bf 100644 --- a/spec/classes/apache_spec.rb +++ b/spec/classes/apache_spec.rb @@ -310,6 +310,18 @@ it { is_expected.to contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^Include "/etc/httpd/mod\.d/\*\.load"$} } end + describe "Alternate conf directory" do + let :params do + { :conf_dir => '/opt/rh/root/etc/httpd/conf' } + end + + it { is_expected.to contain_file("/opt/rh/root/etc/httpd/conf/httpd.conf").with( + 'ensure' => 'file', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) } + end + describe "Alternate conf.d directory" do let :params do { :confd_dir => '/etc/httpd/special_conf.d' }