-
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 #1453 from jonnytpuppet/mod_cluster
Add support for mod_cluster, an httpd-based load balancer.
- Loading branch information
Showing
4 changed files
with
193 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class apache::mod::cluster ( | ||
$allowed_network, | ||
$balancer_name, | ||
$ip, | ||
$version, | ||
$enable_mcpm_receive = true, | ||
$port = '6666', | ||
$keep_alive_timeout = 60, | ||
$manager_allowed_network = '127.0.0.1', | ||
$max_keep_alive_requests = 0, | ||
$server_advertise = true, | ||
) { | ||
|
||
include ::apache | ||
|
||
::apache::mod { 'proxy': } | ||
::apache::mod { 'proxy_ajp': } | ||
::apache::mod { 'manager': } | ||
::apache::mod { 'proxy_cluster': } | ||
::apache::mod { 'advertise': } | ||
|
||
if (versioncmp($version, '1.3.0') >= 0 ) { | ||
::apache::mod { 'cluster_slotmem': } | ||
} else { | ||
::apache::mod { 'slotmem': } | ||
} | ||
|
||
file {'cluster.conf': | ||
ensure => file, | ||
path => "${::apache::mod_dir}/cluster.conf", | ||
mode => $::apache::file_mode, | ||
content => template('apache/mod/cluster.conf.erb'), | ||
require => Exec["mkdir ${::apache::mod_dir}"], | ||
before => File[$::apache::mod_dir], | ||
notify => Class['apache::service'], | ||
} | ||
|
||
} |
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,105 @@ | ||
require 'spec_helper' | ||
|
||
describe 'apache::mod::cluster', :type => :class do | ||
context 'on a RedHat OS Release 7 with mod version = 1.3.0' do | ||
let :facts do | ||
{ | ||
:osfamily => 'RedHat', | ||
:operatingsystemrelease => '7', | ||
: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 | ||
|
||
let(:params) { | ||
{ | ||
:allowed_network => '172.17.0', | ||
:balancer_name => 'mycluster', | ||
:ip => '172.17.0.1', | ||
:version => '1.3.0' | ||
} | ||
} | ||
|
||
it { is_expected.to contain_class("apache") } | ||
it { is_expected.to contain_apache__mod('proxy') } | ||
it { is_expected.to contain_apache__mod('proxy_ajp') } | ||
it { is_expected.to contain_apache__mod('manager') } | ||
it { is_expected.to contain_apache__mod('proxy_cluster') } | ||
it { is_expected.to contain_apache__mod('advertise') } | ||
it { is_expected.to contain_apache__mod('cluster_slotmem') } | ||
|
||
it { is_expected.to contain_file('cluster.conf') } | ||
end | ||
|
||
context 'on a RedHat OS Release 7 with mod version > 1.3.0' do | ||
let :facts do | ||
{ | ||
:osfamily => 'RedHat', | ||
:operatingsystemrelease => '7', | ||
: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 | ||
|
||
let(:params) { | ||
{ | ||
:allowed_network => '172.17.0', | ||
:balancer_name => 'mycluster', | ||
:ip => '172.17.0.1', | ||
:version => '1.3.1' | ||
} | ||
} | ||
|
||
it { is_expected.to contain_class('apache') } | ||
it { is_expected.to contain_apache__mod('proxy') } | ||
it { is_expected.to contain_apache__mod('proxy_ajp') } | ||
it { is_expected.to contain_apache__mod('manager') } | ||
it { is_expected.to contain_apache__mod('proxy_cluster') } | ||
it { is_expected.to contain_apache__mod('advertise') } | ||
it { is_expected.to contain_apache__mod('cluster_slotmem') } | ||
|
||
it { is_expected.to contain_file('cluster.conf') } | ||
end | ||
|
||
context 'on a RedHat OS Release 6 with mod version < 1.3.0' 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 | ||
|
||
let(:params) { | ||
{ | ||
:allowed_network => '172.17.0', | ||
:balancer_name => 'mycluster', | ||
:ip => '172.17.0.1', | ||
:version => '1.2.0' | ||
} | ||
} | ||
|
||
it { is_expected.to contain_class('apache') } | ||
it { is_expected.to contain_apache__mod('proxy') } | ||
it { is_expected.to contain_apache__mod('proxy_ajp') } | ||
it { is_expected.to contain_apache__mod('manager') } | ||
it { is_expected.to contain_apache__mod('proxy_cluster') } | ||
it { is_expected.to contain_apache__mod('advertise') } | ||
it { is_expected.to contain_apache__mod('slotmem') } | ||
|
||
it { is_expected.to contain_file('cluster.conf') } | ||
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,23 @@ | ||
Listen <%= @ip %>:<%= @port %> | ||
<VirtualHost <%= @ip %>:<%= @port %>> | ||
<Location /> | ||
Order deny,allow | ||
Deny from all | ||
Allow from <%= @allowed_network %> | ||
</Location> | ||
|
||
KeepAliveTimeout <%= @keep_alive_timeout %> | ||
MaxKeepAliveRequests <%= @max_keep_alive_requests %> | ||
EnableMCPMReceive <%= scope.function_bool2httpd([@enable_mcpm_receive]) %> | ||
|
||
ManagerBalancerName <%= @balancer_name %> | ||
ServerAdvertise <%= scope.function_bool2httpd([@server_advertise]) %> | ||
|
||
<Location /mod_cluster_manager> | ||
SetHandler mod_cluster-manager | ||
Order deny,allow | ||
Deny from all | ||
Allow from <%= @manager_allowed_network %> | ||
</Location> | ||
|
||
</VirtualHost> |