/
keepalived.pp
142 lines (127 loc) · 3.68 KB
/
keepalived.pp
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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# == Class: lizardfs::keepalived
#
# Configure the high availability of LizardFS with keepalived.
#
# === Authors
#
# Copyright (c) Asher256
#
# License: Apache 2.0
#
# URL: https://github.com/Asher256/puppet-lizardfs
#
# === Examples
#
# class {'lizardfs::ha::keepalived':
# interface => 'eth0',
# auth_pass => 'MyPassword',
# virtual_ip => ['192.168.1.100'],
# }
#
# === Parameters
#
# [*interface*] the network interface (e.g. eth0)
#
# [*priority*] keepalived priority (e.g. 100)
#
# [*auth_pass] the authentication password
#
# [*virtual_ip*] the virtual IP address (need to be a list)
#
# [*virtual_router_id*] arbitary unique number 0..255
# used to differentiate multiple instances of vrrpd
# running on the same NIC (and hence same socket).
# You need to have the same value on the members of the
# same cluster.
#
# [*lvs_id*] keepalived's lvs_id
#
# [*track_script_interval*] check the track script every x seconds (keepalived)
#
# [*track_script_fall*] requires x failures for KO status (keepalived)
#
# [*track_script_raise*] requires x success for OK status (keepalived)
#
# [*state*] keepalived state (MASTER or BACKUP)
#
# [*failover_mfsmetarestore*] true to run 'mfsmetarestore -a' before "mfsmaster start".
# This feature is UNTESTED and I recommend you to
# set AUTO_RECOVERY=1 in /etc/lizardfs/mfsmaster.cfg instead.
# (you can use: lizardfs::master::options={'AUTO_RECOVERY' => 1])
#
class lizardfs::ha::keepalived(
$interface,
$auth_pass,
$virtual_ip,
$lvs_id,
$virtual_router_id = 99,
$priority = 100,
$email_enabled = false,
$smtp_server = '127.0.0.1',
$email_from = 'noreply@domain.com',
$email_to = 'noreplay@domain.com',
$track_script_interval = 10,
$track_script_fall = 5,
$track_script_raise = 2,
$state = undef,
$failover_mfsmetarestore = false,
) {
validate_string($interface)
validate_integer($priority)
validate_string($state)
validate_string($auth_pass)
validate_array($virtual_ip)
validate_integer($virtual_router_id)
validate_string($lvs_id)
validate_string($email_to)
validate_string($email_from)
validate_string($smtp_server)
validate_bool($failover_mfsmetarestore)
include ::lizardfs::master
$master_data_path = $::lizardfs::master::data_path
File {
ensure => present,
mode => '0644',
owner => 'root',
group => 'root',
}
$mfsmaster_personality = $::lizardfs::master::mfsmaster_personality
$script_generate_mfsmaster = $::lizardfs::master::script_generate_mfsmaster
$cfgdir = $::lizardfs::cfgdir
Class['::lizardfs::master']
-> package { 'keepalived':
ensure => present
}
-> file { "${::lizardfs::cfgdir}lfs_failover.sh":
ensure => present,
mode => '0700',
content => template('lizardfs/etc/lizardfs/lfs_failover.sh.erb'),
}
# TODO: remove this file
-> file { "${::lizardfs::cfgdir}lfs_failover_to_master.sh":
ensure => absent,
mode => '0700',
content => "#!/usr/bin/env bash
${::lizardfs::cfgdir}lfs_failover.sh to_master",
}
# TODO: remove this file
-> file { "${::lizardfs::cfgdir}lfs_failover_to_shadow.sh":
ensure => absent,
mode => '0700',
content => "#!/usr/bin/env bash
${::lizardfs::cfgdir}lfs_failover.sh to_shadow",
}
-> file { '/etc/keepalived/keepalived.conf':
content => template('lizardfs/etc/keepalived/keepalived.conf.erb'),
notify => Exec['reload-keepalived'],
}
-> service { 'keepalived':
ensure => running,
}
-> exec { 'reload-keepalived':
command => 'systemctl reload keepalived',
path => '/bin:/sbin:/usr/bin:/usr/sbin',
refreshonly => true,
}
}
# vim:et:sw=2:ts=2:sts=2:tw=0:fenc=utf-8