From 8f194e50a0f95ff21f94afdb9581b19e00ef2571 Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Wed, 8 Jul 2015 06:03:07 +0000 Subject: [PATCH] Fixes an issue with AIO and galera clusters AIO nodes had an address in the gcomm list which would prevent AIO containers from starting appropriately. Change-Id: I6db8c831ef9f9c0348748eb9539db326dc0df048 Closes-Bug: #1472481 --- ansible/roles/database/tasks/main.yml | 7 +++++++ ansible/roles/database/tasks/register.yml | 2 +- ansible/roles/database/tasks/start.yml | 4 ++-- ansible/roles/database/templates/galera.cnf.j2 | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ansible/roles/database/tasks/main.yml b/ansible/roles/database/tasks/main.yml index c7474dde55..c13e4eb0a2 100644 --- a/ansible/roles/database/tasks/main.yml +++ b/ansible/roles/database/tasks/main.yml @@ -5,9 +5,16 @@ - include: start.yml +# We use register as a test to see whether the database is active and ready to +# communicate. This run on all hosts that have a database and attempts to talk +# to the local database rather than the vip, - include: register.yml # This will restart the container we initially used to bootstrap the cluster to # make it match the other containers environment-wise. This also prevents a # change from showing up when rerunning the playbooks - include: start.yml + +# Since the last start.yml may have recreated some containers we must wait and +# check the health again to ensure the hosts are active. +- include: register.yml diff --git a/ansible/roles/database/tasks/register.yml b/ansible/roles/database/tasks/register.yml index ba6021090d..c7382ff88b 100644 --- a/ansible/roles/database/tasks/register.yml +++ b/ansible/roles/database/tasks/register.yml @@ -1,7 +1,7 @@ --- - name: Creating haproxy mysql user mysql_user: - login_host: "{{ database_address }}" + login_host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}" login_user: "{{ database_user }}" login_password: "{{ database_password }}" name: "haproxy" diff --git a/ansible/roles/database/tasks/start.yml b/ansible/roles/database/tasks/start.yml index e60d49d4e1..fcddb9e0ca 100644 --- a/ansible/roles/database/tasks/start.yml +++ b/ansible/roles/database/tasks/start.yml @@ -9,5 +9,5 @@ - "{{ node_config_directory }}/mariadb/:/opt/kolla/mariadb/:ro" container_volumes_from: - "mariadb_data" - when: delegate_host != 'None' or - ( delegate_host == 'None' and inventory_hostname != groups['database'][0]) + when: delegate_host != 'None' or (groups['database'] | length) == 1 or + ( delegate_host == 'None' and inventory_hostname != groups['database'][0] ) diff --git a/ansible/roles/database/templates/galera.cnf.j2 b/ansible/roles/database/templates/galera.cnf.j2 index 9d9d725d4c..5f3dbbda04 100644 --- a/ansible/roles/database/templates/galera.cnf.j2 +++ b/ansible/roles/database/templates/galera.cnf.j2 @@ -8,7 +8,7 @@ query_cache_type=0 innodb_log_file_size=48M wsrep_provider=/usr/lib64/galera/libgalera_smm.so -wsrep_cluster_address=gcomm://{% for host in groups['database'] %}{{ hostvars[host]['ansible_hostname'] }}{% if not loop.last %},{% endif %}{% endfor %} +wsrep_cluster_address=gcomm://{% if (groups['database'] | length) > 1 %}{% for host in groups['database'] %}{{ hostvars[host]['ansible_hostname'] }}{% if not loop.last %},{% endif %}{% endfor %}{% endif %} wsrep_cluster_name="{{ database_cluster_name }}" wsrep_node_address={{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}