aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/ha
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/adapters/ansible/roles/ha')
-rw-r--r--deploy/adapters/ansible/roles/ha/files/notify.sh4
-rw-r--r--deploy/adapters/ansible/roles/ha/tasks/main.yml6
-rw-r--r--deploy/adapters/ansible/roles/ha/templates/failover.j265
-rw-r--r--deploy/adapters/ansible/roles/ha/templates/haproxy.cfg14
-rw-r--r--deploy/adapters/ansible/roles/ha/templates/keepalived.conf42
5 files changed, 32 insertions, 99 deletions
diff --git a/deploy/adapters/ansible/roles/ha/files/notify.sh b/deploy/adapters/ansible/roles/ha/files/notify.sh
deleted file mode 100644
index 5edffe84..00000000
--- a/deploy/adapters/ansible/roles/ha/files/notify.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-python /usr/local/bin/failover.py $1
-mysql -uroot -e"flush hosts"
-service mysql restart
diff --git a/deploy/adapters/ansible/roles/ha/tasks/main.yml b/deploy/adapters/ansible/roles/ha/tasks/main.yml
index edd5e6dd..668f6847 100644
--- a/deploy/adapters/ansible/roles/ha/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/ha/tasks/main.yml
@@ -57,12 +57,6 @@
- name: copy galera_chk file
copy: src=galera_chk dest=/usr/local/bin/galera_chk mode=0777
-- name: copy notify file
- copy: src=notify.sh dest=/usr/local/bin/notify.sh mode=0777
-
-- name: copy notify template file
- template: src=failover.j2 dest=/usr/local/bin/failover.py mode=0777
-
- name: add network service
lineinfile: dest=/etc/services state=present
line="mysqlchk 9200/tcp"
diff --git a/deploy/adapters/ansible/roles/ha/templates/failover.j2 b/deploy/adapters/ansible/roles/ha/templates/failover.j2
deleted file mode 100644
index 3b08cf2d..00000000
--- a/deploy/adapters/ansible/roles/ha/templates/failover.j2
+++ /dev/null
@@ -1,65 +0,0 @@
-import ConfigParser, os, socket
-import logging as LOG
-import pxssh
-import sys
-import re
-
-LOG_FILE="/var/log/mysql_failover"
-try:
- os.remove(LOG_FILE)
-except:
- pass
-
-LOG.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', filename=LOG_FILE,level=LOG.DEBUG)
-ha_vip = {{ internal_vip.ip }}
-LOG.info("ha_vip: %s" % ha_vip)
-
-#ha_vip = "10.1.0.50"
-galera_path = '/etc/mysql/conf.d/wsrep.cnf'
-pattern = re.compile(r"gcomm://(?P<prev_ip>.*)")
-
-def ssh_get_hostname(ip):
- try:
- s = pxssh.pxssh()
- s.login("%s" % ip, "root", "root")
- s.sendline('hostname') # run a command
- s.prompt() # match the prompt
- result = s.before.strip() # print everything before the prompt.
- return result.split(os.linesep)[1]
- except pxssh.ExceptionPxssh as e:
- LOG.error("pxssh failed on login.")
- raise
-
-def failover(mode):
- config = ConfigParser.ConfigParser()
- config.optionxform = str
- config.readfp(open(galera_path))
- wsrep_cluster_address = config.get("mysqld", "wsrep_cluster_address")
- wsrep_cluster_address = pattern.match(wsrep_cluster_address).groupdict()["prev_ip"]
-
- LOG.info("old wsrep_cluster_address = %s" % wsrep_cluster_address)
-
- if mode == "master":
- # refresh wsrep_cluster_address to null
- LOG.info("I'm being master, set wsrep_cluster_address to null")
- wsrep_cluster_address = ""
-
- elif mode == "backup":
- # refresh wsrep_cluster_address to master int ip
- hostname = ssh_get_hostname(ha_vip)
- wsrep_cluster_address = socket.gethostbyname(hostname)
- LOG.info("I'm being slave, set wsrep_cluster_address to master internal ip")
-
- LOG.info("new wsrep_cluster_address = %s" % wsrep_cluster_address)
- wsrep_cluster_address = "gcomm://%s" % wsrep_cluster_address
- config.set("mysqld", "wsrep_cluster_address", wsrep_cluster_address)
- with open(galera_path, 'wb') as fp:
- #config.write(sys.stdout)
- config.write(fp)
-
- os.system("service mysql restart")
- LOG.info("failover success!!!")
-
-if __name__ == "__main__":
- LOG.debug("call me: %s" % sys.argv)
- failover(sys.argv[1])
diff --git a/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg b/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg
index f1a2312c..8f026fa4 100644
--- a/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg
+++ b/deploy/adapters/ansible/roles/ha/templates/haproxy.cfg
@@ -36,6 +36,7 @@ listen proxy-glance_registry_cluster
listen proxy-glance_api_cluster
bind {{ internal_vip.ip }}:9292
+ bind {{ public_vip.ip }}:9292
option tcpka
option httpchk
option tcplog
@@ -94,6 +95,7 @@ listen proxy-keystone_public_internal_cluster
listen proxy-nova_compute_api_cluster
bind {{ internal_vip.ip }}:8774
+ bind {{ public_vip.ip }}:8774
mode tcp
option httpchk
option tcplog
@@ -104,6 +106,7 @@ listen proxy-nova_compute_api_cluster
listen proxy-nova_metadata_api_cluster
bind {{ internal_vip.ip }}:8775
+ bind {{ public_vip.ip }}:8775
option tcpka
option tcplog
balance source
@@ -113,6 +116,7 @@ listen proxy-nova_metadata_api_cluster
listen proxy-cinder_api_cluster
bind {{ internal_vip.ip }}:8776
+ bind {{ public_vip.ip }}:8776
mode tcp
option httpchk
option tcplog
@@ -121,6 +125,16 @@ listen proxy-cinder_api_cluster
server {{ host }} {{ ip }}:8776 weight 1 check inter 2000 rise 2 fall 5
{% endfor %}
+listen proxy-dashboarad
+ bind {{ public_vip.ip }}:80
+ option tcpka
+ option httpchk
+ option tcplog
+ balance source
+{% for host,ip in haproxy_hosts.items() %}
+ server {{ host }} {{ ip }}:80 weight 1 check inter 2000 rise 2 fall 5
+{% endfor %}
+
listen stats
mode http
bind 0.0.0.0:8888
diff --git a/deploy/adapters/ansible/roles/ha/templates/keepalived.conf b/deploy/adapters/ansible/roles/ha/templates/keepalived.conf
index f1e6db5d..a2e008a7 100644
--- a/deploy/adapters/ansible/roles/ha/templates/keepalived.conf
+++ b/deploy/adapters/ansible/roles/ha/templates/keepalived.conf
@@ -19,30 +19,24 @@ vrrp_instance internal_vip {
virtual_ipaddress {
{{ internal_vip.ip }}/{{ internal_vip.netmask }} dev {{ internal_vip.interface }}
}
+}
- notify_master "/usr/local/bin/notify.sh master"
- notify_backup "/usr/local/bin/notify.sh backup"
+vrrp_instance public_vip {
+ interface {{ network_cfg.public_vip.interface }}
+ virtual_router_id {{ vrouter_id_public }}
+ state BACKUP
+ nopreempt
+ preempt_delay 30
+ advert_int 1
+ priority 100
-}
+ authentication {
+ auth_type PASS
+ auth_pass 4321
+ }
-#vrrp_instance public_vip {
-# interface {{ network_cfg.public_vip.interface }}
-# virtual_router_id {{ vrouter_id_public }}
-# state BACKUP
-# nopreempt
-# preempt_delay 30
-# advert_int 1
-# priority 100
-#
-# authentication {
-# auth_type PASS
-# auth_pass 4321
-# }
-#
-# virtual_ipaddress {
-# {{ network_cfg.public_vip.ip }}/{{ network_cfg.public_vip.netmask }} dev {{ network_cfg.public_vip.interface }}
-# }
-#
-#}
-#
-# notify_backup "/usr/local/bin/notify.sh backup"
+ virtual_ipaddress {
+ {{ network_cfg.public_vip.ip }}/{{ network_cfg.public_vip.netmask }} dev {{ network_cfg.public_vip.interface }}
+ }
+
+}