Puppet Class: r_profile::lb::haproxy

Defined in:
manifests/lb/haproxy.pp

Overview

R_profile::Lb::Haproxy

A haproxy based load-balancer

tickets.puppetlabs.com/browse/MODULES-3932

Parameters:

  • listeners (Any) (defaults to: hiera('r_profile::lb::haproxy::listeners',undef))
  • open_firewall (Any) (defaults to: hiera('r_profile::lb::haproxy::open_firewall', false))
  • frontends (Any) (defaults to: hiera('r_profile::lb::haproxy::frontends',undef))
  • backends (Any) (defaults to: hiera('r_profile::lb::haproxy::backends',undef))
  • admin_stats (Any) (defaults to: hiera('r_profile::lb::haproxy::admin_stats', true))
  • nagios_monitored (Any) (defaults to: hiera('r_profile::lb::haproxy::nagios_monitored', true))
  • stats_port (Any) (defaults to: hiera('r_profile::lb::haproxy::stats_port', '9090'))
  • stats_username (Any) (defaults to: hiera('r_profile::lb::haproxy::stats_username', 'puppet'))
  • stats_password (Any) (defaults to: hiera('r_profile::lb::haproxy::stats_password', 'puppet'))


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'manifests/lb/haproxy.pp', line 6

class r_profile::lb::haproxy(
  $listeners        = hiera('r_profile::lb::haproxy::listeners',undef),
  $open_firewall    = hiera('r_profile::lb::haproxy::open_firewall', false),
  $frontends        = hiera('r_profile::lb::haproxy::frontends',undef),
  $backends         = hiera('r_profile::lb::haproxy::backends',undef),
  $admin_stats      = hiera('r_profile::lb::haproxy::admin_stats', true),
  $nagios_monitored = hiera('r_profile::lb::haproxy::nagios_monitored', true),
  $stats_port       = hiera('r_profile::lb::haproxy::stats_port', '9090'),
  $stats_username   = hiera('r_profile::lb::haproxy::stats_username', 'puppet'),
  $stats_password   = hiera('r_profile::lb::haproxy::stats_password', 'puppet'),
) {


  include haproxy
  if $admin_stats {
    haproxy::listen { 'stats':
      ipaddress => '0.0.0.0',
      ports     => $stats_port,
      options   => {
        'mode'  => 'http',
        'stats' => ['uri /', "auth ${stats_username}:${stats_password}"],
        },
    }

    if $nagios_monitored {
      nagios::nagios_service_tcp { 'haproxy_stats':
        port => $stats_port,
      }
    }

    if $open_firewall {
      firewall { "100 nagios_stats":
        dport  => $stats_port,
        proto  => 'tcp',
        action => 'accept',
      }
    }
  }

  if $listeners {
    $listeners.each |String $listener,Hash $listener_values| {
      haproxy::listen { $listener:
        * => $listener_values,
      }

      if $open_firewall {
        firewall { "100 ${listener}":
          dport  => [$listener_values['ports']],
          proto  => 'tcp',
          action => 'accept',
        }
      }

      if $nagios_monitored {
        nagios::nagios_service_tcp { "haproxy_${listener}":
          port => $listener_values['ports'],
        }
      }

    }
  }

  if $frontends {
    $frontends.each |String $frontend, Hash $frontend_values| {
      haproxy::frontend { $frontend:
        * => $frontend_values,
      }

      if $open_firewall {
        firewall { "100 ${frontend}":
          dport  => [$frontend_values['ports']],
          proto  => 'tcp',
          action => 'accept',
        }
      }
    }
  }

  if $backends {
    $backends.each |String $backend, Hash $backend_values| {
      haproxy::backend { $backend:
        * => $backend_values,
      }
    }
  }
}