diff --git a/roles/etcd/tasks/install_from_github.yml b/roles/etcd/tasks/install_from_github.yml index ba9ecb993c1ee096370bd8cdac5fd72537e3f623..2afcc8ec8b2e9585e07bba8e6edc7e89a44c387f 100644 --- a/roles/etcd/tasks/install_from_github.yml +++ b/roles/etcd/tasks/install_from_github.yml @@ -20,11 +20,18 @@ path: /usr/bin/etcd register: etcd_bin +- shell: "/usr/bin/etcd --version | awk '/^etcd/ {print $3}'" + when: etcd_bin.stat.exists + register: etcd_current_version + +- set_fact: + do_install_etcd: "{{ not etcd_bin.stat.exists or etcd_current_version != etcd_version }}" + - name: Download etcd binary get_url: url: https://storage.googleapis.com/etcd/v{{ etcd_version }}/etcd-v{{ etcd_version }}-linux-{{ etcd_binary_arch }}.tar.gz dest: /tmp/etcd.tar.gz - when: not etcd_bin.stat.exists + when: do_install_etcd # We really want to use 'tar' here and not unarchive because we need # --strip-components. @@ -32,7 +39,7 @@ shell: "tar -C /tmp -xzf /tmp/etcd.tar.gz --strip-components=1 && cp /tmp/etcd /tmp/etcdctl /usr/bin/" args: warn: false - when: not etcd_bin.stat.exists + when: do_install_etcd - name: Create etcd group group: