From 639a833c745cb57a5730621d5043268528a26137 Mon Sep 17 00:00:00 2001 From: yangzhengkun Date: Thu, 13 Jul 2023 10:16:27 +0800 Subject: [PATCH] bugfix: fix grep command without -w option causing prefix matched while adding one etcd member --- roles/etcd/tasks/configure.yml | 4 ++-- roles/etcd/tasks/join_etcd-events_member.yml | 2 +- roles/etcd/tasks/join_etcd_member.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/etcd/tasks/configure.yml b/roles/etcd/tasks/configure.yml index 3fdedccac4d..fe53dd535d8 100644 --- a/roles/etcd/tasks/configure.yml +++ b/roles/etcd/tasks/configure.yml @@ -130,7 +130,7 @@ ETCDCTL_ENDPOINTS: "{{ etcd_events_access_addresses }}" - name: Configure | Check if member is in etcd cluster - shell: "{{ bin_dir }}/etcdctl member list | grep -q {{ etcd_access_address }}" + shell: "{{ bin_dir }}/etcdctl member list | grep -w -q {{ etcd_access_address }}" register: etcd_member_in_cluster ignore_errors: true # noqa ignore-errors changed_when: false @@ -146,7 +146,7 @@ ETCDCTL_ENDPOINTS: "{{ etcd_access_addresses }}" - name: Configure | Check if member is in etcd-events cluster - shell: "{{ bin_dir }}/etcdctl member list | grep -q {{ etcd_access_address }}" + shell: "{{ bin_dir }}/etcdctl member list | grep -w -q {{ etcd_access_address }}" register: etcd_events_member_in_cluster ignore_errors: true # noqa ignore-errors changed_when: false diff --git a/roles/etcd/tasks/join_etcd-events_member.yml b/roles/etcd/tasks/join_etcd-events_member.yml index 205549badb3..d627b266379 100644 --- a/roles/etcd/tasks/join_etcd-events_member.yml +++ b/roles/etcd/tasks/join_etcd-events_member.yml @@ -26,7 +26,7 @@ {%- endfor -%} - name: Join Member | Ensure member is in etcd-events cluster - shell: "set -o pipefail && {{ bin_dir }}/etcdctl member list | grep {{ etcd_events_access_address }} >/dev/null" + shell: "set -o pipefail && {{ bin_dir }}/etcdctl member list | grep -w {{ etcd_events_access_address }} >/dev/null" args: executable: /bin/bash register: etcd_events_member_in_cluster diff --git a/roles/etcd/tasks/join_etcd_member.yml b/roles/etcd/tasks/join_etcd_member.yml index b3d8e013c7f..b60a9df9a0f 100644 --- a/roles/etcd/tasks/join_etcd_member.yml +++ b/roles/etcd/tasks/join_etcd_member.yml @@ -27,7 +27,7 @@ {%- endfor -%} - name: Join Member | Ensure member is in etcd cluster - shell: "set -o pipefail && {{ bin_dir }}/etcdctl member list | grep {{ etcd_access_address }} >/dev/null" + shell: "set -o pipefail && {{ bin_dir }}/etcdctl member list | grep -w {{ etcd_access_address }} >/dev/null" args: executable: /bin/bash register: etcd_member_in_cluster