From 13aa32278ad78ba42fb94f8fce9490a00ddbe71a Mon Sep 17 00:00:00 2001 From: yangsenzk <116810037+yangsenzk@users.noreply.github.com> Date: Fri, 14 Jul 2023 12:43:29 +0800 Subject: [PATCH] bugfix: fix grep command without -w option causing prefix matched while adding one etcd member (#10291) --- 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 3fdedccac..fe53dd535 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 205549bad..d627b2663 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 b3d8e013c..b60a9df9a 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 -- GitLab