Skip to content

Commit

Permalink
Support itk with mod php
Browse files Browse the repository at this point in the history
  • Loading branch information
corvus_ch committed Aug 6, 2014
1 parent 62dac65 commit fcb4a09
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
11 changes: 8 additions & 3 deletions manifests/mod/php.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
$template = 'apache/mod/php5.conf.erb',
$source = undef,
) {
if ! defined(Class['apache::mod::prefork']) {
fail('apache::mod::php requires apache::mod::prefork; please enable mpm_module => \'prefork\' on Class[\'apache\']')
if defined(Class['apache::mod::prefork']) {
Class['::apache::mod::prefork']->File['php5.conf']
}
elsif defined(Class['apache::mod::itk']) {
Class['::apache::mod::itk']->File['php5.conf']
}
else {
fail('apache::mod::php requires apache::mod::prefork or apache::mod::itk; please enable mpm_module => \'prefork\' or mpm_module => \'itk\' on Class[\'apache\']')
}
validate_array($extensions)

Expand Down Expand Up @@ -46,7 +52,6 @@
content => $manage_content,
source => $source,
require => [
Class['::apache::mod::prefork'],
Exec["mkdir ${::apache::mod_dir}"],
],
before => File[$::apache::mod_dir],
Expand Down
45 changes: 34 additions & 11 deletions spec/classes/mod/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@
'class { "apache": mpm_module => prefork, }'
end
it { is_expected.to contain_class("apache::params") }
it { is_expected.to contain_class("apache::mod::prefork") }
it { is_expected.to contain_apache__mod('php5') }
it { is_expected.to contain_package("libapache2-mod-php5") }
it { is_expected.to contain_file("php5.load").with(
:content => "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so\n"
) }
end
context 'with mpm_module => worker' do
context "with mpm_module => itk" do
let :pre_condition do
'class { "apache": mpm_module => worker, }'
end
it 'should raise an error' do
expect { subject }.to raise_error Puppet::Error, /mpm_module => 'prefork'/
'class { "apache": mpm_module => itk, }'
end
it { is_expected.to contain_class("apache::params") }
it { is_expected.to contain_class("apache::mod::itk") }
it { is_expected.to contain_apache__mod('php5') }
it { is_expected.to contain_package("libapache2-mod-php5") }
it { is_expected.to contain_file("php5.load").with(
:content => "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so\n"
) }
end
end
describe "on a RedHat OS" do
Expand Down Expand Up @@ -99,12 +104,21 @@
'class { "apache": mpm_module => prefork, }'
end
it { is_expected.to contain_class("apache::params") }
it { is_expected.to contain_class("apache::mod::prefork") }
it { is_expected.to contain_apache__mod('php5') }
it { is_expected.to contain_package("php") }
it { is_expected.to contain_file("php5.load").with(
:content => "LoadModule php5_module modules/libphp5.so\n"
) }
end
context "with mpm_module => itk" do
let :pre_condition do
'class { "apache": mpm_module => itk, }'
end
it 'should raise an error' do
expect { expect(subject).to contain_class("apache::mod::itk") }.to raise_error Puppet::Error, /Unsupported osfamily RedHat/
end
end
end
describe "on a FreeBSD OS" do
let :facts do
Expand All @@ -127,14 +141,15 @@
it { is_expected.to contain_package("lang/php5") }
it { is_expected.to contain_file('php5.load') }
end
# FIXME: not sure about the following context
context 'with mpm_module => worker' do
context "with mpm_module => itk" do
let :pre_condition do
'class { "apache": mpm_module => worker, }'
end
it 'should raise an error' do
expect { expect(subject).to contain_apache__mod('php5') }.to raise_error Puppet::Error, /mpm_module => 'prefork'/
'class { "apache": mpm_module => itk, }'
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_class('apache::mod::itk') }
it { is_expected.to contain_apache__mod('php5') }
it { is_expected.to contain_package("lang/php5") }
it { is_expected.to contain_file('php5.load') }
end
end
describe "OS independent tests" do
Expand Down Expand Up @@ -224,5 +239,13 @@
:source => 'some-path'
) }
end
context 'with mpm_module => worker' do
let :pre_condition do
'class { "apache": mpm_module => worker, }'
end
it 'should raise an error' do
expect { expect(subject).to contain_apache__mod('php5') }.to raise_error Puppet::Error, /mpm_module => 'prefork' or mpm_module => 'itk'/
end
end
end
end

0 comments on commit fcb4a09

Please sign in to comment.