Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SetHandler directive #604

Merged
merged 2 commits into from
Apr 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,21 @@ Sets the order of processing Allow and Deny statements as per [Apache core docum
}
```

######`sethandler`

Sets a `SetHandler` directive as per the [Apache Core documentation](http://httpd.apache.org/docs/2.2/mod/core.html#sethandler). An example:

```puppet
apache::vhost { 'sample.example.net':
docroot => '/path/to/directory',
directories => [
{ path => '/path/to/directory',
sethandler => 'None',
}
],
}
```

######`passenger_enabled`

Sets the value for the [PassengerEnabled](http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerEnabled) directory to 'on' or 'off'. Requires `apache::mod::passenger` to be included.
Expand Down
32 changes: 32 additions & 0 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,38 @@ class { 'apache': }
shell("/usr/bin/curl -sSf files.example.net:80/private.html", {:acceptable_exit_codes => 22}).stderr.should match(/curl: \(22\) The requested URL returned error: 403/)
end
end

describe 'SetHandler directive' do
it 'should configure a vhost with a SetHandler directive' do
pp = <<-EOS
class { 'apache': }
apache::mod { 'status': }
host { 'files.example.net': ip => '127.0.0.1', }
apache::vhost { 'files.example.net':
docroot => '/var/www/files',
directories => [
{ path => '/var/www/files', },
{ path => '/server-status', provider => 'location', sethandler => 'server-status', },
],
}
file { '/var/www/files/index.html':
ensure => file,
content => "Hello World\\n",
}
EOS
apply_manifest(pp, :catch_failures => true)
end

describe service($service_name) do
it { should be_enabled }
it { should be_running }
end

it 'should answer to files.example.net' do
shell("/usr/bin/curl -sSf files.example.net:80/index.html").stdout.should eq("Hello World\n")
shell("/usr/bin/curl -sSf files.example.net:80/server-status?auto").stdout.should match(/Scoreboard: /)
end
end
end

case fact('lsbdistcodename')
Expand Down
2 changes: 2 additions & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@
'options' => '-MultiViews',
'order' => 'deny,yned',
'passenger_enabled' => 'onf',
'sethandler' => 'None',
},
:match => [
/^ <Directory "\/opt\/app">$/,
Expand All @@ -695,6 +696,7 @@
/^ Deny from google.com$/,
/^ Options -MultiViews$/,
/^ Order deny,yned$/,
/^ SetHandler None$/,
/^ PassengerEnabled onf$/,
/^ <\/Directory>$/,
],
Expand Down
3 changes: 3 additions & 0 deletions templates/vhost/_directories.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
AddHandler <%= addhandler['handler'] %> <%= Array(addhandler['extensions']).join(' ') %>
<%- end -%>
<%- end -%>
<%- if directory['sethandler'] and directory['sethandler'] != '' -%>
SetHandler <%= directory['sethandler'] %>
<%- end -%>
<%- if directory['passenger_enabled'] and directory['passenger_enabled'] != '' -%>
PassengerEnabled <%= directory['passenger_enabled'] %>
<%- end -%>
Expand Down