Skip to content

Commit

Permalink
fix(redhat): use correct vhostdir, sitesdir and logrotate script for …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
l00d3r authored Oct 28, 2021
1 parent ea777fd commit c4b8538
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
13 changes: 13 additions & 0 deletions apache/config/logrotate.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,3 +41,4 @@ apache-config-logrotate-file-managed:
fi; \
endscript
}
{% endif %}
6 changes: 3 additions & 3 deletions apache/osfamilymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions test/integration/default/controls/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions test/integration/modules/controls/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit c4b8538

Please sign in to comment.