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: 'eth0')
  • 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
67
68
69
70
71
72
73
74
75
76
77
# 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            = 'eth0',
    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::pin { 'keepalived-bullseye-bpo':
            pin      => 'release a=bullseye-backports',
            package  => 'keepalived',
            priority => 1001,
            before   => Package['keepalived'],
            notify   => Exec['keepalived-apt-get-update'],
        }

        exec { 'keepalived-apt-get-update':
            command     => '/usr/bin/apt-get update',
            refreshonly => true,
        }

        Exec['keepalived-apt-get-update'] -> Package <| |>
    }

    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,
    }
}