Skip to content

Instantly share code, notes, and snippets.

@mrintegrity
Created September 14, 2012 08:32
Show Gist options
  • Save mrintegrity/3720778 to your computer and use it in GitHub Desktop.
Save mrintegrity/3720778 to your computer and use it in GitHub Desktop.
# Class: pound
#
# This module manages pound
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
# [Remember: No empty lines between comments and class definition]
class pound ($content = template('pound/pound.cfg.erb'),
$owner = 'root',
$group = 'root',
$mode = '755',
$require = Package['pound'],
$notify = Service['pound']) {
package {
'pound' :
ensure => installed,
}
service {
'pound' :
ensure => running,
enable => true,
}
}
# Definition: pound::listener
#
# This class installs Pound listeners
#
# Parameters:
# - The $listen_ip to configure the ip that the listener will listen on
# - The $listen_port to configure the port that the listener will listen on
# - The $listen_protocol to configure the protocol that the listener accepts (currently http or https)
# - The $ssl_cert_path to set the location of the SSL certificate if the listen_protocol is https
# - The $head_require to set the required header to allow connections through to the backend
# - The $backend_ip to set the address of the backend server that will receive traffic
# - The $backend_port to set the port of the backend server that will receive traffic
#
# Actions:
# - Install Pound listeners
#
# Requires:
# - The pound class
#
# Sample Usage:
# pound::listener { :
# listen_ip => '10.10.10.10',
# listen_port => '80',
# listen_protocol => 'ListenHTTP',
# head_require => 'Host: .*www.example.com*',
# backend_ip => '10.0.100.10',
# backend_port => '80',
# }
#
define pound::listener (
$template = 'pound/pound.cfg.erb',
$listen_ip,
$listen_port,
$listen_protocol = 'ListenHTTP',
$head_require,
$backend_ip,
$backend_port
) {
include pound
file {
"/etc/pound/pound.cfg" :
content => template('pound/pound.cfg.erb'),
owner => 'root',
group => 'root',
mode => '755',
require => Package['pound'],
notify => Service['pound'],
}
}
## Minimal sample pound.cfg
##
## see pound(8) for details
######################################################################
## global options:
User "www-data"
Group "www-data"
#RootJail "/chroot/pound"
## Logging: (goes to syslog by default)
## 0 no logging
## 1 normal
## 2 extended
## 3 Apache-style (common log format)
LogLevel 3
## check backend every X secs:
Alive 30
## use hardware-accelleration card supported by openssl(1):
#SSLEngine "<hw>"
# poundctl control socket
Control "/var/run/pound/poundctl.socket"
<%= scope.lookupvar("::$listen_protocol") %>
Address <%= scope.lookupvar("pound::$listen_ip") %>
Port <%= scope.lookupvar("pound::params::$listen_port") %>
<% if scope.lookupvar("pound::params::$listen_protocol") == "ListenHTTPS" -%>
Cert "<%= scope.lookupvar("pound::params::$ssl_cert_path") -%>"
<% end -%>
## allow PUT and DELETE also (by default only GET, POST and HEAD)?:
xHTTP 0
Service
HeadRequire "<%= scope.lookupvar("pound::params::$head_require") %>"
BackEnd
Address <%= scope.lookupvar("pound::params::$backend_ip") %>
Port <%= scope.lookupvar("pound::params::$backend_port") %>
End
End
END
# poundtest.pp
node 'poundtest' {
include pound
pound::listener {
testlistener :
listen_ip => '10.10.10.10',
listen_port => '80',
listen_protocol => 'ListenHTTP',
head_require => 'Host: .*www.example.com*',
backend_ip => '10.0.100.10',
backend_port => '80',
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment