File: entry.pp

package info (click to toggle)
puppet-module-puppetlabs-haproxy 8.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 816 kB
  • sloc: ruby: 3,979; sh: 14; makefile: 4
file content (42 lines) | stat: -rw-r--r-- 1,367 bytes parent folder | download
1
2
3
4
5
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
# @summary
#   Manage an HAProxy map file as documented in
#   https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#7.3.1-map
#
# @note
#   A map file contains one key + value per line. These key-value pairs are
#   specified in the `mappings` array.
#
#
# @param name
#   The namevar of the defined resource type is the filename of the map file
#   (without any extension), relative to the `haproxy::config_dir` directory.
#   A '.map' extension will be added automatically.
#
# @param mappings
#   An array of mappings for this map file. Array elements may be Hashes with a
#   single key-value pair each (preferably) or simple Strings. Default: `[]`
#
# @param mapfile
#   A string that specifies the name of the mapfile. Default value: ''.
#
# @param order
#   Defines the order for the mapfile. Accepts Integer or Strings. Default value: '10'.
#
define haproxy::mapfile::entry (
  String                       $mapfile,
  Array[Variant[String, Hash]] $mappings = [$title],
  Variant[String, Integer]     $order = '10',
) {
  $_mapfile_name = "${haproxy::config_dir}/${mapfile}.map"

  $parameters = {
    'mappings'     => $mappings,
    'mapfile_name' => $title,
  }

  concat::fragment { "haproxy_mapfile_${mapfile}-${title}":
    target  => $_mapfile_name,
    content => epp('haproxy/haproxy_mapfile.epp', $parameters),
    order   => $order,
  }
}