From d056b71737c862f41aaae1295c068f02a954f554 Mon Sep 17 00:00:00 2001 From: Thomas Bellman <bellman@nsc.liu.se> Date: Wed, 4 Apr 2018 19:02:09 +0200 Subject: [PATCH] Handle EL-7 Include directives in httpd.conf. The default /etc/httpd/conf/httpd.conf file shipped by EL-6, contains the line "Include conf.d/*.conf". In EL-7, that line has been changed to "IncludeOptional conf.d/*.conf", so it will not throw an error if there are no files in the conf.d directory. Change to handle both variants, and also handle if there should be more than one such line, or none at all. The EL-7 httpd.conf file also contains "Include conf.modules.d/*.conf", as they have moved all the default LoadModule directives to files in the conf.modules.d directory. We don't want to disable that, so keep that line. The conf.modules.d stuff also affects modules installed as separate packages, e.g. mod_ssl, mod_wsgi and mod_perl, as the LoadModule directive those packages provide are now in a separate file in the conf.modules.d directory, not in the config file in conf.d. That only causes a warning about the module being loaded twice, though, so is not particularly dangerous. --- manifests/init.pp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9e7aa27..486875f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -63,11 +63,11 @@ class apache::base require => Package['httpd'], notify => Class[apache::service]; } # We do not want to blindly include things in the conf.d directory. - ensure_line { + regexp_replace_lines { 'apache::base::no_include_all': file => $apache::configfile, - line => '##--Include conf.d/*.conf', - pattern => '^\s*Include\s+conf\.d/\*\.conf\s*$', + pattern => '^\s*Include[A-Za-z]*\s+conf\.d/.*\*.*$', + replacement => '## DISABLED: \&', require => Package['httpd'], notify => Class[apache::service]; } @@ -177,10 +177,11 @@ define apache::include_file($content=undef, $source=undef, $ensure='present') "apache::include_file::include::${name}": file => $apache::configfile, line => "Include conf.d/${name}.conf", - where => '^##--Include conf\.d/\*\.conf$', addhow => append, - require => [ Ensure_line['apache::base::no_include_all'], - File[$includefile] ], + require => [ + Regexp_replace_lines['apache::base::no_include_all'], + File[$includefile] + ], notify => Class[apache::service]; } } -- GitLab