Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion manifests/mod/event.pp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@
'listenbacklog' => $listenbacklog,
}

file { "${apache::mod_dir}/event.conf":
$eventconffile = $facts['os']['family'] ? {
'Debian' => "${apache::mod_dir}/mpm_event.conf",
default => "${apache::mod_dir}/event.conf",
}

file { $eventconffile:
ensure => file,
mode => $apache::file_mode,
content => epp('apache/mod/event.conf.epp', $parameters),
Expand Down
7 changes: 6 additions & 1 deletion manifests/mod/itk.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@
'enablecapabilities' => $enablecapabilities,
}

file { "${apache::mod_dir}/itk.conf":
$itkconffile = $facts['os']['family'] ? {
'Debian' => "${apache::mod_dir}/mpm_itk.conf",
default => "${apache::mod_dir}/itk.conf",
}

file { $itkconffile:
ensure => file,
mode => $apache::file_mode,
content => epp('apache/mod/itk.conf.epp', $parameters),
Expand Down
7 changes: 6 additions & 1 deletion manifests/mod/prefork.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@
'listenbacklog' => $listenbacklog,
}

file { "${apache::mod_dir}/prefork.conf":
$preforkconffile = $facts['os']['family'] ? {
'Debian' => "${apache::mod_dir}/mpm_prefork.conf",
default => "${apache::mod_dir}/prefork.conf",
}

file { $preforkconffile:
ensure => file,
content => epp('apache/mod/prefork.conf.epp', $parameters),
require => Exec["mkdir ${apache::mod_dir}"],
Expand Down
7 changes: 6 additions & 1 deletion manifests/mod/worker.pp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@
'maxrequestworkers' => $maxrequestworkers,
}

file { "${apache::mod_dir}/worker.conf":
$workerconffile = $facts['os']['family'] ? {
'Debian' => "${apache::mod_dir}/mpm_worker.conf",
default => "${apache::mod_dir}/worker.conf",
}

file { $workerconffile:
ensure => file,
content => epp('apache/mod/worker.conf.epp', $parameters),
require => Exec["mkdir ${apache::mod_dir}"],
Expand Down
120 changes: 56 additions & 64 deletions manifests/mpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,48 @@
$_path = "${lib_path}/${_lib}"
$_id = "mpm_${mpm}_module"

if $facts['os']['family'] == 'Suse' {
#mpms on Suse 12 don't use .so libraries so create a placeholder load file
file { "${mod_dir}/${mpm}.load":
ensure => file,
path => "${mod_dir}/${mpm}.load",
content => '',
require => [
Package['httpd'],
Exec["mkdir ${mod_dir}"],
],
before => File[$mod_dir],
notify => Class['apache::service'],
if $facts['os']['family'] == 'Debian' {
$mpm_modules = ['mpm_event', 'mpm_worker', 'mpm_prefork'] - "mpm_${mpm}"
$mpmloadfile = "${mod_dir}/mpm_${mpm}.load"
$mpmloadcontent = $mpm ? {
/(event|prefork|worker)/ => "# Conflicts: ${join($mpm_modules, ' ')}\nLoadModule ${_id} ${_path}\n",
'itk' => "# Depends: mpm_prefork\nLoadModule ${_id} ${_path}\n",
}
} else {
file { "${mod_dir}/${mpm}.load":
ensure => file,
path => "${mod_dir}/${mpm}.load",
content => "LoadModule ${_id} ${_path}\n",
require => [
Package['httpd'],
Exec["mkdir ${mod_dir}"],
],
before => File[$mod_dir],
notify => Class['apache::service'],
$mpmloadfile = "${mod_dir}/${mpm}.load"
$mpmloadcontent = $facts['os']['family'] ? {
'Suse' => '',
default => "LoadModule ${_id} ${_path}\n"
}
}

file { $mpmloadfile:
ensure => file,
path => $mpmloadfile,
content => $mpmloadcontent,
require => [
Package['httpd'],
Exec["mkdir ${mod_dir}"],
],
before => File[$mod_dir],
notify => Class['apache::service'],
}

case $facts['os']['family'] {
'Debian': {
file { "${apache::mod_enable_dir}/${mpm}.conf":
ensure => link,
target => "${apache::mod_dir}/${mpm}.conf",
require => Exec["mkdir ${apache::mod_enable_dir}"],
before => File[$apache::mod_enable_dir],
notify => Class['apache::service'],
}

file { "${apache::mod_enable_dir}/${mpm}.load":
ensure => link,
target => "${apache::mod_dir}/${mpm}.load",
require => Exec["mkdir ${apache::mod_enable_dir}"],
before => File[$apache::mod_enable_dir],
notify => Class['apache::service'],
file {
default:
ensure => link,
require => Exec["mkdir ${apache::mod_enable_dir}"],
before => File[$apache::mod_enable_dir],
notify => Class['apache::service'],
;
"${apache::mod_enable_dir}/mpm_${mpm}.conf":
target => "../mods-available/mpm_${mpm}.conf",
;
"${apache::mod_enable_dir}/mpm_${mpm}.load":
target => "../mods-available/mpm_${mpm}.load",
;
}

if $mpm == 'itk' {
Expand All @@ -67,9 +66,7 @@
require => Package['httpd'],
before => Class['apache::service'],
}
}

if $mpm == 'itk' {
package { 'libapache2-mpm-itk':
ensure => present,
before => [
Expand All @@ -91,33 +88,20 @@
include apache::mpm::disable_mpm_event
}
}

'FreeBSD': {
class { 'apache::package':
mpm_module => $mpm,
}
}
'Gentoo': {
# so we don't fail
}
'RedHat': {
# so we don't fail
}
'Suse': {
file { "${apache::mod_enable_dir}/${mpm}.conf":
ensure => link,
target => "${apache::mod_dir}/${mpm}.conf",
require => Exec["mkdir ${apache::mod_enable_dir}"],
before => File[$apache::mod_enable_dir],
notify => Class['apache::service'],
}

file { "${apache::mod_enable_dir}/${mpm}.load":
ensure => link,
target => "${apache::mod_dir}/${mpm}.load",
require => Exec["mkdir ${apache::mod_enable_dir}"],
before => File[$apache::mod_enable_dir],
notify => Class['apache::service'],
file {
default:
ensure => link,
require => Exec["mkdir ${apache::mod_enable_dir}"],
before => File[$apache::mod_enable_dir],
notify => Class['apache::service'],
;
"${apache::mod_enable_dir}/${mpm}.conf":
target => "${mod_dir}/${mpm}.conf",
;
"${apache::mod_enable_dir}/${mpm}.load":
target => "${mod_dir}/${mpm}.load",
;
}

if $mpm == 'itk' {
Expand All @@ -131,6 +115,14 @@
ensure => present,
}
}
'FreeBSD': {
class { 'apache::package':
mpm_module => $mpm,
}
}
'Gentoo', 'RedHat': {
# so we don't fail
}
default: {
fail("Unsupported osfamily ${$facts['os']['family']}")
}
Expand Down
17 changes: 10 additions & 7 deletions manifests/mpm/disable_mpm_event.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# @summary disable Apache-Module event
class apache::mpm::disable_mpm_event {
$event_command = ['/usr/sbin/a2dismod', 'mpm_event']
$event_onlyif = [['/usr/bin/test', '-e', join([$apache::mod_enable_dir, 'mpm_event.load'],'/')]]
exec { '/usr/sbin/a2dismod mpm_event':
command => $event_command,
onlyif => $event_onlyif,
require => Package['httpd'],
notify => Class['apache::service'],
$mod_names = ['event', 'mpm_event']
$mod_names.each | $mod_name| {
$event_command = ['/usr/sbin/a2dismod', $mod_name]
$event_onlyif = [['/usr/bin/test', '-e', join([$apache::mod_enable_dir, "${mod_name}.load"],'/')]]
exec { "/usr/sbin/a2dismod ${mod_name}":
command => $event_command,
onlyif => $event_onlyif,
require => Package['httpd'],
notify => Class['apache::service'],
}
}
}
17 changes: 10 additions & 7 deletions manifests/mpm/disable_mpm_prefork.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# @summary disable Apache-Module prefork
class apache::mpm::disable_mpm_prefork {
$prefork_command = ['/usr/sbin/a2dismod', 'prefork']
$prefork_onlyif = [['/usr/bin/test', '-e', join([$apache::mod_enable_dir, 'prefork.load'],'/')]]
exec { '/usr/sbin/a2dismod prefork':
command => $prefork_command,
onlyif => $prefork_onlyif,
require => Package['httpd'],
before => Class['apache::service'],
$mod_names = ['itk', 'mpm_itk', 'prefork', 'mpm_prefork']
$mod_names.each | $mod_name| {
$prefork_command = ['/usr/sbin/a2dismod', $mod_name]
$prefork_onlyif = [['/usr/bin/test', '-e', join([$apache::mod_enable_dir, "${mod_name}.load"],'/')]]
exec { "/usr/sbin/a2dismod ${mod_name}":
command => $prefork_command,
onlyif => $prefork_onlyif,
require => Package['httpd'],
notify => Class['apache::service'],
}
}
}
17 changes: 10 additions & 7 deletions manifests/mpm/disable_mpm_worker.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# @summary disable Apache-Module worker
class apache::mpm::disable_mpm_worker {
$worker_command = ['/usr/sbin/a2dismod', 'worker']
$worker_onlyif = [['/usr/bin/test', '-e', join([$apache::mod_enable_dir, 'worker.load'],'/')]]
exec { '/usr/sbin/a2dismod worker':
command => $worker_command,
onlyif => $worker_onlyif,
require => Package['httpd'],
before => Class['apache::service'],
$mod_names = ['worker', 'mpm_worker']
$mod_names.each | $mod_name| {
$worker_command = ['/usr/sbin/a2dismod', $mod_name]
$worker_onlyif = [['/usr/bin/test', '-e', join([$apache::mod_enable_dir, "${mod_name}.load"],'/')]]
exec { "/usr/sbin/a2dismod ${mod_name}":
command => $worker_command,
onlyif => $worker_onlyif,
require => Package['httpd'],
notify => Class['apache::service'],
}
}
}
68 changes: 36 additions & 32 deletions spec/classes/mod/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@

context 'on a Debian OS' do
include_examples 'Debian 11'
let(:loadcontent) do
"# Conflicts: mpm_worker mpm_prefork\n"\
"LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so\n"
end

it { is_expected.to contain_class('apache::params') }
it { is_expected.not_to contain_apache__mod('event') }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file') }
it { is_expected.to contain_file('/etc/apache2/mods-enabled/event.conf').with_ensure('link') }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file') }
it { is_expected.to contain_file('/etc/apache2/mods-enabled/mpm_event.conf').with_ensure('link') }

context 'Test mpm_event new params' do
let :params do
Expand All @@ -46,15 +50,15 @@
}
end

it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ServerLimit\s*0}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*StartServers\s*1}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MinSpareThreads\s*3}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxSpareThreads\s*4}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ThreadsPerChild\s*5}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ThreadLimit\s*7}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ListenBacklog\s*8}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxRequestWorkers\s*9}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxConnectionsPerChild\s*10}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ServerLimit\s*0}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*StartServers\s*1}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MinSpareThreads\s*3}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MaxSpareThreads\s*4}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ThreadsPerChild\s*5}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ThreadLimit\s*7}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ListenBacklog\s*8}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MaxRequestWorkers\s*9}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MaxConnectionsPerChild\s*10}) }
end

