diff --git a/roles/raspotify/defaults/main.yaml b/roles/raspotify/defaults/main.yaml new file mode 100644 index 0000000..424fd70 --- /dev/null +++ b/roles/raspotify/defaults/main.yaml @@ -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 diff --git a/roles/raspotify/tasks/main.yaml b/roles/raspotify/tasks/main.yaml new file mode 100644 index 0000000..b780717 --- /dev/null +++ b/roles/raspotify/tasks/main.yaml @@ -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 }}"'