From d19e6dec7a1931659c35582edcce048c3472a20b Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Mon, 20 Feb 2017 17:17:15 +0300 Subject: [PATCH] speed up etcd preupgrade check --- roles/etcd/tasks/pre_upgrade.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/roles/etcd/tasks/pre_upgrade.yml b/roles/etcd/tasks/pre_upgrade.yml index eb17e9871..d498a0336 100644 --- a/roles/etcd/tasks/pre_upgrade.yml +++ b/roles/etcd/tasks/pre_upgrade.yml @@ -34,6 +34,11 @@ command: "{{ docker_bin_dir }}/docker rm -f {{item}}" with_items: "{{etcd_proxy_container.stdout_lines}}" +- name: "Pre-upgrade | see if etcdctl is installed" + stat: + path: "{{ bin_dir }}/etcdctl" + register: etcdctl_installed + - name: "Pre-upgrade | check if member list is non-SSL" command: "{{ bin_dir }}/etcdctl --no-sync --peers={{ etcd_access_addresses | regex_replace('https','http') }} member list" register: etcd_member_list @@ -41,6 +46,7 @@ delay: 3 until: etcd_member_list.rc != 2 run_once: true + when: etcdctl_installed.stat.exists failed_when: false - name: "Pre-upgrade | change peer names to SSL" @@ -48,4 +54,4 @@ {{ bin_dir }}/etcdctl --no-sync --peers={{ etcd_access_addresses | regex_replace('https','http') }} member list | awk -F"[: =]" '{print "{{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses | regex_replace('https','http') }} member update "$1" https:"$7":"$8}' | bash run_once: true - when: 'etcd_member_list.rc == 0 and "http://" in etcd_member_list.stdout' + when: 'etcdctl_installed.stat.exists and etcd_member_list.rc == 0 and "http://" in etcd_member_list.stdout'