Only rebuild the venv when the deployed commit changes

The previous fix made the install convergent but not idempotent: it keyed
"changed" off uv printing "Installed", and uv prints that every single run.
musicmouse is a local path dependency, so uv rebuilds and reinstalls it every
time regardless. Every ansible run therefore restarted the service and made it
rescan the whole library for nothing.

Decide from the device instead: the commit the checkout landed on, recorded in
the venv, plus whether the venv can import the package at all. That keeps the
convergence the handler lacked - an empty venv reinstalls even when the commit
matches - without touching anything on a run where nothing moved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-19 21:13:00 +02:00
parent 340eeb5433
commit 6fcc345a26
2 changed files with 39 additions and 7 deletions

View File

@@ -43,3 +43,7 @@ pi_musicmouse_force_config: false
# section will not start without it - curriculum_file is validated as must-exist. Set to
# "" for a host whose config has no tippen section.
pi_musicmouse_curriculum_file: "tippen-curriculum.yml"
# The commit the checkout task actually landed on, used to decide whether the venv
# needs rebuilding. Empty under --check, where the git task reports without writing.
pi_musicmouse_commit: "{{ pi_musicmouse_checkout.after | default('') }}"