diff --git a/changelogs/fragments/8100-haproxy-drain-fails-on-down-backend.yml b/changelogs/fragments/8100-haproxy-drain-fails-on-down-backend.yml new file mode 100644 index 0000000000..58f1478914 --- /dev/null +++ b/changelogs/fragments/8100-haproxy-drain-fails-on-down-backend.yml @@ -0,0 +1,2 @@ +bugfixes: + - "haproxy - fix an issue where HAProxy could get stuck in DRAIN mode when the backend was unreachable (https://github.com/ansible-collections/community.general/issues/8092)." diff --git a/plugins/modules/haproxy.py b/plugins/modules/haproxy.py index 05f52d55c8..cbaa438334 100644 --- a/plugins/modules/haproxy.py +++ b/plugins/modules/haproxy.py @@ -343,7 +343,7 @@ class HAProxy(object): if state is not None: self.execute(Template(cmd).substitute(pxname=backend, svname=svname)) - if self.wait: + if self.wait and not (wait_for_status == "DRAIN" and state == "DOWN"): self.wait_until_status(backend, svname, wait_for_status) def get_state_for(self, pxname, svname):