Defined Type: haproxy::resolver
- Defined in:
- manifests/resolver.pp
Summary
This type will setup resolvers configuration block inside the haproxy.cfg file on an haproxy load balancer.Overview
Authors
Gary Larizza <gary@puppetlabs.com> Ricardo Rosales <missingcharacter@gmail.com>
Note:
Currently requires the puppetlabs/concat module on the Puppet Forge and uses storeconfigs on the Puppet Server to export/collect resources from all balancer members.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'manifests/resolver.pp', line 98
define haproxy::resolver (
Hash $nameservers = {},
Boolean $parse_resolv_conf = false,
Optional[Hash] $hold = undef,
Optional[Integer] $resolve_retries = undef,
Optional[Hash] $timeout = undef,
# https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#5.3.2-accepted_payload_size
Optional[Integer[512, 8192]] $accepted_payload_size = undef,
String $instance = 'haproxy',
String[1] $section_name = $name,
Boolean $sort_options_alphabetic = true,
Boolean $collect_exported = true,
Optional[Stdlib::Absolutepath] $config_file = undef,
Optional[String] $defaults = undef,
) {
include haproxy::params
if $instance == 'haproxy' {
$instance_name = 'haproxy'
$_config_file = pick($config_file, $haproxy::config_file)
} else {
$instance_name = "haproxy-${instance}"
$_config_file = pick($config_file, inline_template($haproxy::params::config_file_tmpl))
}
assert_type(Stdlib::AbsolutePath, dirname($_config_file))
include haproxy::globals
$_sort_options_alphabetic = pick($sort_options_alphabetic, $haproxy::globals::sort_options_alphabetic)
if $defaults == undef {
$order = "20-${section_name}-01"
} else {
$order = "25-${defaults}-${section_name}-02"
}
$parameters = {
'section_name' => $section_name,
'nameservers' => $nameservers,
'parse_resolv_conf' => $parse_resolv_conf,
'resolve_retries' => $resolve_retries,
'timeout' => $timeout,
'hold' => $hold,
'accepted_payload_size' => $accepted_payload_size,
}
# Template uses: $section_name
concat::fragment { "${instance_name}-${section_name}_resolver_block":
order => $order,
target => $_config_file,
content => epp('haproxy/haproxy_resolver_block.epp', $parameters),
}
if $collect_exported {
haproxy::balancermember::collect_exported { $section_name: }
}
# else: the resources have been created and they introduced their
# concat fragments. We don't have to do anything about them.
}
|