From c647db040758cbe2a3fb08662126819701062831 Mon Sep 17 00:00:00 2001 From: Xavier leune Date: Tue, 1 Apr 2014 11:48:03 +0200 Subject: [PATCH 1/4] Allow custom extensions for php handler --- manifests/mod/php.pp | 2 ++ templates/mod/php5.conf.erb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index 8c1b94d6b..2d954db5b 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -2,10 +2,12 @@ $package_name = undef, $package_ensure = 'present', $path = undef, + $extensions = ['.php'], ) { if ! defined(Class['apache::mod::prefork']) { fail('apache::mod::php requires apache::mod::prefork; please enable mpm_module => \'prefork\' on Class[\'apache\']') } + validate_array($extensions) ::apache::mod { 'php5': package => $package_name, package_ensure => $package_ensure, diff --git a/templates/mod/php5.conf.erb b/templates/mod/php5.conf.erb index 9eef7628a..2b0c8f784 100644 --- a/templates/mod/php5.conf.erb +++ b/templates/mod/php5.conf.erb @@ -14,7 +14,7 @@ # # Cause the PHP interpreter to handle files with a .php extension. # -AddHandler php5-script .php +AddHandler php5-script <%= @extensions.join(' ') %> AddType text/html .php # From 5a8df9ff5c7033cdf302425444fa4f5abd1d3808 Mon Sep 17 00:00:00 2001 From: Xavier leune Date: Tue, 1 Apr 2014 16:01:26 +0200 Subject: [PATCH 2/4] Changing extensions.join to extensions.flatten.compact.join --- templates/mod/php5.conf.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mod/php5.conf.erb b/templates/mod/php5.conf.erb index 2b0c8f784..25ae102e0 100644 --- a/templates/mod/php5.conf.erb +++ b/templates/mod/php5.conf.erb @@ -14,7 +14,7 @@ # # Cause the PHP interpreter to handle files with a .php extension. # -AddHandler php5-script <%= @extensions.join(' ') %> +AddHandler php5-script <%= @@extensions.flatten.compact.join(' ') %> AddType text/html .php # From fc347a870155dbfb9b8e9075ed15c296ccb66f29 Mon Sep 17 00:00:00 2001 From: Xavier leune Date: Tue, 1 Apr 2014 16:10:33 +0200 Subject: [PATCH 3/4] Typo --- templates/mod/php5.conf.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mod/php5.conf.erb b/templates/mod/php5.conf.erb index 25ae102e0..44df2ae06 100644 --- a/templates/mod/php5.conf.erb +++ b/templates/mod/php5.conf.erb @@ -14,7 +14,7 @@ # # Cause the PHP interpreter to handle files with a .php extension. # -AddHandler php5-script <%= @@extensions.flatten.compact.join(' ') %> +AddHandler php5-script <%= @extensions.flatten.compact.join(' ') %> AddType text/html .php # From 8fb2dfd46c5a17a36bef16081b25ce4e401115b7 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 1 May 2014 17:04:09 -0700 Subject: [PATCH 4/4] Update specs --- manifests/mod/php.pp | 1 + spec/acceptance/mod_php_spec.rb | 8 +++++--- spec/classes/mod/php_spec.rb | 8 ++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/manifests/mod/php.pp b/manifests/mod/php.pp index 2d954db5b..b797936bd 100644 --- a/manifests/mod/php.pp +++ b/manifests/mod/php.pp @@ -18,6 +18,7 @@ include ::apache::mod::dir Class['::apache::mod::mime'] -> Class['::apache::mod::dir'] -> Class['::apache::mod::php'] + # Template uses $extensions file { 'php5.conf': ensure => file, path => "${::apache::mod_dir}/php5.conf", diff --git a/spec/acceptance/mod_php_spec.rb b/spec/acceptance/mod_php_spec.rb index d1c991621..cf8054053 100644 --- a/spec/acceptance/mod_php_spec.rb +++ b/spec/acceptance/mod_php_spec.rb @@ -53,13 +53,15 @@ class { 'apache::mod::php': } end end - context "custom php admin_flag and php_admin_value" do + context "custom extensions, php_admin_flag, and php_admin_value" do it 'succeeds in puppeting php' do pp= <<-EOS class { 'apache': mpm_module => 'prefork', } - class { 'apache::mod::php': } + class { 'apache::mod::php': + extensions => ['.php','.php5'], + } apache::vhost { 'php.example.com': port => '80', docroot => '/var/www/php', @@ -67,7 +69,7 @@ class { 'apache::mod::php': } php_admin_flags => { 'engine' => 'on', }, } host { 'php.example.com': ip => '127.0.0.1', } - file { '/var/www/php/index.php': + file { '/var/www/php/index.php5': ensure => file, content => "\\n", } diff --git a/spec/classes/mod/php_spec.rb b/spec/classes/mod/php_spec.rb index 29adc870f..32b2ff099 100644 --- a/spec/classes/mod/php_spec.rb +++ b/spec/classes/mod/php_spec.rb @@ -64,6 +64,14 @@ :content => "LoadModule php5_module alternative-path\n" ) } end + context "with alternative extensions" do let :pre_condition do + 'class { "apache": }' + end + let :params do + { :extensions => ['.php','.php5']} + end + it { should contain_file("php5.conf").with_content =~ /AddHandler php5-script .php .php5\n/ } + end context "with specific version" do let :pre_condition do 'class { "apache": }'