music/trollibox: Run as a distinct user
This commit is contained in:
parent
e9f31417b7
commit
8e5b9f6b30
4 changed files with 22 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
||||||
music_audio_user: audio
|
music_audio_user: audio
|
||||||
music_audio_group: audio
|
music_audio_group: audio
|
||||||
music_librespot_user: librespot
|
music_librespot_user: librespot
|
||||||
|
music_trollibox_user: trollibox
|
||||||
|
|
||||||
music_pulse_server: /tmp/pipewire-pulse-socket
|
music_pulse_server: /tmp/pipewire-pulse-socket
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
state: restarted
|
state: restarted
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
|
||||||
- name: Restart trollibox
|
- name: restart trollibox
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: trollibox
|
name: trollibox
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
---
|
---
|
||||||
|
- name: Create trollibox user
|
||||||
|
user:
|
||||||
|
name: "{{ music_trollibox_user }}"
|
||||||
|
system: true
|
||||||
|
home: /var/lib/trollibox
|
||||||
|
|
||||||
- name: Install Trollibox config
|
- name: Install Trollibox config
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: trollibox.yaml
|
src: trollibox.yaml
|
||||||
|
@ -6,27 +12,29 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
notify: Restart trollibox
|
notify: restart trollibox
|
||||||
|
|
||||||
- name: Get latest Trollibox version from Github API
|
- name: Get latest Trollibox version from Github API
|
||||||
ansible.builtin.get_url:
|
uri:
|
||||||
url: "https://api.github.com/repos/polyfloyd/trollibox/releases/latest"
|
url: "https://api.github.com/repos/polyfloyd/trollibox/releases/latest"
|
||||||
dest: "/tmp/_ansible_trollibox_latest_release.json"
|
return_content: true
|
||||||
|
register: response
|
||||||
|
changed_when: false
|
||||||
|
check_mode: false
|
||||||
|
failed_when: "response is failed or 'json' not in response"
|
||||||
|
|
||||||
- name: Get download url
|
- name: Format trollibox latest version
|
||||||
ansible.builtin.shell:
|
set_fact:
|
||||||
cmd: cat /tmp/_ansible_trollibox_latest_release.json | jq .assets[] | select(.name
|
trollibox_version: "{{ response['json']['tag_name'] | trim('v') }}"
|
||||||
| contains("linux-amd64")) | .browser_download_url -r
|
|
||||||
register: "trollibox_download_url"
|
|
||||||
|
|
||||||
- name: Download Trollibox
|
- name: Download Trollibox
|
||||||
ansible.builtin.unarchive:
|
ansible.builtin.unarchive:
|
||||||
src: "{{ trollibox_download_url.stdout }}"
|
src: "https://github.com/polyfloyd/trollibox/releases/download/v{{ trollibox_version }}/trollibox-x86_64-unknown-linux-gnu.tar.gz"
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
dest: /usr/local/bin
|
dest: /usr/local/bin
|
||||||
include: [ trollibox ]
|
include: [ trollibox ]
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
notify: Restart trollibox
|
notify: restart trollibox
|
||||||
|
|
||||||
- name: Install service file
|
- name: Install service file
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
@ -35,7 +43,7 @@
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
notify: Restart trollibox
|
notify: restart trollibox
|
||||||
|
|
||||||
- name: Enable Trollibox
|
- name: Enable Trollibox
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
|
|
|
@ -10,8 +10,7 @@ Type=simple
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=2s
|
RestartSec=2s
|
||||||
ExecStart=/usr/local/bin/trollibox -conf /etc/trollibox.yaml
|
ExecStart=/usr/local/bin/trollibox -conf /etc/trollibox.yaml
|
||||||
User={{ music_audio_user }}
|
User={{ music_trollibox_user }}
|
||||||
Group={{ music_audio_user }}
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue