2020-07-18 18:23:58 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
control 'apache configuration' do
|
2020-09-13 06:07:20 +02:00
|
|
|
title 'should match desired lines'
|
2020-07-18 18:23:58 +02:00
|
|
|
|
2020-09-13 06:07:20 +02:00
|
|
|
apachectl = 'apachectl -t'
|
|
|
|
case platform[:family]
|
|
|
|
when 'debian', 'suse'
|
|
|
|
vhostdir = '/etc/apache2/sites-available'
|
|
|
|
logrotatedir = '/etc/logrotate.d/apache2'
|
|
|
|
logdir = '/var/log/apache2'
|
|
|
|
moddir = '/etc/apache2/mods-enabled'
|
|
|
|
sitesdir = '/etc/apache2/sites-enabled'
|
|
|
|
when 'redhat', 'fedora'
|
|
|
|
vhostdir = '/etc/httpd/vhosts.d'
|
|
|
|
logrotatedir = '/etc/logrotate.d/httpd'
|
|
|
|
logdir = '/var/log/httpd'
|
|
|
|
moddir = '/etc/httpd/conf.modules.d'
|
|
|
|
sitesdir = '/etc/httpd/sites-enabled'
|
|
|
|
apachectl = 'httpd -t'
|
|
|
|
when 'gentoo'
|
|
|
|
vhostdir = '/etc/apache2/vhosts.d'
|
|
|
|
logrotatedir = '/etc/logrotate.d/apache2'
|
|
|
|
logdir = '/var/log/apache2'
|
|
|
|
moddir = '/etc/apache2/mods-enabled'
|
|
|
|
sitesdir = '/etc/apache2/sites-enabled'
|
|
|
|
# `linux` here is sufficient for `arch`
|
|
|
|
when 'linux', 'arch'
|
|
|
|
vhostdir = '/etc/httpd/conf/vhosts'
|
|
|
|
logrotatedir = '/etc/logrotate.d/httpd'
|
|
|
|
logdir = '/var/log/httpd'
|
|
|
|
moddir = '/etc/httpd/conf.modules.d'
|
|
|
|
sitesdir = '/etc/httpd/sites-enabled'
|
|
|
|
when 'bsd'
|
|
|
|
vhostdir = '/usr/local/etc/apache24/Includes'
|
|
|
|
logdir = '/var/log'
|
2021-04-03 23:39:56 +02:00
|
|
|
logrotatedir = '/usr/local/etc/logrotate.d/apache2'
|
|
|
|
moddir = '/usr/local/etc/apache24/modules.d'
|
|
|
|
# https://docs.freebsd.org/en/books/handbook/network-servers/#_virtual_hosting
|
|
|
|
# All done under `/usr/local/etc/apache24/httpd.conf`
|
|
|
|
sitesdir = '/usr/local/etc/apache24'
|
2020-09-13 06:07:20 +02:00
|
|
|
end
|
|
|
|
describe command(apachectl) do
|
2020-07-18 18:23:58 +02:00
|
|
|
its('stdout') { should eq '' }
|
|
|
|
its('stderr') { should include 'Syntax OK' }
|
|
|
|
its('exit_status') { should eq 0 }
|
|
|
|
end
|
2020-09-13 06:07:20 +02:00
|
|
|
describe file(vhostdir) do
|
|
|
|
it { should exist }
|
|
|
|
it { should be_directory }
|
|
|
|
its('type') { should eq :directory }
|
|
|
|
end
|
|
|
|
describe file(logrotatedir) do
|
|
|
|
it { should exist }
|
|
|
|
its('type') { should eq :file }
|
|
|
|
end
|
|
|
|
describe file(logdir) do
|
|
|
|
it { should exist }
|
|
|
|
it { should be_directory }
|
|
|
|
its('type') { should eq :directory }
|
|
|
|
end
|
|
|
|
describe file(moddir) do
|
|
|
|
it { should exist }
|
|
|
|
it { should be_directory }
|
|
|
|
its('type') { should eq :directory }
|
|
|
|
end
|
|
|
|
describe file(sitesdir) do
|
|
|
|
it { should exist }
|
|
|
|
it { should be_directory }
|
|
|
|
its('type') { should eq :directory }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
control 'apache configuration (unique)' do
|
|
|
|
title 'should match desired lines'
|
|
|
|
|
2021-04-03 23:39:56 +02:00
|
|
|
config_file_group = 'root'
|
2020-09-13 06:07:20 +02:00
|
|
|
case platform[:family]
|
|
|
|
when 'debian'
|
|
|
|
config_file = '/etc/apache2/apache2.conf'
|
|
|
|
wwwdir = '/srv'
|
|
|
|
when 'suse'
|
|
|
|
config_file = '/etc/apache2/httpd.conf'
|
|
|
|
wwwdir = '/srv/www'
|
|
|
|
when 'redhat', 'fedora'
|
|
|
|
config_file = '/etc/httpd/conf/httpd.conf'
|
|
|
|
wwwdir = '/var/www'
|
|
|
|
when 'gentoo'
|
|
|
|
config_file = '/etc/apache2/httpd.conf'
|
|
|
|
wwwdir = '/var/www'
|
|
|
|
when 'linux', 'arch'
|
|
|
|
config_file = '/etc/httpd/conf/httpd.conf'
|
|
|
|
wwwdir = '/srv/http'
|
|
|
|
when 'bsd'
|
|
|
|
config_file = '/usr/local/etc/apache24/httpd.conf'
|
2021-04-03 23:39:56 +02:00
|
|
|
config_file_group = 'wheel'
|
2020-09-13 06:07:20 +02:00
|
|
|
wwwdir = '/usr/local/www/apache24/'
|
|
|
|
end
|
|
|
|
describe file(config_file) do
|
|
|
|
it { should be_file }
|
2021-04-03 23:39:56 +02:00
|
|
|
it { should be_grouped_into config_file_group }
|
2020-09-13 06:07:20 +02:00
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
its('content') do
|
|
|
|
should include(
|
|
|
|
'This file is managed by Salt! Do not edit by hand!'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
describe file(wwwdir) do
|
|
|
|
it { should exist }
|
|
|
|
it { should be_directory }
|
|
|
|
its('type') { should eq :directory }
|
|
|
|
end
|
2020-07-18 18:23:58 +02:00
|
|
|
end
|