Skip to content

Commit

Permalink
Allows for the configuration of mod_actions, specifically the action …
Browse files Browse the repository at this point in the history
…type triggered by the request.
  • Loading branch information
typhonius authored and Adam Malone committed Mar 2, 2014
1 parent b499aa2 commit 736382c
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions manifests/default_mods.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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': }
Expand Down Expand Up @@ -55,6 +55,7 @@
}
}
'freebsd': {
include ::apache::mod::actions
include ::apache::mod::cache
include ::apache::mod::disk_cache
include ::apache::mod::headers
Expand All @@ -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': }
Expand Down
3 changes: 3 additions & 0 deletions manifests/mod/actions.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class apache::mod::actions {
apache::mod { 'actions': }
}
1 change: 1 addition & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
$wsgi_script_aliases = undef,
$custom_fragment = undef,
$itk = undef,
$action = undef,
$fastcgi_server = undef,
$fastcgi_socket = undef,
$fastcgi_dir = undef,
Expand Down
19 changes: 19 additions & 0 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
:attr => 'scriptalias',
:value => '/usr/scripts',
:match => [
/^ ScriptAlias \/cgi-bin\/ "\/usr\/scripts"$/,
/^ ScriptAlias \/cgi-bin "\/usr\/scripts"$/,
],
},
{
Expand Down Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions templates/vhost.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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']) -%>
Expand Down
4 changes: 4 additions & 0 deletions templates/vhost/_action.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<% if @action -%>

Action <%= @action %> /cgi-bin virtual
<% end -%>
2 changes: 1 addition & 1 deletion templates/vhost/_scriptalias.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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"] != '' -%>
Expand Down

0 comments on commit 736382c

Please sign in to comment.