Puppet Class: tripleo::haproxy::stats

Defined in:
manifests/haproxy/stats.pp

Overview

Class: tripleo::haproxy::stats

Configure the HAProxy stats interface

haproxy_listen_bind_param

A list of params to be added to the HAProxy listener bind directive.

ip

IP Address(es) on which the stats interface is listening on. Can be a string or a list of ip addresses

use_backend_syntax

(optional) When set to true, generate a config with frontend and backend sections, otherwise use listen sections. Defaults to hiera(‘haproxy_backend_syntax’, false)

port

Port on which to listen to for haproxy stats web interface Defaults to ‘1993’

password

Password for haproxy stats authentication. When set, authentication is enabled on the haproxy stats endpoint. A string. Defaults to undef

certificate

Filename of an HAProxy-compatible certificate and key file When set, enables SSL on the haproxy stats endpoint using the specified file. Defaults to undef

user

Username for haproxy stats authentication. A string. Defaults to ‘admin’

Parameters:

  • haproxy_listen_bind_param (Any)
  • ip (Any)
  • use_backend_syntax (Any) (defaults to: hiera('haproxy_backend_syntax', false))
  • port (Any) (defaults to: '1993')
  • password (Any) (defaults to: undef)
  • certificate (Any) (defaults to: undef)
  • user (Any) (defaults to: 'admin')


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
92
93
94
95
96
97
98
99
100
101
# File 'manifests/haproxy/stats.pp', line 52

class tripleo::haproxy::stats (
  $haproxy_listen_bind_param,
  $ip,
  $use_backend_syntax = hiera('haproxy_backend_syntax', false),
  $port        = '1993',
  $password    = undef,
  $certificate = undef,
  $user        = 'admin'
) {
  if $certificate {
    $opts = union($haproxy_listen_bind_param, ['ssl', 'crt', $certificate])
  } else {
    $opts = $haproxy_listen_bind_param
  }

  $haproxy_stats_bind_opts = list_to_hash(suffix(any2array($ip), ":${port}"), $opts)

  $stats_base = ['enable', 'uri /']
  if $password {
    $stats_config = union($stats_base, ["auth ${user}:${password}"])
  } else {
    $stats_config = $stats_base
  }
  if $use_backend_syntax {
    haproxy::frontend { 'haproxy.stats':
      bind             => $haproxy_stats_bind_opts,
      mode             => 'http',
      options          => {
        'default_backend' => 'haproxy.stats_be',
        'stats'           => $stats_config,
      },
      collect_exported => false,
    }
    haproxy::backend { 'haproxy.stats_be':
      mode    => 'http',
      options => {
        'stats' => $stats_config,
      },
    }
  } else {
    haproxy::listen { 'haproxy.stats':
      bind             => $haproxy_stats_bind_opts,
      mode             => 'http',
      options          => {
        'stats' => $stats_config,
      },
      collect_exported => false,
    }
  }
}