From 736382c3d04932af8ebdcafdadcd020275b961c7 Mon Sep 17 00:00:00 2001 From: Adam Malone Date: Mon, 27 Jan 2014 16:35:24 +1100 Subject: [PATCH] Allows for the configuration of mod_actions, specifically the action type triggered by the request. --- README.md | 1 + manifests/default_mods.pp | 4 ++-- manifests/mod/actions.pp | 3 +++ manifests/vhost.pp | 1 + spec/acceptance/vhost_spec.rb | 19 +++++++++++++++++++ spec/defines/vhost_spec.rb | 13 ++++++++++++- templates/vhost.conf.erb | 1 + templates/vhost/_action.erb | 4 ++++ templates/vhost/_scriptalias.erb | 2 +- 9 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 manifests/mod/actions.pp create mode 100644 templates/vhost/_action.erb diff --git a/README.md b/README.md index fd21507cd..353120e3c 100644 --- a/README.md +++ b/README.md @@ -413,6 +413,7 @@ Used to enable arbitrary Apache HTTPD modules for which there is no specific `ap There are many `apache::mod::[name]` classes within this module that can be declared using `include`: +* `actions` * `alias` * `auth_basic` * `auth_kerb` diff --git a/manifests/default_mods.pp b/manifests/default_mods.pp index 139503e3c..af9889621 100644 --- a/manifests/default_mods.pp +++ b/manifests/default_mods.pp @@ -21,12 +21,12 @@ include ::apache::mod::reqtimeout } 'redhat': { + include ::apache::mod::actions include ::apache::mod::cache include ::apache::mod::mime include ::apache::mod::mime_magic include ::apache::mod::vhost_alias include ::apache::mod::rewrite - ::apache::mod { 'actions': } ::apache::mod { 'auth_digest': } ::apache::mod { 'authn_anon': } ::apache::mod { 'authn_dbm': } @@ -55,6 +55,7 @@ } } 'freebsd': { + include ::apache::mod::actions include ::apache::mod::cache include ::apache::mod::disk_cache include ::apache::mod::headers @@ -65,7 +66,6 @@ include ::apache::mod::userdir include ::apache::mod::vhost_alias - ::apache::mod { 'actions': } ::apache::mod { 'asis': } ::apache::mod { 'auth_digest': } ::apache::mod { 'authn_alias': } diff --git a/manifests/mod/actions.pp b/manifests/mod/actions.pp new file mode 100644 index 000000000..3b60f297f --- /dev/null +++ b/manifests/mod/actions.pp @@ -0,0 +1,3 @@ +class apache::mod::actions { + apache::mod { 'actions': } +} diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 8525235e9..5d61b267a 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -169,6 +169,7 @@ $wsgi_script_aliases = undef, $custom_fragment = undef, $itk = undef, + $action = undef, $fastcgi_server = undef, $fastcgi_socket = undef, $fastcgi_dir = undef, diff --git a/spec/acceptance/vhost_spec.rb b/spec/acceptance/vhost_spec.rb index f6749d35a..d3133e0a3 100644 --- a/spec/acceptance/vhost_spec.rb +++ b/spec/acceptance/vhost_spec.rb @@ -682,6 +682,25 @@ class { 'apache': service_ensure => stopped, } end end + describe 'actions' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + action => 'php-fastcgi', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'Action php-fastcgi /cgi-bin virtual' } + end + end + describe 'suphp' do it 'applies cleanly' do pp = <<-EOS diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index 46e6fd395..b16ce8840 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -269,7 +269,7 @@ :attr => 'scriptalias', :value => '/usr/scripts', :match => [ - /^ ScriptAlias \/cgi-bin\/ "\/usr\/scripts"$/, + /^ ScriptAlias \/cgi-bin "\/usr\/scripts"$/, ], }, { @@ -1179,6 +1179,17 @@ end end + describe 'when action is specified specified' do + let :params do default_params.merge({ + :action => 'php-fastcgi', + }) end + it 'should set Action' do + should contain_file("25-#{title}.conf").with_content( + /^ Action php-fastcgi \/cgi-bin virtual$/ + ) + end + end + describe 'when suphp_engine is on and suphp_configpath is specified' do let :params do default_params.merge({ :suphp_engine => 'on', diff --git a/templates/vhost.conf.erb b/templates/vhost.conf.erb index 0eb69b009..673ea0c2b 100644 --- a/templates/vhost.conf.erb +++ b/templates/vhost.conf.erb @@ -44,6 +44,7 @@ <% elsif @access_log -%> CustomLog "<%= @access_log_destination %>" <%= @_access_log_format %> <% end -%> +<%= scope.function_template(['apache/vhost/_action.erb']) -%> <%= scope.function_template(['apache/vhost/_block.erb']) -%> <%= scope.function_template(['apache/vhost/_error_document.erb']) -%> <%= scope.function_template(['apache/vhost/_proxy.erb']) -%> diff --git a/templates/vhost/_action.erb b/templates/vhost/_action.erb new file mode 100644 index 000000000..8a0229059 --- /dev/null +++ b/templates/vhost/_action.erb @@ -0,0 +1,4 @@ +<% if @action -%> + + Action <%= @action %> /cgi-bin virtual +<% end -%> diff --git a/templates/vhost/_scriptalias.erb b/templates/vhost/_scriptalias.erb index 5a757f617..bb4f6b316 100644 --- a/templates/vhost/_scriptalias.erb +++ b/templates/vhost/_scriptalias.erb @@ -10,7 +10,7 @@ ## Script alias directives <%# Combine scriptalais and scriptaliases into a single data structure -%> <%# for backward compatibility and ease of implementation -%> -<%- aliases << { 'alias' => '/cgi-bin/', 'path' => @scriptalias } if @scriptalias -%> +<%- aliases << { 'alias' => '/cgi-bin', 'path' => @scriptalias } if @scriptalias -%> <%- aliases.flatten.compact! -%> <%- aliases.each do |salias| -%> <%- if salias["path"] != '' -%>