Skip to content

Commit

Permalink
(raspotify): Add role
Browse files Browse the repository at this point in the history
  • Loading branch information
thibmaek committed Jun 4, 2024
1 parent 16be7da commit 2550b46
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions roles/raspotify/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Output of `librespot -d ?` (https://github.com/dtcooper/raspotify/wiki/Basic-Setup-Guide#alsa-backend-default)
raspotify_sound_device: hw:CARD=Headphones,DEV=0
raspotify_device_type: speaker
raspotify_script_url: https://dtcooper.github.io/raspotify/install.sh
raspotify_config_file: /etc/raspotify/conf
34 changes: 34 additions & 0 deletions roles/raspotify/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: 'Download raspotify install script'
become: true
ansible.builtin.get_url:
url: '{{ raspotify_script_url }}'
dest: '{{ tmp_dir }}/raspotify.sh'
mode: 0755

- name: 'Install raspotify'
become: true
ansible.builtin.command: './raspotify.sh'
changed_when: false
args:
chdir: '{{ tmp_dir }}'

- name: 'Remove raspotify install script'
become: true
ansible.builtin.file:
path: '{{ tmp_dir }}/raspotify.sh'
state: absent

- name: 'Set sound device'
become: true
ansible.builtin.replace:
dest: '{{ raspotify_config_file }}'
regexp: '^#LIBRESPOT_DEVICE="default"'
replace: 'LIBRESPOT_DEVICE="{{ raspotify_sound_device }}"'

- name: 'Set device type'
become: true
ansible.builtin.replace:
dest: '{{ raspotify_config_file }}'
regexp: '^#LIBRESPOT_DEVICE_TYPE="speaker"'
replace: 'LIBRESPOT_DEVICE_TYPE="{{ raspotify_device_type }}"'

0 comments on commit 2550b46

Please sign in to comment.