context 'Test mpm_event old style params' do
Expand All @@ -72,15 +76,15 @@
}
end

it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ServerLimit\s*0}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*StartServers\s*1}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MinSpareThreads\s*3}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxSpareThreads\s*4}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ThreadsPerChild\s*5}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ThreadLimit\s*7}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ListenBacklog\s*8}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestWorkers}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxConnectionsPerChild}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ServerLimit\s*0}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*StartServers\s*1}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MinSpareThreads\s*3}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*MaxSpareThreads\s*4}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ThreadsPerChild\s*5}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ThreadLimit\s*7}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').with_content(%r{^\s*ListenBacklog\s*8}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestWorkers}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxConnectionsPerChild}) }
end

context 'Test mpm_event false params' do
Expand All @@ -98,23 +102,23 @@
}
end

it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*ServerLimit}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*StartServers}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MinSpareThreads}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxSpareThreads}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*ThreadsPerChild}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*ThreadLimit}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*ListenBacklog}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestWorkers}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxConnectionsPerChild}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*ServerLimit}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*StartServers}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MinSpareThreads}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxSpareThreads}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*ThreadsPerChild}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*ThreadLimit}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*ListenBacklog}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestWorkers}) }
it { is_expected.to contain_file('/etc/apache2/mods-available/mpm_event.conf').with_ensure('file').without_content(%r{^\s*MaxConnectionsPerChild}) }
end

it {
expect(subject).to contain_file('/etc/apache2/mods-available/event.load').with('ensure' => 'file',
'content' => "LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so\n")
expect(subject).to contain_file('/etc/apache2/mods-available/mpm_event.load').with('ensure' => 'file',
'content' => loadcontent)
}

it { is_expected.to contain_file('/etc/apache2/mods-enabled/event.load').with_ensure('link') }
it { is_expected.to contain_file('/etc/apache2/mods-enabled/mpm_event.load').with_ensure('link') }
end

context 'on a RedHat OS' do
Expand Down
Loading
Loading