musicmouse_version pointed both hosts at rearchitect-backend, a branch that only ever existed on a laptop - so the previous commit's rework could never actually have run. Point each host at a deploy/<host> branch on the remote instead. Those branches are the deployment record: what is installed on that box right now, moved with a force-push when you mean to deploy. musicmouse (Kinderzimmer) is the reason this matters. It is in daily use and still runs the pre-rearchitecture backend out of /opt/musicmouse_venv and espmusicmouse/host_driver/main.py. That commit has no python-backend/ pyproject.toml, no python-backend/musicmouse.service and no web/ at all, so this role cannot install it - and a run would have force-checked-out incompatible code over a working device first and failed afterwards. Set mediapi_install_kidsmusic: false there and leave it alone; deploy/musicmouse records the commit that is installed, for rollback. Add a stat + fail right after the checkout so the same mistake stops with an explanation instead of failing three tasks deeper. Also in the role: - Install the typing game's curriculum next to config.yml. A config with a tippen: section refuses to start without it - curriculum_file is validated as must-exist - so musicdolphin's new config needs it present. - Stop clobbering config.yml. The app writes to it at runtime: parent mode patches the volume keys and the remote-control page rewrites the remote: block. A plain copy: undid that on every run. Install-once by default, with -e pi_musicmouse_force_config=true to push a change deliberately. - Fill out config-musicdolphin.yml against the current schema: library root and cache, an absolute static_dir (../web/dist would resolve to /media/web/dist from /media/musicmouse and silently serve nothing), tippen, and the volume range for a screen-driven instance. ha: is left commented out until the Wohnzimmer-oben entity ids are picked - the ones in the dev config are Arbeitszimmer. No mqtt: (it would publish a device of dead entities on a simulate-only host) and no lirc:/remote: (this host runs irserver, a serial daemon, not the lircd this speaks TCP to). The curriculum is a verbatim copy of app content, so exclude it from ansible-lint rather than reformat it away from its source. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
142 lines
4.6 KiB
YAML
142 lines
4.6 KiB
YAML
---
|
|
- name: Packages
|
|
ansible.builtin.apt:
|
|
name:
|
|
- 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: "{{ pi_musicmouse_repo }}"
|
|
dest: /opt/musicmouse
|
|
version: "{{ musicmouse_version }}"
|
|
accept_hostkey: true
|
|
force: true
|
|
notify: Reinstall musicmouse backend
|
|
|
|
- name: Check the checkout has the layout this role knows
|
|
ansible.builtin.stat:
|
|
path: /opt/musicmouse/python-backend/pyproject.toml
|
|
register: pi_musicmouse_pyproject
|
|
|
|
- name: Fail on a pre-rearchitecture checkout
|
|
ansible.builtin.fail:
|
|
msg: >-
|
|
{{ musicmouse_version }} has no python-backend/pyproject.toml, so it predates the
|
|
rearchitecture and this role cannot install it - the venv, the systemd unit and
|
|
the web/ build all live somewhere else on those commits. Point
|
|
musicmouse_version at a branch that has it (deploy/musicdolphin), or set
|
|
mediapi_install_kidsmusic to false for this host and leave whatever is installed
|
|
alone. Stopping here rather than failing three tasks deeper with the real reason
|
|
buried.
|
|
when: not pi_musicmouse_pyproject.stat.exists
|
|
|
|
- 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: "{{ pi_musicmouse_config_file }}"
|
|
dest: /media/musicmouse/config.yml
|
|
mode: "0644"
|
|
# Install-once: the app writes this file itself (parent mode's volume keys, the
|
|
# remote-control mapping). See pi_musicmouse_force_config in defaults.
|
|
force: "{{ pi_musicmouse_force_config }}"
|
|
notify: Restart musicmouse
|
|
|
|
- name: Install tippen curriculum
|
|
ansible.builtin.copy:
|
|
src: "{{ pi_musicmouse_curriculum_file }}"
|
|
dest: /media/musicmouse/tippen-curriculum.yml
|
|
mode: "0644"
|
|
when: pi_musicmouse_curriculum_file | length > 0
|
|
notify: Restart musicmouse
|
|
|
|
- name: Install systemd service file (from the checked-out repo, not a copy kept here)
|
|
ansible.builtin.copy:
|
|
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: 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: scripts/sync-library.sh in the app repo, which
|
|
# also carries the cover and analysis cache over (or use the samba share, and let
|
|
# the device spend the DSP time itself)
|