Puppet Class: keepalived

Defined in:
modules/keepalived/manifests/init.pp

Overview

Parameters:

  • peers (Array[Stdlib::Fqdn])
  • auth_pass (String)
  • vips (Array[Stdlib::IP::Address])
  • default_state (Enum['BACKUP', 'MASTER']) (defaults to: 'BACKUP')
  • interface (String) (defaults to: $::facts['networking']['primary'])
  • priority (Integer) (defaults to: fqdn_rand(100))
  • virtual_router_id (Integer) (defaults to: 51)
  • config (String) (defaults to: '')


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
# File 'modules/keepalived/manifests/init.pp', line 22

class keepalived(
    Array[Stdlib::Fqdn] $peers,
    String              $auth_pass,
    Array[Stdlib::IP::Address] $vips,
    Enum['BACKUP', 'MASTER']   $default_state = 'BACKUP',
    String              $interface            = $::facts['networking']['primary'],
    Integer             $priority             = fqdn_rand(100),
    Integer             $virtual_router_id    = 51,
    String              $config               = '',
) {
    if debian::codename::eq('bullseye') {
        # default keepalived in bullseye seems broken, see
        # https://bugs.debian.org/1008222
        apt::package_from_bpo { 'keepalived':
            distro => 'bullseye',
        }
    }

    package { 'keepalived':
        ensure => present,
    }

    # support for arbitrary config file
    if $config == '' {
        $content = template('keepalived/keepalived.conf.erb')
    } else {
        $content = $config
    }

    file { '/etc/keepalived/keepalived.conf':
        ensure    => present,
        mode      => '0444',
        owner     => 'root',
        group     => 'root',
        content   => $content,
        show_diff => false,
        require   => Package['keepalived'],
        notify    => Exec['restart-keepalived'],
    }

    exec { 'restart-keepalived':
        command     => '/bin/systemctl restart keepalived',
        refreshonly => true,
    }
}