Skip to content

Commit

Permalink
Merge pull request #1453 from jonnytpuppet/mod_cluster
Browse files Browse the repository at this point in the history
Add support for mod_cluster, an httpd-based load balancer.
  • Loading branch information
jonnytdevops committed May 9, 2016
2 parents 16104a4 + 3f4e1cf commit 0a08026
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
[`apache::mod::auth_cas`]: #class-apachemodauth_cas
[`apache::mod::auth_mellon`]: #class-apachemodauth_mellon
[`apache::mod::authnz_ldap`]: #class-apachemodauthnz_ldap
[`apache::mod::cluster`]: #class-apachemodcluster
[`apache::mod::disk_cache`]: #class-apachemoddisk_cache
[`apache::mod::event`]: #class-apachemodevent
[`apache::mod::ext_filter`]: #class-apachemodext_filter
Expand Down Expand Up @@ -1273,6 +1274,7 @@ The following Apache modules have supported classes, many of which allow for par
* `cache`
* `cgi`
* `cgid`
* `cluster` (see [`apache::mod::cluster`][])
* `dav`
* `dav_fs`
* `dav_svn`\*
Expand Down Expand Up @@ -1428,6 +1430,31 @@ Installs `mod_authnz_ldap` and uses the `authnz_ldap.conf.erb` template to gener
- `package_name`: Default: `undef`.
- `verify_server_cert`: Default: `undef`.

##### Class: `apache::mod::cluster`

**Note**: There is no official package available for mod\_cluster and thus it must be made available by means outside of the control of the apache module. Binaries can be found at http://mod-cluster.jboss.org/

``` puppet
class { '::apache::mod::cluster':
ip => '172.17.0.1',
allowed_network => '172.17.0.',
balancer_name => 'mycluster',
version => '1.3.1'
}
```

**Parameters within `apache::mod::cluster`**:

- `port`: mod_cluster listen port. Default: '6666'.
- `server_advertise`: Whether the server should advertise. Default: true.
- `manager_allowed_network`: Network allowed to access the mod_cluster_manager. Default: '127.0.0.1'.
- `keep_alive_timeout`: Keep-alive timeout. Default: 60.
- `max_keep_alive_requests`: Max number of requests kept alive. Default: 0
- `enable_mcpm_receive`: Whether MCPM should be enabled: Default: true.
- `ip`: Listen ip address..
- `allowed_network`: Balanced members network.
- `version`: mod_cluster version. >= 1.3.0 is required for httpd 2.4.

##### Class: `apache::mod::deflate`

Installs and configures [`mod_deflate`][].
Expand Down
38 changes: 38 additions & 0 deletions manifests/mod/cluster.pp
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'],
}

}
105 changes: 105 additions & 0 deletions spec/classes/mod/cluster_spec.rb
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
23 changes: 23 additions & 0 deletions templates/mod/cluster.conf.erb
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>

0 comments on commit 0a08026

Please sign in to comment.