mariadb: use add_host to include inactive hosts in shard grouping

In case of running mariadb role with --limit the group_by module will only include the limited hosts and other hosts that are not limited by ansible will not be included.
Using add_host will add all hosts in mariadb group to their shards group

Signed-off-by: Seena Fallah <seenafallah@gmail.com>
Change-Id: I1331698e313bd714a16fc35f38fb579d75b56370
Closes-Bug: #1947589
This commit is contained in:
Seena Fallah 2021-10-16 22:34:21 +03:30 committed by Radosław Piliszek
parent f98000c98a
commit 68cd2a0553
4 changed files with 13 additions and 5 deletions

View File

@ -377,6 +377,9 @@ mariadb_clustercheck_port: "4569"
mariadb_monitor_user: "haproxy"
mariadb_default_database_shard_id: 0
mariadb_default_database_shard_hosts: "{% set default_shard = [] %}{% for host in groups['mariadb'] %}{% if hostvars[host]['mariadb_shard_id'] is not defined or hostvars[host]['mariadb_shard_id'] == mariadb_default_database_shard_id %}{{ default_shard.append(host) }}{% endif %}{% endfor %}{{ default_shard }}"
mariadb_shard_id: "{{ mariadb_default_database_shard_id }}"
mariadb_shard_name: "shard_{{ mariadb_shard_id }}"
mariadb_shard_group: "mariadb_{{ mariadb_shard_name }}"
mariadb_loadbalancer: "haproxy"
masakari_api_port: "15868"

View File

@ -123,7 +123,4 @@ enable_mariadb_clustercheck: "{{ enable_haproxy }}"
####################
# Sharding
####################
mariadb_shard_id: "{{ mariadb_default_database_shard_id }}"
mariadb_shard_name: "shard_{{ mariadb_shard_id }}"
mariadb_shard_group: "mariadb_{{ mariadb_shard_name }}"
mariadb_shard_database_user: "{% if mariadb_loadbalancer == 'haproxy' %}{{ database_user }}{% else %}root_{{ mariadb_shard_name }}{% endif %}"

View File

@ -1,7 +1,9 @@
---
- name: Group MariaDB hosts based on shards
group_by:
key: "{{ mariadb_shard_group }}"
add_host:
name: "{{ item }}"
groups: "{{ hostvars[item]['mariadb_shard_group'] }}"
loop: "{{ groups['mariadb'] }}"
changed_when: false
- include_tasks: "{{ kolla_action }}.yml"

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes the generation of ``wsrep_cluster_address`` in ``galera.cnf``
when ``--limit`` is used while deploying MariaDB nodes.
`LP#1947589 <https://bugs.launchpad.net/kolla-ansible/+bug/1947589>`__