From 3d405dfd52c0a5059cefd877fd578114bcdd912d Mon Sep 17 00:00:00 2001 From: Logan V Date: Sun, 6 Oct 2019 11:56:15 -0500 Subject: [PATCH] Improve compatibility with connection delegation In some cases when delegated hosts are used with connection plugins and variables are used in the ansible_host var, they can be resolved using the wrong node (the source of the delegated task, rather than the target of the delegated task), causing the connection plugin to run all of the mysql restarts on the same host, rather than delegating to the correct ansible_host. This minor fix improves compatibility in these situations so that ansible_host is set to the correct host, causing the task to run against the correct node. Depends-On: https://review.opendev.org/687142 Change-Id: I082f4920cc8366e3b1309c952a5104d3d63215e5 --- handlers/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/handlers/main.yml b/handlers/main.yml index 49c0cb9f..6dfcd80b 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -63,6 +63,8 @@ changed_when: start_new_cluster.rc == 3 register: start_new_cluster delegate_to: "{{ galera_server_bootstrap_node }}" + vars: + ansible_host: "{{ hostvars[galera_server_bootstrap_node]['ansible_host'] }}" run_once: true when: - not galera_cluster_ready | bool @@ -79,6 +81,8 @@ retries: 6 delay: 5 delegate_to: "{{ item }}" + vars: + ansible_host: "{{ hostvars[item]['ansible_host'] }}" when: - hostvars[item]['galera_cluster_ready'] is defined - hostvars[item]['galera_deployed'] | default(false) | bool