Defined Type: haproxy::mapfile

Defined in:
manifests/mapfile.pp

Summary

Manage an HAProxy map file as documented in https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#7.3.1-map

Overview

Note:

A map file contains one key + value per line. These key-value pairs are specified in the ‘mappings` array or by additional `haproxy::mapfile::entry` definitions.

Parameters:

  • 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.

  • mappings (Array[Variant[String, Hash]]) (defaults to: [])

    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: ‘[]`

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    The state of the underlying file resource, either ‘present’ or ‘absent’. Default: ‘present’

  • owner (String) (defaults to: 'root')

    The owner of the underlying file resource. Defaut: ‘root’

  • group (String) (defaults to: 'root')

    The group of the underlying file resource. Defaut: ‘root’

  • mode (String) (defaults to: '0644')

    The mode of the underlying file resource. Defaut: ‘0644’

  • instances (Array) (defaults to: ['haproxy'])

    Array of managed HAproxy instance names to notify (restart/reload) when the map file is updated. This is so that the same map file can be used with multiple HAproxy instances. Default: ‘[ ’haproxy’ ]‘



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'manifests/mapfile.pp', line 37

define haproxy::mapfile (
  Array[Variant[String, Hash]]  $mappings   = [],
  Enum['present', 'absent']     $ensure     = 'present',
  String                        $owner      = 'root',
  String                        $group      = 'root',
  String                        $mode       = '0644',
  Array                         $instances  = ['haproxy'],
) {
  $mapfile_name = $title

  $_instances = flatten($instances)

  $_mapfile_name = "${haproxy::config_dir}/${mapfile_name}.map"

  concat { "haproxy_mapfile_${mapfile_name}":
    ensure => $ensure,
    owner  => $owner,
    group  => $group,
    mode   => $mode,
    path   => $_mapfile_name,
    notify => Haproxy::Service[$_instances],
  }

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

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