Deploy rearchitected MusicMouse backend + web frontend

The app grew a python-backend/ and a web/ frontend, so pi_musicmouse no
longer matches it. Rework the role:

- Install a pinned uv and build the venv with Python 3.13; Raspbian
  Bookworm's python3 is 3.11 and the backend uses PEP 695 syntax.
- pip install python-backend/ instead of a requirements.txt, and take
  the systemd unit straight from the checkout so it can't drift.
- Build web/ on the control machine (no npm on the Pi) and rsync
  web/dist over. Chain the checkout -> install -> build -> sync -> restart
  steps through handlers so a run with no repo change does nothing.
- Per-host config files (config-<host>.yml); the schema now differs
  between a host with a real mouse and a display-only one.
- Version to deploy is per host (musicmouse_version), no default.

Add pi_kiosk: autologin user running startx with Firefox in kiosk mode
and no window manager, for a Pi with a monitor attached. Enabled by
mediapi_has_monitor, defaulting off.

Turn musicdolphin into a display-only instance: serial and audio
simulated, driven entirely through the kiosk page.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-19 17:58:51 +02:00
parent 2443a75871
commit 9b1d01115b
19 changed files with 337 additions and 33 deletions

View File

@@ -2,54 +2,111 @@
- name: Packages
ansible.builtin.apt:
name:
- python3
- python3-pip
- python3-vlc # also in venv - but this installs vlc + deps
- git
- libvlc5 # runtime lib python-vlc (installed into the venv by uv) binds against
- vlc-plugin-base
- alsa-utils
- samba
cache_valid_time: 7200
- name: Ensure uv install directory exists
ansible.builtin.file:
path: "/opt/uv-{{ pi_musicmouse_uv_version }}"
state: directory
mode: "0755"
- name: Download and extract uv {{ pi_musicmouse_uv_version }}
ansible.builtin.unarchive:
src: "https://github.com/astral-sh/uv/releases/download/{{ pi_musicmouse_uv_version }}/uv-aarch64-unknown-linux-gnu.tar.gz"
dest: "/opt/uv-{{ pi_musicmouse_uv_version }}"
remote_src: true
extra_opts: ["--strip-components=1"]
creates: "/opt/uv-{{ pi_musicmouse_uv_version }}/uv"
- name: Symlink uv/uvx into /usr/local/bin
ansible.builtin.file:
src: "/opt/uv-{{ pi_musicmouse_uv_version }}/{{ item }}"
dest: "/usr/local/bin/{{ item }}"
state: link
force: true
loop:
- uv
- uvx
- name: Checkout Musicmouse repo
ansible.builtin.git:
repo: "ssh://git@git.bauer.tech:2222/martin/musicmouse.git"
dest: "/opt/musicmouse"
version: "release/1.1"
repo: "{{ pi_musicmouse_repo }}"
dest: /opt/musicmouse
version: "{{ musicmouse_version }}"
accept_hostkey: true
- name: Create and update virtual env
ansible.builtin.pip:
requirements: /opt/musicmouse/espmusicmouse/host_driver/requirements.txt
virtualenv: /opt/musicmouse_venv
virtualenv_command: "/usr/bin/python3 -m venv"
force: true
notify: Reinstall musicmouse backend
- name: Create virtualenv with Python {{ pi_musicmouse_python_version }}
ansible.builtin.command:
cmd: "/usr/local/bin/uv venv --python {{ pi_musicmouse_python_version }} /opt/musicmouse/.venv"
creates: /opt/musicmouse/.venv/bin/python
- name: Create media directory
ansible.builtin.file:
path: /media/musicmouse
state: directory
mode: "0755"
- name: Install config file
ansible.builtin.copy:
src: config.yml
src: "{{ pi_musicmouse_config_file }}"
dest: /media/musicmouse/config.yml
mode: "0644"
- name: Install systemd service file
notify: Restart musicmouse
- name: Install systemd service file (from the checked-out repo, not a copy kept here)
ansible.builtin.copy:
src: musicmouse.service
dest: /etc/systemd/system/
src: /opt/musicmouse/python-backend/musicmouse.service
dest: /etc/systemd/system/musicmouse.service
mode: "0644"
remote_src: true
notify: Restart musicmouse
- name: Add script to autostart and start now
ansible.builtin.systemd:
name: musicmouse
state: restarted
state: started
enabled: "yes"
daemon_reload: "yes"
- name: Ensure local frontend build cache directory exists
ansible.builtin.file:
path: "{{ pi_musicmouse_build_cache }}/{{ musicmouse_version | regex_replace('/', '_') }}"
state: directory
mode: "0755"
delegate_to: localhost
become: false
- name: Checkout Musicmouse repo for frontend build (control machine)
ansible.builtin.git:
repo: "{{ pi_musicmouse_repo }}"
dest: "{{ pi_musicmouse_build_cache }}/{{ musicmouse_version | regex_replace('/', '_') }}"
version: "{{ musicmouse_version }}"
accept_hostkey: true
force: true
delegate_to: localhost
become: false
notify: Build frontend
- name: Samba setup
ansible.builtin.copy:
src: smb.conf
dest: /etc/samba/
mode: "0644"
- name: Restart samba
ansible.builtin.systemd:
name: smbd
state: restarted
enabled: "yes"
daemon_reload: "yes"
# manual steps:
# - set samba passwords with smbpasswd
# - copy music into /media/musicmouse (or via samba share)
# - upload host driver?
# - manual patching of hassclient necessary :( loop has to be passed in, to not use running_event_loop