From aa6391aa928cb936acc1e82ce750e1389ad69831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Sat, 17 Feb 2024 22:22:50 +0100 Subject: [PATCH] fix remote nodes bind interface lookup --- templates/etc/my.cnf.d/server.cnf.j2 | 2 +- templates/etc/my.cnf.d/server.cnf.temp.j2 | 2 +- templates/etc/mysql/conf.d/galera.cnf.j2 | 2 +- templates/etc/mysql/conf.d/galera.cnf.temp.j2 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/etc/my.cnf.d/server.cnf.j2 b/templates/etc/my.cnf.d/server.cnf.j2 index fd83374..4e8339e 100644 --- a/templates/etc/my.cnf.d/server.cnf.j2 +++ b/templates/etc/my.cnf.d/server.cnf.j2 @@ -48,7 +48,7 @@ wsrep_provider={{ galera_wsrep_provider }} wsrep_cluster_name="{{ galera_cluster_name }}" {% set _galera_cluster_node_addresses = [] %} {% for node in galera_cluster_nodes %} -{% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ galera_cluster_bind_interface]['ipv4']['address']) | mandatory ) %} +{% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ hostvars[node]['galera_cluster_bind_interface']|default(galera_cluster_bind_interface)]['ipv4']['address']) | mandatory ) %} {% endfor %} wsrep_cluster_address="{{ 'gcomm://' ~ _galera_cluster_node_addresses | map('ansible.utils.ipwrap') | list | join(',') }}" # To start failed cluster comment out above and uncomment below...Once cluster is started revert changes and restart mysql on main node where change was made diff --git a/templates/etc/my.cnf.d/server.cnf.temp.j2 b/templates/etc/my.cnf.d/server.cnf.temp.j2 index a3658d5..aac0364 100644 --- a/templates/etc/my.cnf.d/server.cnf.temp.j2 +++ b/templates/etc/my.cnf.d/server.cnf.temp.j2 @@ -48,7 +48,7 @@ wsrep_provider={{ galera_wsrep_provider }} wsrep_cluster_name="{{ galera_cluster_name }}" {% set _galera_cluster_node_addresses = [] %} {% for node in galera_cluster_nodes %} -{% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ galera_cluster_bind_interface]['ipv4']['address']) | mandatory ) %} +{% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ hostvars[node]['galera_cluster_bind_interface']|default(galera_cluster_bind_interface)]['ipv4']['address']) | mandatory ) %} {% endfor %} #wsrep_cluster_address="{{ 'gcomm://' ~ _galera_cluster_node_addresses | map('ansible.utils.ipwrap') | list | join(',') }}" # To start failed cluster comment out above and uncomment below...Once cluster is started revert changes and restart mysql on main node where change was made diff --git a/templates/etc/mysql/conf.d/galera.cnf.j2 b/templates/etc/mysql/conf.d/galera.cnf.j2 index fd83374..4e8339e 100644 --- a/templates/etc/mysql/conf.d/galera.cnf.j2 +++ b/templates/etc/mysql/conf.d/galera.cnf.j2 @@ -48,7 +48,7 @@ wsrep_provider={{ galera_wsrep_provider }} wsrep_cluster_name="{{ galera_cluster_name }}" {% set _galera_cluster_node_addresses = [] %} {% for node in galera_cluster_nodes %} -{% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ galera_cluster_bind_interface]['ipv4']['address']) | mandatory ) %} +{% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ hostvars[node]['galera_cluster_bind_interface']|default(galera_cluster_bind_interface)]['ipv4']['address']) | mandatory ) %} {% endfor %} wsrep_cluster_address="{{ 'gcomm://' ~ _galera_cluster_node_addresses | map('ansible.utils.ipwrap') | list | join(',') }}" # To start failed cluster comment out above and uncomment below...Once cluster is started revert changes and restart mysql on main node where change was made diff --git a/templates/etc/mysql/conf.d/galera.cnf.temp.j2 b/templates/etc/mysql/conf.d/galera.cnf.temp.j2 index 6dfaecb..1e1be9d 100644 --- a/templates/etc/mysql/conf.d/galera.cnf.temp.j2 +++ b/templates/etc/mysql/conf.d/galera.cnf.temp.j2 @@ -48,7 +48,7 @@ wsrep_provider={{ galera_wsrep_provider }} wsrep_cluster_name="{{ galera_cluster_name }}" {% set _galera_cluster_node_addresses = [] %} {% for node in galera_cluster_nodes %} -{% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ galera_cluster_bind_interface]['ipv4']['address']) | mandatory ) %} +{% set _ = _galera_cluster_node_addresses.append( hostvars[node]['galera_cluster_bind_address'] | default(hostvars[node]['ansible_' ~ hostvars[node]['galera_cluster_bind_interface']|default(galera_cluster_bind_interface)]['ipv4']['address']) | mandatory ) %} {% endfor %} #wsrep_cluster_address="{{ 'gcomm://' ~ _galera_cluster_node_addresses | map('ansible.utils.ipwrap') | list | join(',') }}" # To start failed cluster comment out above and uncomment below...Once cluster is started revert changes and restart mysql on main node where change was made