Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions roles/spotify_soloist/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
register: spotify_soloist_arch
changed_when: false
check_mode: false
tags: argh

- name: Check if Spotify arch is compatible
ansible.builtin.fail:
msg: Seems no binary for your Architecture is available from Spotify
when: spotify_soloist_arch.stdout not in spotify_soloist_supported_arches
tags: argh

- name: Fetch Spotify soloist
ansible.builtin.get_url:
Expand All @@ -17,6 +24,7 @@
ansible.builtin.unarchive:
src: /usr/local/bin/spotify_soloist.tar.gz
dest: /usr/local/bin/
include: soloist
remote_src: true
when: not ansible_check_mode

Expand Down Expand Up @@ -46,3 +54,48 @@
enabled: true
scope: user
when: not ansible_check_mode

- name: Template Spotify soloist download service
ansible.builtin.template:
src: spotify_soloist_reinstall.service.j2
dest: /etc/systemd/system/spotify_soloist_reinstall.service
owner: media
group: media
mode: '600'
when: not ansible_check_mode
tags: create_soloist_service

- name: Template Spotify soloist download restart script
ansible.builtin.template:
src: templates/soloist_refresh.sh.j2
dest: /usr/local/bin/soloist_refresh.sh
owner: root
group: root
mode: '700'
when: not ansible_check_mode
notify: Reload systemd
tags: argh

- name: Template Spotify soloist download timer and service
ansible.builtin.template:
src: "templates/{{ item }}"
dest: /etc/systemd/system/{{ item|regex_replace(".j2","") }}
owner: root
group: root
mode: '600'
when: not ansible_check_mode
notify: Reload systemd
loop:
- "spotify_soloist_reinstall.timer.j2"
- "spotify_soloist_reinstall.service.j2"
tags: argh

- name: Enable Schedule soloist download timer
become: true
ansible.builtin.systemd:
name: spotify_soloist_reinstall.timer
state: started
enabled: true
when: not ansible_check_mode
tags: argh
notify: Reload systemd
15 changes: 15 additions & 0 deletions roles/spotify_soloist/templates/soloist_refresh.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail

/usr/bin/curl --location \
--output-dir /tmp/ \
--silent \
--no-buffer \
--remote-name {{ spotify_soloist_download_url }}{{ spotify_soloist_arch.stdout }}.tar.gz

/usr/bin/tar -C /usr/local/bin/ \
-xzvf \
/tmp/soloist_release_{{ spotify_soloist_arch.stdout }}.tar.gz \
--get soloist

/usr/bin/systemctl --user -M media@ restart spotify_soloist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Unit]
Description=Download and replace and restart spotify soloist binary

[Service]
Type=oneshot

ExecStart=/usr/local/bin/soloist_refresh.sh
12 changes: 12 additions & 0 deletions roles/spotify_soloist/templates/spotify_soloist_reinstall.timer.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=trigger soloist re-downloda and re-start

[Timer]

# Run monthly with some flex
OnCalendar=Mon *-*-01..07 10:00:00
AcuracySec=7
Persistent=true

[Install]
WantedBy=timers.target
8 changes: 8 additions & 0 deletions roles/spotify_soloist/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

spotify_soloist_download_url: "https://soloist-builds.spotifycdn.com/soloist_release_"

spotify_soloist_supported_arches:
- arm64
- arm32
- x86
Loading