Debian Codegraph @

manifests/mapfile/entry.pp

raw
1 # @summary
2 # Manage an HAProxy map file as documented in
3 # https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#7.3.1-map
4 #
5 # @note
6 # A map file contains one key + value per line. These key-value pairs are
7 # specified in the `mappings` array.
8 #
9 #
10 # @param name
11 # The namevar of the defined resource type is the filename of the map file
12 # (without any extension), relative to the `haproxy::config_dir` directory.
13 # A '.map' extension will be added automatically.
14 #
15 # @param mappings
16 # An array of mappings for this map file. Array elements may be Hashes with a
17 # single key-value pair each (preferably) or simple Strings. Default: `[]`
18 #
19 # @param mapfile
20 # A string that specifies the name of the mapfile. Default value: ''.
21 #
22 # @param order
23 # Defines the order for the mapfile. Accepts Integer or Strings. Default value: '10'.
24 #
25 define haproxy::mapfile::entry (
26 String $mapfile,
27 Array[Variant[String, Hash]] $mappings = [$title],
28 Variant[String, Integer] $order = '10',
29 ) {
30 $_mapfile_name = "${haproxy::config_dir}/${mapfile}.map"
31
32 $parameters = {
33 'mappings' => $mappings,
34 'mapfile_name' => $title,
35 }
36
37 concat::fragment { "haproxy_mapfile_${mapfile}-${title}":
38 target => $_mapfile_name,
39 content => epp('haproxy/haproxy_mapfile.epp', $parameters),
40 order => $order,
41 }
42 }