-
Notifications
You must be signed in to change notification settings - Fork 4
/
README
205 lines (156 loc) · 6.2 KB
/
README
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# keepalived module #
Author : Benoit CATTIE <[email protected]>
Version : 1.0
Licence : GPLv3
Basic module for configuring keepalived with puppet.
This module requires :
- puppet-common module (http://forge.puppetlabs.com/DavidSchmitt/common)
- stored configuration
- Create '/var/lib/puppet/modules/keepalived/functions' directory on the puppetmaster with write permission
I m not going to explain how keepalived / IPVS works :
- http://www.keepalived.org/documentation.html ( http://www.keepalived.org/pdf/UserGuide.pdf )
All variables without documentation in this module is documented in keepalived user guide
# Special note for DSR config on the exported real server #
This module setup loopback interface and arp config on exported real servers.
Be carefull when the real server reboots : config is made 'on the fly'.
You can add some fixed config. In my case i construct /etc/network/interfaces using concat::fragment. So i have something like this in keepalived::virtual_server :
@@concat::fragment{"network_interfaces_eth0-DSR-$name":
target => "/etc/network/interfaces",
ensure => present,
content => "\t#DSR IP for $name\n\tup ip addr add ${virtual_ipaddress}/32 dev lo\n",
order => 'eth0_20',
tag => "keepalived-exported-dsr-config-$name",
}
with Concat::Fragment <<| tag == "keepalived-exported-dsr-config-$virtual_server_name" |>> in keepalived::exported_real_server
This config is commented in those manifests.
keepalived::arp_config class ensure arp configuration at boot time.
## Class: keepalived::server ##
install keepalived from packages
install a basic /etc/keepalived/keepalived.conf file
## Class: keepalived::arp_config ##
This class manage arp_config on the real servers using /etc/sysctl.d/ directory.
## Define: keepalived::virtual_server ##
Configure a vrrp virtual server.
Only DR mode is implemented in this module.
This definition collect all keepalived::exported_real_server to construct keepalived.conf
Variables :
state : MASTER or BACKUP
virtual_router_id
virtual_ipaddress
virtual_server_port
lb_kind = 'DR' : Support only DR in this version
lb_algo = 'wlc'
interface = 'eth0'
priority = '' : If not set, BACKUP will take 100 and MASTER 200
## Define: keepalived::real_server ##
Configure a vrrp real server. (not exported, see "standelone config" example)
Variables :
ip
port
virtual_server_name : name of the related keepalived::virtual_server
weight = '100',
check_type : MISC_CHECK , TCP_CHECK or HTTP_GET - if not set, the check is a TCP_CHECK on $port
check_connect_timeout = '2',
check_nb_get_retry = '2',
check_delay_before_retry = '2',
check_misc_path = '', #for MISC_CHECK
check_connect_port = '', #for TCP_CHECK and HTTP_GET
check_url_path = '', #for HTTP_GET
check_url_digest = '' #for HTTP_GET
## Define: keepalived::exported_real_server ##
Configure an "exported" vrrp real server.
This real server is collected by keepalived::virtual_server
Variables :
$virtual_server_name : the name of the keepalived::virtual_server collecting real servers
$port
$weight
$ip = "$ipaddress",
$check_type = 'TCP_CHECK', # MISC_CHECK , TCP_CHECK or HTTP_GET - if not set, the check is a TCP_CHECK on $port
$check_connect_timeout = '2',
$check_nb_get_retry = '2',
$check_delay_before_retry = '2',
$check_misc_path = '', #for MISC_CHECK
$check_connect_port = '', #for TCP_CHECK and HTTP_GET
$check_url_path = '', #for HTTP_GET
$check_url_digest = '' #for HTTP_GET
) {
## Sample Usage ##
# standelone config #
node vrrp_master {
include keepalived::server
keepalived::virtual_server{"lb_www":
state => 'MASTER',
virtual_router_id => "42",
virtual_ipaddress => "192.168.0.42",
virtual_server_port => "80",
lb_kind => "DR",
notification_email => "root@localhost",
}
keepalived::real_server{"www1":
virtual_server_name => "lb_www",
ip => '192.168.0.45',
port => '80',
weight => '100',
}
keepalived::real_server{"www2":
virtual_server_name => "lb_www",
ip => '192.168.0.46',
port => '80',
weight => '90',
}
}
# with exported ressource config #
@keepalived::virtual_server{"lb_www":
virtual_router_id => "42",
virtual_ipaddress => "192.168.0.42",
virtual_server_port => "80",
lb_kind => "DR",
}
@keepalived::virtual_server{"lb_sql":
virtual_router_id => "43",
virtual_ipaddress => "192.168.0.43",
virtual_server_port => "3306",
lb_kind => "DR",
}
node vrrp_master {
include keepalived::server
Keepalived::Virtual_server <| title == "lb_www" |> {state => "MASTER"}
Keepalived::Virtual_server <| title == "lb_sql" |> {state => "MASTER"}
}
node vrrp_slave {
include keepalived::server
Keepalived::Virtual_server <| title == "lb_www" |> {state => "BACKUP"}
Keepalived::Virtual_server <| title == "lb_sql" |> {state => "BACKUP"}
}
node www1 {
keepalived::exported_real_server{"$fqdn-lb_www":
virtual_server_name => "lb_www",
port => '80',
weight => '100',
}
}
node www2 {
keepalived::exported_real_server{"$fqdn-lb_www":
virtual_server_name => "lb_www",
port => '80',
weight => '90',
}
}
node sql1 {
keepalived::exported_real_server{"$fqdn-lb_sql":
virtual_server_name => "lb_sql",
port => '3306',
weight => '100',
check_type => 'MISC_CHECK',
check_misc_path => "/usr/local/bin/is_mysql_OK.sh $ipaddress",
}
}
node sql2 {
keepalived::exported_real_server{"$fqdn-lb_sql":
virtual_server_name => "lb_sql",
port => '3306',
weight => '90',
check_type => 'MISC_CHECK',
check_misc_path => "/usr/local/bin/is_mysql_OK.sh $ipaddress",
}
}