From 1efe0fe333ff869ea0a04ff87a11ff27a251560b Mon Sep 17 00:00:00 2001
From: Christian Berendt <berendt@betacloud-solutions.de>
Date: Tue, 18 Feb 2020 13:02:28 +0100
Subject: [PATCH] Avoid multiple haproxy restarts after reconfiguration

The haproxy role and the site.yml file calls the
haproxy-config role to provide configuration for individual
services.

If the configuration within a service changes, the haproxy
container is restarted.

If the configuration in n services changes, there will be n
restarts. This is not necessary, a restart at the end is
sufficient.

By removing the handler from the haproxy-config role and
using the listen parameter in the handler of the haproxy role,
the handler is executed only once.

Change-Id: I535fe67579fb748093bb4b30a6bd31b81e021a1b
Closes-Bug: #1864810
---
 ansible/roles/haproxy-config/handlers/main.yml | 17 -----------------
 ansible/roles/haproxy/handlers/main.yml        |  1 +
 2 files changed, 1 insertion(+), 17 deletions(-)
 delete mode 100644 ansible/roles/haproxy-config/handlers/main.yml

diff --git a/ansible/roles/haproxy-config/handlers/main.yml b/ansible/roles/haproxy-config/handlers/main.yml
deleted file mode 100644
index dc4b1305f2..0000000000
--- a/ansible/roles/haproxy-config/handlers/main.yml
+++ /dev/null
@@ -1,17 +0,0 @@
----
-- name: Restart haproxy container
-  become: true
-  kolla_docker:
-    action: "restart_container"
-    name: haproxy
-  when:
-    - kolla_action != "config"
-    - inventory_hostname in groups['haproxy']
-    - enable_haproxy | bool
-  notify:
-    - Waiting for haproxy to start
-
-- name: Waiting for haproxy to start
-  wait_for:
-    host: "{{ api_interface_address }}"
-    port: "{{ haproxy_stats_port }}"
diff --git a/ansible/roles/haproxy/handlers/main.yml b/ansible/roles/haproxy/handlers/main.yml
index 60fa5a03e3..cec9b97acf 100644
--- a/ansible/roles/haproxy/handlers/main.yml
+++ b/ansible/roles/haproxy/handlers/main.yml
@@ -18,6 +18,7 @@
     - service.enabled | bool
   notify:
     - Waiting for haproxy to start
+  listen: "Restart haproxy container"
 
 - name: Restart keepalived container
   vars: