From 3ab65f56a61cfedbe75a3b41143f0d44fbad0a93 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 12 Oct 2012 11:28:24 -0700 Subject: Rename everything! What is renamed: - Class/define: - haproxy::config to haproxy::listen - haproxy::data to haproxy::params - Parameters: - haproxy::listen listen_ip to ipaddress - haproxy::listen config_options to options - haproxy haproxy_global_options to global_options - haproxy haproxy_defaults_options to defaults_options --- manifests/balancermember.pp | 4 +- manifests/config.pp | 100 ------------------------------------------- manifests/data.pp | 65 ---------------------------- manifests/init.pp | 32 ++++++-------- manifests/listen.pp | 101 ++++++++++++++++++++++++++++++++++++++++++++ manifests/params.pp | 65 ++++++++++++++++++++++++++++ 6 files changed, 182 insertions(+), 185 deletions(-) delete mode 100644 manifests/config.pp delete mode 100644 manifests/data.pp create mode 100644 manifests/listen.pp create mode 100644 manifests/params.pp (limited to 'manifests') diff --git a/manifests/balancermember.pp b/manifests/balancermember.pp index af5728e..d43d98a 100644 --- a/manifests/balancermember.pp +++ b/manifests/balancermember.pp @@ -22,8 +22,8 @@ # # [*listening_service*] # The haproxy service's instance name (or, the title of the -# haproxy::config resource). This must match up with a declared -# haproxy::config resource. +# haproxy::listen resource). This must match up with a declared +# haproxy::listen resource. # # [*balancer_port*] # A unique port for which the balancer member will accept connections diff --git a/manifests/config.pp b/manifests/config.pp deleted file mode 100644 index b9caf15..0000000 --- a/manifests/config.pp +++ /dev/null @@ -1,100 +0,0 @@ -# == Define Resource Type: haproxy::config -# -# This type will setup a listening service configuration block inside -# the haproxy.cfg file on an haproxy load balancer. Each listening service -# configuration needs one or more load balancer member server (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 balancer members. -# -# === Parameters -# -# [*name*] -# The namevar of the defined resource type is the listening service's name. -# This name goes right after the 'listen' statement in haproxy.cfg -# -# [*ports*] -# Ports on which the proxy will listen for connections on the ip address -# specified in the virtual_ip parameter. Accepts either a single string or -# an array of strings which may be a unique port or a hyphenated port range. -# -# [*order*] -# The order, or numerical weight, of the fragment created by this defined -# resource type. This is necessary to ensure the fragment is associated -# with the correct listening service instance. -# -# [*listen_ip*] -# 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 listening service. Valid values are 'tcp', -# HTTP', and 'health'. -# -# [*config_options*] -# A hash of options that are inserted into the listening service -# 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 balancermembers in advance and use haproxy::balancermember -# with array arguments, which allows you to deploy everything in 1 run) -# -# -# === Examples -# -# Exporting the resource for a balancer member: -# -# haproxy::config { 'puppet00': -# order => '20', -# listen_ip => $::ipaddress, -# ports => '18140', -# mode => 'tcp', -# config_options => { -# 'option' => [ -# 'tcplog', -# 'ssl-hello-chk' -# ], -# 'balance' => 'roundrobin' -# }, -# } -# -# === Authors -# -# Gary Larizza -# -define haproxy::config ( - $ports, - $order = '20', - $listen_ip = $::ipaddress, - $mode = 'tcp', - $collect_exported = true, - $config_options = { - 'option' => [ - 'tcplog', - 'ssl-hello-chk' - ], - 'balance' => 'roundrobin' - } -) { - concat::fragment { "${name}_config_block": - order => $order, - target => '/etc/haproxy/haproxy.cfg', - content => template('haproxy/haproxy_config_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. -} diff --git a/manifests/data.pp b/manifests/data.pp deleted file mode 100644 index ab920ed..0000000 --- a/manifests/data.pp +++ /dev/null @@ -1,65 +0,0 @@ -# == Class: haproxy::data -# -# This is a container class holding default parameters for for haproxy class. -# currently, only the Redhat family is supported, but this can be easily -# extended by changing package names and configuration file paths. -# -class haproxy::data { - case $osfamily { - Redhat: { - $haproxy_global_options = { - 'log' => "${::ipaddress} local0", - 'chroot' => '/var/lib/haproxy', - 'pidfile' => '/var/run/haproxy.pid', - 'maxconn' => '4000', - 'user' => 'haproxy', - 'group' => 'haproxy', - 'daemon' => '', - 'stats' => 'socket /var/lib/haproxy/stats' - } - $haproxy_defaults_options = { - 'log' => 'global', - 'stats' => 'enable', - 'option' => 'redispatch', - 'retries' => '3', - 'timeout' => [ - 'http-request 10s', - 'queue 1m', - 'connect 10s', - 'client 1m', - 'server 1m', - 'check 10s', - ], - 'maxconn' => '8000' - } - } - Debian: { - $haproxy_global_options = { - 'log' => "${::ipaddress} local0", - 'chroot' => '/var/lib/haproxy', - 'pidfile' => '/var/run/haproxy.pid', - 'maxconn' => '4000', - 'user' => 'haproxy', - 'group' => 'haproxy', - 'daemon' => '', - 'stats' => 'socket /var/lib/haproxy/stats' - } - $haproxy_defaults_options = { - 'log' => 'global', - 'stats' => 'enable', - 'option' => 'redispatch', - 'retries' => '3', - 'timeout' => [ - 'http-request 10s', - 'queue 1m', - 'connect 10s', - 'client 1m', - 'server 1m', - 'check 10s', - ], - 'maxconn' => '8000' - } - } - default: { fail("The $::osfamily operating system is not supported with the haproxy module") } - } -} diff --git a/manifests/init.pp b/manifests/init.pp index 7bf6aa9..92df8b8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,4 +1,4 @@ -# == Class: puppet-haproxy +# == Class: haproxy # # A Puppet module, using storeconfigs, to model an haproxy configuration. # Currently VERY limited - assumes Redhat/CentOS setup. Pull requests accepted! @@ -15,13 +15,13 @@ # Chooses whether haproxy should be installed or ensured absent. # Currently ONLY accepts valid boolean true/false values. # -# [*haproxy_global_options*] +# [*global_options*] # A hash of all the haproxy global options. If you want to specify more # than one option (i.e. multiple timeout or stats options), pass those # options as an array and you will get a line for each of them in the # resultant haproxy.cfg file. # -# [*haproxy_defaults_options*] +# [*defaults_options*] # A hash of all the haproxy defaults options. If you want to specify more # than one option (i.e. multiple timeout or stats options), pass those # options as an array and you will get a line for each of them in the @@ -31,8 +31,8 @@ # === Examples # # class { 'haproxy': -# enable => true, -# haproxy_global_options => { +# enable => true, +# global_options => { # 'log' => "${::ipaddress} local0", # 'chroot' => '/var/lib/haproxy', # 'pidfile' => '/var/run/haproxy.pid', @@ -42,7 +42,7 @@ # 'daemon' => '', # 'stats' => 'socket /var/lib/haproxy/stats' # }, -# haproxy_defaults_options => { +# defaults_options => { # 'log' => 'global', # 'stats' => 'enable', # 'option' => 'redispatch', @@ -59,16 +59,12 @@ # }, # } # -# === Authors -# -# Gary Larizza -# class haproxy ( - $manage_service = true, - $enable = true, - $haproxy_global_options = $haproxy::data::haproxy_global_options, - $haproxy_defaults_options = $haproxy::data::haproxy_defaults_options -) inherits haproxy::data { + $manage_service = true, + $enable = true, + $global_options = $haproxy::params::global_options, + $defaults_options = $haproxy::params::defaults_options +) inherits haproxy::params { include concat::setup package { 'haproxy': @@ -95,7 +91,7 @@ class haproxy ( content => "# This file managed by Puppet\n", } - # Most of the variables are used inside the haproxy-base.cfg.erb template + # Template uses $global_options, $defaults_options concat::fragment { 'haproxy-base': target => '/etc/haproxy/haproxy.cfg', order => '10', @@ -110,7 +106,7 @@ class haproxy ( } } - file { $haproxy_global_options['chroot']: + file { $global_options['chroot']: ensure => directory, before => Service['haproxy'], } @@ -132,7 +128,7 @@ class haproxy ( hasstatus => true, require => [ Concat['/etc/haproxy/haproxy.cfg'], - File[$haproxy_global_options['chroot']], + File[$global_options['chroot']], ], } } diff --git a/manifests/listen.pp b/manifests/listen.pp new file mode 100644 index 0000000..d4ddd60 --- /dev/null +++ b/manifests/listen.pp @@ -0,0 +1,101 @@ +# == Define Resource Type: haproxy::listen +# +# This type will setup a listening service configuration block inside +# the haproxy.cfg file on an haproxy load balancer. Each listening service +# configuration needs one or more load balancer member server (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 balancer members. +# +# === Parameters +# +# [*name*] +# The namevar of the defined resource type is the listening service's name. +# This name goes right after the 'listen' statement in haproxy.cfg +# +# [*ports*] +# Ports on which the proxy will listen for connections on the ip address +# specified in the virtual_ip parameter. Accepts either a single string or +# an array of strings which may be a unique port or a hyphenated port range. +# +# [*order*] +# The order, or numerical weight, of the fragment created by this defined +# resource type. This is necessary to ensure the fragment is associated +# with the correct listening service instance. +# +# [*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 listening service. Valid values are 'tcp', +# HTTP', and 'health'. +# +# [*options*] +# A hash of options that are inserted into the listening service +# 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 balancermembers in advance and use haproxy::balancermember +# with array arguments, which allows you to deploy everything in 1 run) +# +# +# === Examples +# +# Exporting the resource for a balancer member: +# +# haproxy::listen { 'puppet00': +# order => '20', +# ipaddress => $::ipaddress, +# ports => '18140', +# mode => 'tcp', +# options => { +# 'option' => [ +# 'tcplog', +# 'ssl-hello-chk' +# ], +# 'balance' => 'roundrobin' +# }, +# } +# +# === Authors +# +# Gary Larizza +# +define haproxy::listen ( + $ports, + $order = '20', + $ipaddress = $::ipaddress, + $mode = 'tcp', + $collect_exported = true, + $options = { + 'option' => [ + 'tcplog', + 'ssl-hello-chk' + ], + 'balance' => 'roundrobin' + } +) { + # Template uses: $name, $ipaddress, $ports, $options + concat::fragment { "${name}_listen_block": + order => $order, + target => '/etc/haproxy/haproxy.cfg', + content => template('haproxy/haproxy_listen_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. +} diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..53442dd --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,65 @@ +# == Class: haproxy::params +# +# This is a container class holding default parameters for for haproxy class. +# currently, only the Redhat family is supported, but this can be easily +# extended by changing package names and configuration file paths. +# +class haproxy::params { + case $osfamily { + Redhat: { + $global_options = { + 'log' => "${::ipaddress} local0", + 'chroot' => '/var/lib/haproxy', + 'pidfile' => '/var/run/haproxy.pid', + 'maxconn' => '4000', + 'user' => 'haproxy', + 'group' => 'haproxy', + 'daemon' => '', + 'stats' => 'socket /var/lib/haproxy/stats' + } + $defaults_options = { + 'log' => 'global', + 'stats' => 'enable', + 'option' => 'redispatch', + 'retries' => '3', + 'timeout' => [ + 'http-request 10s', + 'queue 1m', + 'connect 10s', + 'client 1m', + 'server 1m', + 'check 10s', + ], + 'maxconn' => '8000' + } + } + Debian: { + $global_options = { + 'log' => "${::ipaddress} local0", + 'chroot' => '/var/lib/haproxy', + 'pidfile' => '/var/run/haproxy.pid', + 'maxconn' => '4000', + 'user' => 'haproxy', + 'group' => 'haproxy', + 'daemon' => '', + 'stats' => 'socket /var/lib/haproxy/stats' + } + $defaults_options = { + 'log' => 'global', + 'stats' => 'enable', + 'option' => 'redispatch', + 'retries' => '3', + 'timeout' => [ + 'http-request 10s', + 'queue 1m', + 'connect 10s', + 'client 1m', + 'server 1m', + 'check 10s', + ], + 'maxconn' => '8000' + } + } + default: { fail("The $::osfamily operating system is not supported with the haproxy module") } + } +} -- cgit v1.2.3