Debian Codegraph @

manifests/peers.pp

raw
1 # @summary
2 # This type will set up a peers entry in haproxy.cfg
3 # on the load balancer. This setting is required to share the
4 # current state of HAproxy with other HAproxy in High available
5 # configurations.
6 #
7 #
8 # @param name
9 # Sets the peers' name. Generally it will be the namevar of the
10 # defined resource type. This value appears right after the
11 # 'peers' statement in haproxy.cfg
12 #
13 # @param config_file
14 # Optional. Path of the config file where this entry will be added.
15 # Assumes that the parent directory exists.
16 # Default: $haproxy::params::config_file
17 #
18 # @param instance
19 # Optional. Defaults to 'haproxy'
20 #
21 # @param collect_exported
22 # Boolean. Defaults to true
23 #
24 define haproxy::peers (
25 Boolean $collect_exported = true,
26 String $instance = 'haproxy',
27 Optional[Stdlib::Absolutepath] $config_file = undef,
28 ) {
29 # We derive these settings so that the caller only has to specify $instance.
30 include haproxy::params
31
32 if $instance == 'haproxy' {
33 $instance_name = 'haproxy'
34 $_config_file = pick($config_file, $haproxy::config_file)
35 } else {
36 $instance_name = "haproxy-${instance}"
37 $_config_file = pick($config_file, inline_template($haproxy::params::config_file_tmpl))
38 }
39
40 # Template uses: $name
41 concat::fragment { "${instance_name}-${name}_peers_block":
42 order => "30-peers-00-${name}",
43 target => $_config_file,
44 content => epp('haproxy/haproxy_peers_block.epp', { 'name' => $name }),
45 }
46
47 if $collect_exported {
48 haproxy::peer::collect_exported { $name: }
49 }
50 # else: the resources have been created and they introduced their
51 # concat fragments. We don't have to do anything about them.
52 }