Skip to content

Commit a51bfa8

Browse files
author
enekogb
committed
Add $status_path parameter to change mod_status url
1 parent a88bbc7 commit a51bfa8

4 files changed

Lines changed: 30 additions & 10 deletions

File tree

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* [Class: apache::mod::pagespeed](#class-apachemodpagespeed)
2121
* [Class: apache::mod::php](#class-apachemodphp)
2222
* [Class: apache::mod::ssl](#class-apachemodssl)
23+
* [Class: apache::mod::status](#class-apachemodstatus)
2324
* [Class: apache::mod::wsgi](#class-apachemodwsgi)
2425
* [Class: apache::mod::fcgid](#class-apachemodfcgid)
2526
* [Class: apache::mod::negotiation](#class-apachemodnegotiation)
@@ -556,7 +557,7 @@ There are many `apache::mod::[name]` classes within this module that can be decl
556557
* `shib`* (see [`apache::mod::shib`](#class-apachemodshib) below)
557558
* `speling`
558559
* `ssl`* (see [`apache::mod::ssl`](#class-apachemodssl) below)
559-
* `status`*
560+
* `status`* (see [`apache::mod::status`](#class-apachemodstatus) below)
560561
* `suphp`
561562
* `userdir`*
562563
* `vhost_alias`
@@ -721,6 +722,21 @@ Installs Apache SSL capabilities and uses the ssl.conf.erb template. These are t
721722

722723
To *use* SSL with a virtual host, you must either set the`default_ssl_vhost` parameter in `::apache` to 'true' or set the `ssl` parameter in `apache::vhost` to 'true'.
723724

725+
####Class: `apache::mod::status`
726+
727+
Installs Apache mod_status and uses the status.conf.erb template. These are the defaults:
728+
729+
```puppet
730+
class { 'apache::mod::status':
731+
allow_from = ['127.0.0.1','::1'],
732+
extended_status = 'On',
733+
status_path = '/server-status',
734+
){
735+
736+
737+
}
738+
```
739+
724740
####Class: `apache::mod::wsgi`
725741

726742
Enables Python support in the WSGI module. To use, simply `include 'apache::mod::wsgi'`.

manifests/mod/status.pp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
# /server-status URL. Defaults to ['127.0.0.1', '::1'].
1010
# - $extended_status track and display extended status information. Valid
1111
# values are 'On' or 'Off'. Defaults to 'On'.
12-
#
12+
# - $status_path is the path assigned to the Location directive which
13+
# defines the URL to access the server status. Defaults to '/server-status'.
14+
#
1315
# Actions:
1416
# - Enable and configure Apache mod_status
1517
#
@@ -27,11 +29,12 @@
2729
$allow_from = ['127.0.0.1','::1'],
2830
$extended_status = 'On',
2931
$apache_version = $::apache::apache_version,
32+
$status_path = '/server-status',
3033
){
3134
validate_array($allow_from)
3235
validate_re(downcase($extended_status), '^(on|off)$', "${extended_status} is not supported for extended_status. Allowed values are 'On' and 'Off'.")
3336
::apache::mod { 'status': }
34-
# Template uses $allow_from, $extended_status, $apache_version
37+
# Template uses $allow_from, $extended_status, $apache_version, $status_path
3538
file { 'status.conf':
3639
ensure => file,
3740
path => "${::apache::mod_dir}/status.conf",

spec/classes/mod/status_spec.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require 'spec_helper'
22

33
# Helper function for testing the contents of `status.conf`
4-
def status_conf_spec(allow_from, extended_status)
4+
def status_conf_spec(allow_from, extended_status, status_path)
55
it do
66
is_expected.to contain_file("status.conf").with_content(
7-
"<Location /server-status>\n"\
7+
"<Location #{status_path}>\n"\
88
" SetHandler server-status\n"\
99
" Order deny,allow\n"\
1010
" Deny from all\n"\
@@ -41,7 +41,7 @@ def status_conf_spec(allow_from, extended_status)
4141

4242
it { is_expected.to contain_apache__mod("status") }
4343

44-
status_conf_spec(["127.0.0.1", "::1"], "On")
44+
status_conf_spec(["127.0.0.1", "::1"], "On", "/server-status")
4545

4646
it { is_expected.to contain_file("status.conf").with({
4747
:ensure => 'file',
@@ -70,13 +70,13 @@ def status_conf_spec(allow_from, extended_status)
7070

7171
it { is_expected.to contain_apache__mod("status") }
7272

73-
status_conf_spec(["127.0.0.1", "::1"], "On")
73+
status_conf_spec(["127.0.0.1", "::1"], "On", "/server-status")
7474

7575
it { is_expected.to contain_file("status.conf").with_path("/etc/httpd/conf.d/status.conf") }
7676

7777
end
7878

79-
context "with custom parameters $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off'" do
79+
context "with custom parameters $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off', $status_path => '/custom-status'" do
8080
let :facts do
8181
{
8282
:osfamily => 'Debian',
@@ -93,10 +93,11 @@ def status_conf_spec(allow_from, extended_status)
9393
{
9494
:allow_from => ['10.10.10.10','11.11.11.11'],
9595
:extended_status => 'Off',
96+
:status_path => '/custom-status',
9697
}
9798
end
9899

99-
status_conf_spec(["10.10.10.10", "11.11.11.11"], "Off")
100+
status_conf_spec(["10.10.10.10", "11.11.11.11"], "Off", "/custom-status")
100101

101102
end
102103

templates/mod/status.conf.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Location /server-status>
1+
<Location <%= @status_path %>>
22
SetHandler server-status
33
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%>
44
Require ip <%= Array(@allow_from).join(" ") %>

0 commit comments

Comments
 (0)