From c4b85381288ae878207ffa5d2cc36cabc916e8f1 Mon Sep 17 00:00:00 2001 From: l00d3r <45118187+l00d3r@users.noreply.github.com> Date: Thu, 28 Oct 2021 11:35:24 +0300 Subject: [PATCH] fix(redhat): use correct vhostdir, sitesdir and logrotate script for redhat family (#376) * fix(redhat): use correct dirs for redhat family Red hat family distributions do not implement sites-enabled nor vhosts.d directories and all virtual hosts are under /etc/httpd/conf.d Redhat based distros don't have /etc/init.d/httpd to rotate logs. Default for them uses systemctl reload to rotate logs --- apache/config/logrotate.sls | 13 +++++++++++++ apache/osfamilymap.yaml | 6 +++--- test/integration/default/controls/config_spec.rb | 4 ++-- test/integration/modules/controls/config_spec.rb | 4 ++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/apache/config/logrotate.sls b/apache/config/logrotate.sls index fa1573c6..3390e11c 100644 --- a/apache/config/logrotate.sls +++ b/apache/config/logrotate.sls @@ -8,6 +8,18 @@ apache-config-logrotate-file-managed: file.managed: - name: {{ apache.logrotatedir }} - makedirs: True + {%- if grains.os_family == "RedHat" %} + - contents: | + {{ apache.logdir }}/*log { + missingok + notifempty + sharedscripts + delaycompress + postrotate + /bin/systemctl reload {{ apache.service.name }}.service > /dev/null 2>/dev/null || true + endscript + } + {% else %} - contents: | {{ apache.logdir }}/*.log { daily @@ -29,3 +41,4 @@ apache-config-logrotate-file-managed: fi; \ endscript } + {% endif %} diff --git a/apache/osfamilymap.yaml b/apache/osfamilymap.yaml index 469dc3e3..4de42dc3 100644 --- a/apache/osfamilymap.yaml +++ b/apache/osfamilymap.yaml @@ -74,19 +74,19 @@ RedHat: mod_geoip: mod_geoip mod_geoip_database: GeoIP - vhostdir: /etc/httpd/vhosts.d + vhostdir: /etc/httpd/conf.d confdir: /etc/httpd/conf.d modulesdir: /usr/lib64/httpd/modules confext: .conf default_site: default - default_site_ssl: default-ssl + default_site_ssl: ssl logdir: /var/log/httpd logrotatedir: /etc/logrotate.d/httpd wwwdir: /var/www default_charset: UTF-8 use_require: false moddir: /etc/httpd/conf.modules.d - sitesdir: /etc/httpd/sites-enabled + sitesdir: /etc/httpd/conf.d Suse: pkg: diff --git a/test/integration/default/controls/config_spec.rb b/test/integration/default/controls/config_spec.rb index 678bf50c..414539f7 100644 --- a/test/integration/default/controls/config_spec.rb +++ b/test/integration/default/controls/config_spec.rb @@ -16,10 +16,10 @@ moddir = '/etc/apache2/mods-enabled' sitesdir = '/etc/apache2/vhosts.d' when 'redhat', 'fedora' - vhostdir = '/etc/httpd/vhosts.d' + vhostdir = '/etc/httpd/conf.d' logrotatedir = '/etc/logrotate.d/httpd' moddir = '/etc/httpd/conf.modules.d' - sitesdir = '/etc/httpd/sites-enabled' + sitesdir = '/etc/httpd/conf.d' when 'gentoo' vhostdir = '/etc/apache2/vhosts.d' logrotatedir = '/etc/logrotate.d/apache2' diff --git a/test/integration/modules/controls/config_spec.rb b/test/integration/modules/controls/config_spec.rb index 71e3dc98..b3535cb2 100644 --- a/test/integration/modules/controls/config_spec.rb +++ b/test/integration/modules/controls/config_spec.rb @@ -18,11 +18,11 @@ moddir = '/etc/apache2/mods-enabled' sitesdir = '/etc/apache2/vhosts.d' when 'redhat', 'fedora' - vhostdir = '/etc/httpd/vhosts.d' + vhostdir = '/etc/httpd/conf.d' logrotatedir = '/etc/logrotate.d/httpd' logdir = '/var/log/httpd' moddir = '/etc/httpd/conf.modules.d' - sitesdir = '/etc/httpd/sites-enabled' + sitesdir = '/etc/httpd/conf.d' apachectl = 'httpd -t' when 'gentoo' vhostdir = '/etc/apache2/vhosts.d'