From c20b3970828115169910dd1e3491b6d6c4a72792 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Fri, 11 Mar 2022 10:00:49 +0000
Subject: [PATCH] Avoid text file busy when upgrading etcd binary

---
 roles/etcd/tasks/install_from_github.yml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/roles/etcd/tasks/install_from_github.yml b/roles/etcd/tasks/install_from_github.yml
index 2afcc8e..5bdcad8 100644
--- a/roles/etcd/tasks/install_from_github.yml
+++ b/roles/etcd/tasks/install_from_github.yml
@@ -33,6 +33,11 @@
     dest: /tmp/etcd.tar.gz
   when: do_install_etcd
 
+# Avoid 'text file busy' when copying over running binary.
+- name: Move old etcd binary out of the way
+  shell: "mv -f /usr/bin/etcd /usr/bin/etcd.old"
+  when: "do_install_etcd and etcd_bin.stat.exists"
+
 # We really want to use 'tar' here and not unarchive because we need
 # --strip-components.
 - name: Extract etcd binary and install contents
-- 
GitLab