188 lines
4.5 KiB
YAML
188 lines
4.5 KiB
YAML
---
|
|
# The home-server project produces a multi-purpose setup using Ansible.
|
|
# Copyright © 2018 Y. Gablin, under the GPL-3.0-or-later license.
|
|
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
|
|
|
|
### UPSTREAM BEGIN ⇒ ###
|
|
- name: pull prerequisites from upstream
|
|
include_role: name=etckeeper.inc allow_duplicates=true tasks_from=upstream.yml
|
|
vars:
|
|
msg: media player
|
|
### ⇐ UPSTREAM BEGIN ###
|
|
|
|
- name: install software
|
|
package:
|
|
name: "{{item}}"
|
|
with_items:
|
|
- minidlna
|
|
- kodi
|
|
- kodi-addons-audioencoder
|
|
- kodi-addon-inputstream-adaptive
|
|
- lxdm
|
|
- python-pycryptodome
|
|
|
|
- name: create the Kodi user
|
|
user:
|
|
name: "{{kodi_user}}"
|
|
createhome: true
|
|
home: "{{kodi_data}}"
|
|
system: true
|
|
groups:
|
|
- users
|
|
- uucp
|
|
- lock
|
|
|
|
### UPSTREAM END ⇒ ###
|
|
- name: merge upstream
|
|
include_role: name=etckeeper.inc allow_duplicates=true tasks_from=merge.yml
|
|
vars:
|
|
msg: media player
|
|
### ⇐ UPSTREAM END ###
|
|
|
|
- name: ensure ownership of minidlna directory
|
|
file:
|
|
path: /var/lib/minidlna
|
|
state: directory
|
|
owner: minidlna
|
|
group: minidlna
|
|
|
|
- name: disable the default media_dir
|
|
lineinfile:
|
|
path: /etc/minidlna.conf
|
|
backrefs: true
|
|
regexp: '^(media_dir=/opt.*)$'
|
|
line: '#\1'
|
|
|
|
- name: send the minidlna configuration
|
|
blockinfile:
|
|
path: /etc/minidlna.conf
|
|
marker: '# {mark} {{nickname}} configuration'
|
|
block: "{{media_minidlna_conf}}"
|
|
insertbefore: BOF
|
|
notify:
|
|
- restart minidlna.service
|
|
|
|
- name: increase the number of allowed inotify watches
|
|
copy:
|
|
content: |
|
|
fs.inotify.max_user_watches=65536
|
|
dest: /etc/sysctl.d/max_user_watches.conf
|
|
mode: 0600
|
|
notify:
|
|
- enforce max_user_watches limit
|
|
- restart minidlna.service
|
|
|
|
- name: prepare to override minidlna systemd settings
|
|
file:
|
|
name: /etc/systemd/system/minidlna.service.d
|
|
state: directory
|
|
mode: 0755
|
|
|
|
- name: override minidlna systemd settings
|
|
copy:
|
|
content: |
|
|
[Unit]
|
|
Requires=nslcd.service
|
|
After=nslcd.service
|
|
[Service]
|
|
DynamicUser=no
|
|
CacheDirectory=
|
|
Group={{media_group}}
|
|
dest: /etc/systemd/system/minidlna.service.d/{{nickname}}.conf
|
|
mode: 0644
|
|
notify:
|
|
- restart minidlna.service
|
|
|
|
- name: enable minidlna.service
|
|
systemd:
|
|
daemon_reload: true
|
|
name: minidlna.service
|
|
enabled: true
|
|
|
|
- name: disable DPMS for the sake of Kodi
|
|
copy:
|
|
content: |
|
|
Section "Extensions"
|
|
Option "DPMS" "Disable"
|
|
EndSection
|
|
dest: "/etc/X11/xorg.conf.d/10-{{nickname}}-kodi.conf"
|
|
mode: 0644
|
|
|
|
- name: enable the kodi X11 session
|
|
copy:
|
|
content: |
|
|
[Desktop]
|
|
Session=kodi
|
|
dest: "{{kodi_data}}/.dmrc"
|
|
mode: 0644
|
|
|
|
- name: autologin kodi on lxdm
|
|
lineinfile:
|
|
path: /etc/lxdm/lxdm.conf
|
|
regexp: "^autologin="
|
|
line: "autologin={{kodi_user}}"
|
|
insertafter: "^\\[base\\]"
|
|
|
|
- name: stop lxdm after kodi quits
|
|
lineinfile:
|
|
path: /etc/lxdm/PostLogout
|
|
regexp: "systemctl stop lxdm"
|
|
line: "sudo /usr/bin/systemctl stop lxdm.service"
|
|
insertafter: EOF
|
|
|
|
- name: ensure stopping lxdm works
|
|
lineinfile:
|
|
path: /etc/sudoers
|
|
regexp: "systemctl stop lxdm"
|
|
line: "ALL ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop lxdm.service"
|
|
insertafter: EOF
|
|
|
|
- name: prepare to override lxdm systemd settings
|
|
file:
|
|
name: /etc/systemd/system/lxdm.service.d
|
|
state: directory
|
|
mode: 0755
|
|
|
|
- name: override lxdm systemd settings
|
|
copy:
|
|
content: |
|
|
[Unit]
|
|
Description=Kodi on-demand
|
|
Conflicts=kodi.socket
|
|
[Service]
|
|
ProtectSystem=full
|
|
ReadWriteDirectories={{kodi_data}}
|
|
# the client has 10 seconds to stop sending network packets to the socket
|
|
ExecStopPost=/usr/bin/bash -c "/usr/bin/sleep 10s; exec /usr/bin/systemctl --no-block start lxdm.socket"
|
|
Restart=no
|
|
dest: /etc/systemd/system/lxdm.service.d/{{nickname}}.conf
|
|
mode: 0644
|
|
|
|
- name: set socket activation for kodi
|
|
copy:
|
|
content: |
|
|
[Unit]
|
|
Conflicts=lxdm.service
|
|
[Socket]
|
|
ListenStream=8080
|
|
[Install]
|
|
WantedBy=sockets.target
|
|
dest: /etc/systemd/system/lxdm.socket
|
|
mode: 0644
|
|
notify:
|
|
- restart lxdm.socket
|
|
|
|
- name: enable lxdm.socket
|
|
systemd:
|
|
daemon_reload: true
|
|
name: lxdm.socket
|
|
enabled: true
|
|
|
|
### LOCAL COMMIT ⇒ ###
|
|
- name: commit local changes
|
|
include_role: name=etckeeper.inc allow_duplicates=true tasks_from=local.yml
|
|
vars:
|
|
msg: media player
|
|
### ⇐ LOCAL COMMIT ###
|
|
- meta: flush_handlers
|