From fcb4a09e38d8a7aaba7eefc90ce031d5cb9bc84d Mon Sep 17 00:00:00 2001 From: corvus_ch Date: Tue, 5 Aug 2014 08:33:15 +0200 Subject: [PATCH] Support itk with mod php --- manifests/mod/php.pp | 11 ++++++--- spec/classes/mod/php_spec.rb | 45 +++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index a94bfe50b..ad0ff48a0 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -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) @@ -46,7 +52,6 @@ content => $manage_content, source => $source, require => [ - Class['::apache::mod::prefork'], Exec["mkdir ${::apache::mod_dir}"], ], before => File[$::apache::mod_dir], diff --git a/spec/classes/mod/php_spec.rb b/spec/classes/mod/php_spec.rb index 76fd69226..c61cdf6f5 100644 --- a/spec/classes/mod/php_spec.rb +++ b/spec/classes/mod/php_spec.rb @@ -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 @@ -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 @@ -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 @@ -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