From f9b812a9825326360677783e7248120d11db8de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Esbj=C3=B8rn=20Engell?= Date: Tue, 19 Mar 2019 00:10:49 +0100 Subject: [PATCH] Haproxy: add support for track in wait_until_status (#53677) When haproxy is configured to track the status of a server using a server in another backend it will not report all status as expected. Using substring matching will solve this. The CSV will output the server status in the following way: MAINT: MAINT (via pxname/svname) UP: UP DOWN: DOWN Haproxy doc on trach: https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#5.2-track --- lib/ansible/modules/net_tools/haproxy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/net_tools/haproxy.py b/lib/ansible/modules/net_tools/haproxy.py index f7ee651fea..677eabf712 100644 --- a/lib/ansible/modules/net_tools/haproxy.py +++ b/lib/ansible/modules/net_tools/haproxy.py @@ -353,8 +353,9 @@ class HAProxy(object): state = self.get_state_for(pxname, svname) # We can assume there will only be 1 element in state because both svname and pxname are always set when we get here - if state[0]['status'] == status: - if not self._drain or (state[0]['scur'] == '0' and state == 'MAINT'): + # When using track we get a status like this: MAINT (via pxname/svname) so we need to do substring matching + if status in state[0]['status']: + if not self._drain or (state[0]['scur'] == '0' and 'MAINT' in state): return True else: time.sleep(self.wait_interval)