39 changes: 22 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
language: ruby
rvm:
- 1.8.7
- 1.9.3
script: "rake spec"
branches:
only:
- master
- master
language: ruby
bundler_args: --without development
script: bundle exec rake spec SPEC_OPTS='--format documentation'
after_success:
- git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release
- .forge-release/publish
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
env:
- PUPPET_VERSION=2.6.17
- PUPPET_VERSION=2.7.19
#- PUPPET_VERSION=3.0.1 # Breaks due to rodjek/rspec-puppet#58
notifications:
email: false
gemfile: .gemfile
matrix:
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.3.0"
global:
- PUBLISHER_LOGIN=puppetlabs
- secure: RPcn+PnoxnRCaV2dLgPlnqPZQQqpMGBqjIIBDMEqKl8cispgE8hwnh1sd3iG1zfnF6fY9gcz04MVdk+d2Uv33RYuUZcrYEbkIoSVZn7NBrCBfhxucXu2Th44iyEYjlPSi4NLRoj5AKCAyz0FQxBOJQTxxtpWI6eBQvS47IdEopc=
matrix:
exclude:
- rvm: 1.9.3
gemfile: .gemfile
env: PUPPET_VERSION=2.6.17
- rvm: 1.8.7
gemfile: .gemfile
env: PUPPET_VERSION=3.0.1
env: PUPPET_GEM_VERSION="~> 2.7.0"
- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 2.7.0"
notifications:
email: false
20 changes: 19 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
2013-10-03 - Version 0.4.0

Summary:

The largest feature in this release is the new haproxy::frontend
and haproxy::backend defines. The other changes are mostly to
increase flexibility.

Features:
- Added parameters to haproxy:
- `package_name`: Allows alternate package name.
- Add haproxy::frontend and haproxy::backend defines.
- Add an ensure parameter to balancermember so they can be removed.
- Made chroot optional

Fixes:
- Remove deprecation warnings from templates.

2013-05-25 - Version 0.3.0
Features:
- Add travis testing
- Add `haproxy::basancermember` `define_cookies` parameter
- Add `haproxy::balancermember` `define_cookies` parameter
- Add array support to `haproxy::listen` `ipaddress` parameter

Bugfixes:
Expand Down
22 changes: 22 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
source 'https://rubygems.org'

group :development, :test do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-system', :require => false
gem 'rspec-system-puppet', :require => false
gem 'rspec-system-serverspec', :require => false
gem 'serverspec', :require => false
gem 'puppet-lint', :require => false
gem 'pry', :require => false
gem 'simplecov', :require => false
end

if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end

# vim:ft=ruby
4 changes: 1 addition & 3 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name 'puppetlabs-haproxy'
version '0.3.0'
version '0.4.0'
source 'git://github.com/puppetlabs/puppetlabs-haproxy'
author 'Puppet Labs'
license 'Apache License, Version 2.0'
summary 'Haproxy Module'
description 'An Haproxy module for Redhat family OSes using Storeconfigs'
project_page 'http://github.com/puppetlabs/puppetlabs-haproxy'

## Add dependencies, if any:
# dependency 'username/name', '>= 1.2.0'
dependency 'ripienaar/concat', '>= 0.1.0'
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ Configuring haproxy daemon listener

One `haproxy::listen` defined resource should be defined for each HAProxy loadbalanced set of backend servers. The title of the `haproxy::listen` resource is the key to which balancer members will be proxied to. The `ipaddress` field should be the public ip address which the loadbalancer will be contacted on. The `ports` attribute can accept an array or comma-separated list of ports which should be proxied to the `haproxy::balancermember` nodes.

Configuring haproxy daemon frontend
-----------------------------------

One `haproxy::frontend` defined resource should be defined for each HAProxy front end you wish to set up. The `ipaddress` field should be the public ip address which the loadbalancer will be contacted on. The `ports` attribute can accept an array or comma-separated list of ports which should be proxied to the `haproxy::backend` resources.

Configuring haproxy daemon backend
----------------------------------

One `haproxy::backend` defined resource should be defined for each HAProxy loadbalanced set of backend servers. The title of the `haproxy::backend` resource is the key to which balancer members will be proxied to. Note that an `haproxy::listen` resource and `haproxy::backend` resource *can* have the same name, and any balancermembers exported to that name will show up in both places. This is likely to have unsatisfactory results, but there's nothing preventing this from happening.

Configuring haproxy loadbalanced member nodes
---------------------------------------------

Expand Down
76 changes: 76 additions & 0 deletions manifests/backend.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# == Define Resource Type: haproxy::backend
#
# This type will setup a backend service configuration block inside the
# haproxy.cfg file on an haproxy load balancer. Each backend service needs one
# or more backend member servers (that can be declared with the
# haproxy::balancermember defined resource type). Using storeconfigs, you can
# export the haproxy::balancermember resources on all load balancer member
# servers and then collect them on a single haproxy load balancer server.
#
# === Requirement/Dependencies:
#
# Currently requires the ripienaar/concat module on the Puppet Forge and
# uses storeconfigs on the Puppet Master to export/collect resources
# from all backend members.
#
# === Parameters
#
# [*name*]
# The namevar of the defined resource type is the backend service's name.
# This name goes right after the 'backend' statement in haproxy.cfg
#
# [*options*]
# A hash of options that are inserted into the backend configuration block.
#
# [*collect_exported*]
# Boolean, default 'true'. True means 'collect exported @@balancermember
# resources' (for the case when every balancermember node exports itself),
# false means 'rely on the existing declared balancermember resources' (for
# the case when you know the full set of balancermember in advance and use
# haproxy::balancermember with array arguments, which allows you to deploy
# everything in 1 run)
#
#
# === Examples
#
# Exporting the resource for a backend member:
#
# haproxy::backend { 'puppet00':
# options => {
# 'option' => [
# 'tcplog',
# 'ssl-hello-chk'
# ],
# 'balance' => 'roundrobin'
# },
# }
#
# === Authors
#
# Gary Larizza <gary@puppetlabs.com>
# Jeremy Kitchen <jeremy@nationbuilder.com>
#
define haproxy::backend (
$collect_exported = true,
$options = {
'option' => [
'tcplog',
'ssl-hello-chk'
],
'balance' => 'roundrobin'
}
) {

# Template uses: $name, $ipaddress, $ports, $options
concat::fragment { "${name}_backend_block":
order => "20-${name}-00",
target => '/etc/haproxy/haproxy.cfg',
content => template('haproxy/haproxy_backend_block.erb'),
}

if $collect_exported {
Haproxy::Balancermember <<| listening_service == $name |>>
}
# else: the resources have been created and they introduced their
# concat fragments. We don't have to do anything about them.
}
6 changes: 6 additions & 0 deletions manifests/balancermember.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
# The ip address used to contact the balancer member server.
# Can be an array, see documentation to server_names.
#
# [*ensure*]
# If the balancermember should be present or absent.
# Defaults to present.
#
# [*options*]
# An array of options to be specified after the server declaration
# in the listening service's configuration block.
Expand Down Expand Up @@ -87,12 +91,14 @@
$ports,
$server_names = $::hostname,
$ipaddresses = $::ipaddress,
$ensure = 'present',
$options = '',
$define_cookies = false
) {
# Template uses $ipaddresses, $server_name, $ports, $option
concat::fragment { "${listening_service}_balancermember_${name}":
order => "20-${listening_service}-${name}",
ensure => $ensure,
target => '/etc/haproxy/haproxy.cfg',
content => template('haproxy/haproxy_balancermember.erb'),
}
Expand Down
76 changes: 76 additions & 0 deletions manifests/frontend.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# == Define Resource Type: haproxy::frontend
#
# This type will setup a frontend service configuration block inside
# the haproxy.cfg file on an haproxy load balancer.
#
# === Requirement/Dependencies:
#
# Currently requires the ripienaar/concat module on the Puppet Forge and
# uses storeconfigs on the Puppet Master to export/collect resources
# from all balancer members.
#
# === Parameters
#
# [*name*]
# The namevar of the defined resource type is the frontend service's name.
# This name goes right after the 'frontend' statement in haproxy.cfg
#
# [*ports*]
# Ports on which the proxy will listen for connections on the ip address
# specified in the ipaddress parameter. Accepts either a single
# comma-separated string or an array of strings which may be ports or
# hyphenated port ranges.
#
# [*ipaddress*]
# The ip address the proxy binds to. Empty addresses, '*', and '0.0.0.0'
# mean that the proxy listens to all valid addresses on the system.
#
# [*mode*]
# The mode of operation for the frontend service. Valid values are undef,
# 'tcp', 'http', and 'health'.
#
# [*options*]
# A hash of options that are inserted into the frontend service
# configuration block.
#
# === Examples
#
# Exporting the resource for a balancer member:
#
# haproxy::frontend { 'puppet00':
# ipaddress => $::ipaddress,
# ports => '18140',
# mode => 'tcp',
# options => {
# 'option' => [
# 'tcplog',
# 'accept-invalid-http-request',
# ],
# 'timeout client' => '30',
# 'balance' => 'roundrobin'
# },
# }
#
# === Authors
#
# Gary Larizza <gary@puppetlabs.com>
#
define haproxy::frontend (
$ports,
$ipaddress = [$::ipaddress],
$mode = undef,
$collect_exported = true,
$options = {
'option' => [
'tcplog',
],
}
) {
# Template uses: $name, $ipaddress, $ports, $options
concat::fragment { "${name}_frontend_block":
order => "15-${name}-00",
target => '/etc/haproxy/haproxy.cfg',
content => template('haproxy/haproxy_frontend_block.erb'),
}

}
31 changes: 22 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
# options as an array and you will get a line for each of them in the
# resultant haproxy.cfg file.
#
# [*package_name*]
# The package name to install containing haproxy. Defaults to <code>'haproxy'</code>
#
# === Examples
#
Expand Down Expand Up @@ -63,16 +65,17 @@
$manage_service = true,
$enable = true,
$global_options = $haproxy::params::global_options,
$defaults_options = $haproxy::params::defaults_options
$defaults_options = $haproxy::params::defaults_options,
$package_name = 'haproxy'
) inherits haproxy::params {
include concat::setup

package { 'haproxy':
package { $package_name:
ensure => $enable ? {
true => present,
false => absent,
},
name => 'haproxy',
alias => 'haproxy',
}

if $enable {
Expand Down Expand Up @@ -112,13 +115,26 @@
}
}

file { $global_options['chroot']:
ensure => directory,
if $global_options['chroot'] {
file { $global_options['chroot']:
ensure => directory,
}
}

}

if $manage_service {
if $global_options['chroot'] {
$deps = [
Concat['/etc/haproxy/haproxy.cfg'],
File[$global_options['chroot']],
]
} else {
$deps = [
Concat['/etc/haproxy/haproxy.cfg'],
]
}

service { 'haproxy':
ensure => $enable ? {
true => running,
Expand All @@ -131,10 +147,7 @@
name => 'haproxy',
hasrestart => true,
hasstatus => true,
require => [
Concat['/etc/haproxy/haproxy.cfg'],
File[$global_options['chroot']],
],
require => $deps,
}
}
}
Loading