From 68d547099a19bcd2fee16847f6e5f2d3891452f9 Mon Sep 17 00:00:00 2001
From: Georg Krause <mail@georg-krause.net>
Date: Wed, 16 Aug 2023 14:20:21 +0200
Subject: [PATCH] feat: Allow to migrate to the new installation method for
 ansible

---
 upgrade.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/upgrade.sh b/upgrade.sh
index 6747fe9..822f158 100755
--- a/upgrade.sh
+++ b/upgrade.sh
@@ -49,6 +49,19 @@ yesno_prompt() {
 }
 
 do_upgrade() {
+    echo '[Check Ansible installation]'
+    if [ ! -f "$ansible_bin_path/ansible" ]; then
+      echo "To make the installation more future proof, we changed how ansible gets installed and now install it in its own venv."
+      yesno_prompt proceed 'Do you want to migrate to the new ansible installation method?' 'yes'
+      if [ "$proceed" = "false" ]; then
+          ansible_bin_path="$HOME/.local/bin"
+      else
+          apt-get install -y python3-venv
+          python3 -m venv $ansible_venv_path
+          $ansible_venv_path/bin/pip3 install --upgrade pip
+          $ansible_venv_path/bin/pip3 install ansible=="$ansible_version"
+      fi
+    fi
     echo '[Beginning upgrade]'
     playbook_path="$ansible_conf_path/playbook.yml"
     echo "[1/$total_steps] Retrieving currently installed version from $playbook_path"
-- 
GitLab