From caf29091d1082c0252a731fc8f2118789437857d Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Wed, 29 Sep 2021 15:03:06 +0100
Subject: [PATCH] Allow automated distro upgrades

We run 'apt full-upgrade' whenever sources.list changes, so that the
rest of the playbook can execute with the new packages according to
float_debian_dist.

Fixes issue #117.
---
 roles/float-base/tasks/apt.yml | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/roles/float-base/tasks/apt.yml b/roles/float-base/tasks/apt.yml
index 4d72c468..01ac2231 100644
--- a/roles/float-base/tasks/apt.yml
+++ b/roles/float-base/tasks/apt.yml
@@ -49,6 +49,7 @@
   template:
     src: "sources.list.j2"
     dest: "/etc/apt/sources.list"
+  register: sources_list
 
 - name: Install package repositories
   apt_repository:
@@ -59,12 +60,22 @@
     - buster
     - bullseye
 
-- name: Run apt-get update
+- name: Run apt update
   apt:
     update_cache: yes
     cache_valid_time: '{{ 1800 if ansible_distribution_release == float_debian_dist else 1 }}'
   changed_when: false
 
+# If we're updating the distro, the first round of 'apt upgrade'
+# (staggered, to handle normal software upgrades) did not do anything,
+# but now we have to run 'apt full-upgrade' because we've just
+# switched sources.list, and we're expecting the rest of the playbook
+# to execute with the new float_debian_dist.
+- name: Run apt full-upgrade
+  apt:
+    upgrade: "full"
+  when: "sources_list.changed"
+
 # When testing, try to make dpkg faster by disabling fsync.
 - name: Speed up dpkg
   apt:
-- 
GitLab