From f5efcd1b2be058e4ab56c3d990541080003bcd89 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com> Date: Thu, 14 Sep 2023 15:56:41 +0300 Subject: [PATCH] etcd: expect 'is healthy' status in stdout or in stderr In certain scenarios (for example the old etcd version), even when a command executes without errors (.rc=0), the output may reside in stderr instead of stdout. Now we accommodate for 'is healthy' in either output stream. --- roles/etcd/tasks/main.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml index 716309186..5a4de3026 100644 --- a/roles/etcd/tasks/main.yml +++ b/roles/etcd/tasks/main.yml @@ -132,7 +132,9 @@ environment: ETCDCTL_API: "3" register: etcd_health_result - until: "'is healthy' in etcd_health_result.stdout" + until: > + 'is healthy' in etcd_health_result.stdout or + 'is healthy' in etcd_health_result.stderr retries: 10 delay: 10 changed_when: false @@ -140,7 +142,10 @@ - name: cluster health ansible.builtin.debug: - msg: "{{ etcd_health_result.stdout }}" + msg: > + {{ etcd_health_result.stdout + if etcd_health_result.stdout | length > 0 + else etcd_health_result.stderr }} when: not ansible_check_mode tags: etcd, etcd_start, etcd_status