From 050cc471d103c1c8f9dc6efffd31b2d6a1701718 Mon Sep 17 00:00:00 2001 From: Mateusz Mojsiejuk Date: Tue, 1 Sep 2026 19:10:23 +0200 Subject: [PATCH] role for official headless spotify-connect client --- README.md | 11 +++++ roles/spotify_soloist/handlers/main.yml | 15 ++++++ roles/spotify_soloist/tasks/main.yml | 48 +++++++++++++++++++ .../templates/spotify_soloist.service.j2 | 15 ++++++ 4 files changed, 89 insertions(+) create mode 100644 roles/spotify_soloist/handlers/main.yml create mode 100644 roles/spotify_soloist/tasks/main.yml create mode 100644 roles/spotify_soloist/templates/spotify_soloist.service.j2 diff --git a/README.md b/README.md index 4b142a3..6edd7b1 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,17 @@ by default in anonymous mode allowing anyone on your network to stream to your d | spotify_connect_name:| my-hifi | no | +## spotify-soloist +Installs & configures official spotify-connect compatible client +by default in anonymous mode allowing anyone on your network to stream to your device + + +| Variable name | Example | Mandatory | +| -------------------- |:-------------:| :----------:| +| spotify_soloist_api_key | | yes| +| spotify_connect_name:| my-hifi | no | + + ## roc_streaming Installs the roc sink modules for pulseaudio allowing streaming audio from any pulseaudio/pipewire sound server giving a apple air-share like streaming experience diff --git a/roles/spotify_soloist/handlers/main.yml b/roles/spotify_soloist/handlers/main.yml new file mode 100644 index 0000000..760453d --- /dev/null +++ b/roles/spotify_soloist/handlers/main.yml @@ -0,0 +1,15 @@ +--- +- name: Reload systemd + become: false + remote_user: media + ansible.builtin.systemd: + daemon_reload: true + scope: user + +- name: Restart Spotify soloist + become: false + remote_user: media + ansible.builtin.systemd: + service: spotify_soloist + state: restarted + scope: user diff --git a/roles/spotify_soloist/tasks/main.yml b/roles/spotify_soloist/tasks/main.yml new file mode 100644 index 0000000..190cc48 --- /dev/null +++ b/roles/spotify_soloist/tasks/main.yml @@ -0,0 +1,48 @@ +--- +- name: Deduce OS architecture + ansible.builtin.command: dpkg --print-architecture + register: spotify_soloist_arch + changed_when: false + check_mode: false + +- name: Fetch Spotify soloist + ansible.builtin.get_url: + url: https://soloist-builds.spotifycdn.com/soloist_release_{{ spotify_soloist_arch.stdout }}.tar.gz + dest: /usr/local/bin/spotify_soloist.tar.gz + owner: media + group: media + mode: '600' + +- name: Unarchive spotify soloist + ansible.builtin.unarchive: + src: /usr/local/bin/spotify_soloist.tar.gz + dest: /usr/local/bin/ + remote_src: true + when: not ansible_check_mode + +- name: Remove Spotify-soloist archive file + ansible.builtin.file: + path: /usr/local/bin/spotify_soloist.tar.gz + state: absent + when: not ansible_check_mode + +- name: Create Spotify soloist service + ansible.builtin.template: + src: spotify_soloist.service.j2 + dest: /home/media/.config/systemd/user/spotify_soloist.service + owner: media + group: media + mode: '600' + notify: Reload systemd + when: not ansible_check_mode + tags: create_soloist_service + +- name: Enable Spotify soloist service + become: false + remote_user: media + ansible.builtin.systemd: + name: spotify_soloist + state: started + enabled: true + scope: user + when: not ansible_check_mode diff --git a/roles/spotify_soloist/templates/spotify_soloist.service.j2 b/roles/spotify_soloist/templates/spotify_soloist.service.j2 new file mode 100644 index 0000000..49139f9 --- /dev/null +++ b/roles/spotify_soloist/templates/spotify_soloist.service.j2 @@ -0,0 +1,15 @@ +[Unit] +Description=Spotifys official headless spotify-connect client +Documentation=https://developer.spotify.com/documentation/soloist + +After=network-online.target +Wants=network-online.target + +[Service] +ExecStart=/usr/local/bin/soloist -k {{ spotify_soloist_api_key }} -n {% if spotify_connect_name is defined %}{{ spotify_connect_name }}{% else %}{{ inventory_hostname }}{% endif %} + +Restart=always +RestartSec=10 + +[Install] +WantedBy=default.target