Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Commit ad58e08

Browse files
authored
Merge pull request #1275 from cbaenziger/mysql_vip_fix
LGTM
2 parents b357859 + 7b48192 commit ad58e08

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

cookbooks/bcpc/attributes/apache2.rb

+10
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313

1414
# extra files to be exposed
1515
bach_web['files_url'] = 'files'
16+
17+
# links to services (an hash of hashes with structure:
18+
# <name>=>{'desc':<desc> and 'url':<url>} to be listed)
19+
bach_web['links'] = {}
20+
# files to be served from nodes
21+
# <name>=>{'desc':<desc> and 'path':<file>} to be listed)
22+
# note: file needs to be under the document_root/files directory
23+
bach_web['files'] = {}
24+
# <name>=>{'desc':<desc> and 'port':<port>} to be listed)
25+
bach_web['files'] = {}
1626
end
1727

1828
# haproxy

cookbooks/bcpc/recipes/haproxy.rb

+9-6
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@
5757
service.merge({
5858
'servers' => get_nodes_for(service['servers_recipe'], service['servers_cookbook']).map { |hst|
5959
{
60-
'fqdn' => float_host(hst['fqdn']),
61-
'ip' => hst['bcpc']['floating']['ip'],
60+
'fqdn' => hst['fqdn'],
61+
'floating_fqdn' => float_host(hst['fqdn']),
62+
'floating_ip' => hst['bcpc']['floating']['ip'],
6263
'port' => service['servers_port']
6364
}
6465
}
@@ -67,17 +68,19 @@
6768

6869
mysql_servers = get_nodes_for("mysql","bcpc").collect { |hst|
6970
{
70-
'fqdn' => float_host(hst['fqdn']),
71-
'ip' => hst['bcpc']['floating']['ip']
71+
'fqdn' => hst['fqdn'],
72+
'ip' => hst['bcpc']['management']['ip']
7273
}
7374
}
7475

7576
template "/etc/haproxy/haproxy.cfg" do
7677
source "haproxy.cfg.erb"
7778
mode 00644
7879
variables(:mysql_servers => mysql_servers,
79-
:cluster_vip => node['bcpc']['floating']['vip'],
80-
:local_ip => node['bcpc']['floating']['ip'],
80+
:floating_vip => node['bcpc']['floating']['vip'],
81+
:management_vip => node['bcpc']['management']['vip'],
82+
:local_management_ip => node['bcpc']['management']['ip'],
83+
:local_floating_ip => node['bcpc']['floating']['ip'],
8184
:haproxy_stats_user => get_config('haproxy-stats-user'),
8285
:haproxy_stats_pwd => get_config!('password',"haproxy-stats","os"),
8386
:haproxy_tune_chksize => node['bcpc']['haproxy']['tune_chksize'],

cookbooks/bcpc/templates/default/haproxy.cfg.erb

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ global
1616
defaults
1717
log global
1818
maxconn 8000
19-
source <%= @local_ip %>
19+
source <%= @local_management_ip %>
2020
mode http
2121
option abortonclose
2222
option tcplog
@@ -31,25 +31,25 @@ defaults
3131
timeout client 30m
3232
timeout server 30m
3333

34-
listen stats <%= @local_ip%>:1936
34+
listen stats <%= @local_management_ip%>:1936
3535
mode http
3636
stats enable
3737
stats uri /
3838
stats hide-version
3939
stats realm Haproxy\ Statistics
4040
stats auth <%= "#{@haproxy_stats_user}:#{@haproxy_stats_pwd}" %>
4141

42-
listen stats-vip <%= @cluster_vip%>:1936
42+
listen stats-vip <%= @management_vip%>:1936
4343
mode http
44-
server myself <%= @local_ip %>:1936
44+
server myself <%= @local_management_ip %>:1936
4545

46-
listen memcached <%= @cluster_vip %>:11211
46+
listen memcached <%= @management_vip %>:11211
4747
mode tcp
4848
option tcpka
4949
server myself 127.0.0.1:11211
5050

5151
<% if @mysql_servers.length > 0 -%>
52-
listen mysql-galera <%= @cluster_vip %>:3306
52+
listen mysql-galera <%= @management_vip %>:3306
5353
timeout client 24h
5454
timeout server 24h
5555
mode tcp
@@ -63,15 +63,15 @@ listen mysql-galera <%= @cluster_vip %>:3306
6363
<% end -%>
6464

6565
<% @ha_services.each do |service| -%>
66-
listen <%= "#{service['name']} #{@cluster_vip}:#{service['port']}" %>
66+
listen <%= "#{service['name']} #{@floating_vip}:#{service['port']}" %>
6767
balance roundrobin
6868
<% if !service['http_check_url'].nil? and !service['http_check_expect_str'].nil? -%>
6969
option httpchk GET <%= service['http_check_url'] %>
7070
http-check expect string <%= service['http_check_expect_str'] %>
7171
<% end -%>
72-
source <%= @local_ip %>
72+
source <%= @local_floating_ip %>
7373
<% service['servers'].each do |server| -%>
74-
<%= "server #{server['fqdn']} #{server['ip']}:#{server['port']} check" %>
74+
<%= "server #{server['floating_fqdn']} #{server['floating_ip']}:#{server['port']} check" %>
7575
<% end -%>
7676

7777
<% end -%>

0 commit comments

Comments
 (0)