-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1562 from sathieu/balancer-manager
mod_proxy_balancer manager
- Loading branch information
Showing
4 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
require 'spec_helper' | ||
|
||
# Helper function for testing the contents of `proxy_balancer.conf` | ||
def balancer_manager_conf_spec(allow_from, manager_path) | ||
it do | ||
is_expected.to contain_file("proxy_balancer.conf").with_content( | ||
"<Location #{manager_path}>\n"\ | ||
" SetHandler balancer-manager\n"\ | ||
" Require ip #{Array(allow_from).join(' ')}\n"\ | ||
"</Location>\n" | ||
) | ||
end | ||
end | ||
|
||
describe 'apache::mod::proxy_balancer', :type => :class do | ||
let :pre_condition do | ||
[ | ||
'include apache::mod::proxy', | ||
] | ||
end | ||
it_behaves_like "a mod class, without including apache" | ||
|
||
context "default configuration with default parameters" do | ||
context "on a Debian OS" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:operatingsystemrelease => '8', | ||
:concat_basedir => '/dne', | ||
:lsbdistcodename => 'jessie', | ||
:operatingsystem => 'Debian', | ||
:id => 'root', | ||
:kernel => 'Linux', | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
:is_pe => false, | ||
} | ||
end | ||
|
||
it { is_expected.to contain_apache__mod("proxy_balancer") } | ||
|
||
it { is_expected.to_not contain_file("proxy_balancer.conf") } | ||
it { is_expected.to_not contain_file("proxy_balancer.conf symlink") } | ||
|
||
end | ||
|
||
context "on a RedHat OS" do | ||
let :facts do | ||
{ | ||
:osfamily => 'RedHat', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
:operatingsystem => 'RedHat', | ||
:id => 'root', | ||
:kernel => 'Linux', | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
:is_pe => false, | ||
} | ||
end | ||
|
||
it { is_expected.to contain_apache__mod("proxy_balancer") } | ||
|
||
it { is_expected.to_not contain_file("proxy_balancer.conf") } | ||
it { is_expected.to_not contain_file("proxy_balancer.conf symlink") } | ||
|
||
end | ||
end | ||
|
||
context "default configuration with custom parameters $manager => true, $allow_from => ['10.10.10.10','11.11.11.11'], $status_path => '/custom-manager'" do | ||
context "on a Debian OS" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:operatingsystemrelease => '8', | ||
:concat_basedir => '/dne', | ||
:lsbdistcodename => 'jessie', | ||
:operatingsystem => 'Debian', | ||
:id => 'root', | ||
:kernel => 'Linux', | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
:is_pe => false, | ||
} | ||
end | ||
let :params do | ||
{ | ||
:manager => true, | ||
:allow_from => ['10.10.10.10','11.11.11.11'], | ||
:manager_path => '/custom-manager', | ||
} | ||
end | ||
|
||
balancer_manager_conf_spec(["10.10.10.10", "11.11.11.11"], "/custom-manager") | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Location <%= @manager_path %>> | ||
SetHandler balancer-manager | ||
<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> | ||
Require ip <%= Array(@allow_from).join(" ") %> | ||
<%- else -%> | ||
Order deny,allow | ||
Deny from all | ||
Allow from <%= Array(@allow_from).join(" ") %> | ||
<%- end -%> | ||
</Location> |