start reorganizing main.yml in roles

This commit is contained in:
Alexander Grothe 2017-07-30 14:29:38 +02:00
parent 0f9caa6605
commit 02ccd7de10
22 changed files with 198 additions and 188 deletions

View File

@ -1392,15 +1392,12 @@ b'\xde\xad\xbe\xef'
#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/main.yml :mkdirp yes :padline no #+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/main.yml :mkdirp yes :padline no
--- ---
# file: roles/yavdr-xorg/tasks/main.yml # file: roles/yavdr-xorg/tasks/main.yml
- include: setup-xorg.yml tags:install,update
- include: desktop-session.yml
- include: detect-xorg.yml tags=xorg:detect,install
#+END_SRC
# IDEA: use hooks or requirements instead #+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/setup-xorg.yml :mkdirp yes :padline no
- name: Stop VDR
systemd:
name: vdr.service
state: stopped
enabled: yes
notify: ['Start VDR']
- name: create directory /etc/systemd/system/vdr.service.d/ - name: create directory /etc/systemd/system/vdr.service.d/
file: file:
dest: /etc/systemd/system/vdr.service.d/ dest: /etc/systemd/system/vdr.service.d/
@ -1439,39 +1436,8 @@ b'\xde\xad\xbe\xef'
- tmux - tmux
- kiosk-browser - kiosk-browser
- read-edid - read-edid
- python3-yavdrfrontend
#- yavdr-xorg #- yavdr-xorg
- name: Stop xlogin
systemd:
name: xlogin@vdr.service
state: stopped
enabled: yes
- name: Stop x
systemd:
name: x@vt7.service
state: stopped
- include: detect-xorg.yml
# TODO: expand template for xorg.conf (or snippets)
# with respect for the available graphics card driver
# nvidia, noveau, intel, radeon
- name: create xorg.conf (for nvidia driver)
template:
src: templates/xorg.conf.j2
dest: /etc/X11/xorg.conf
backup: yes
- include: desktop-session.yml
- name: enable and start xlogin for the user vdr
systemd:
daemon_reload: yes
name: 'xlogin@{{ vdr.user }}'
enabled: yes
state: started
#+END_SRC #+END_SRC
#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/detect-xorg.yml :mkdirp yes :padline no #+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/detect-xorg.yml :mkdirp yes :padline no
@ -1488,6 +1454,26 @@ b'\xde\xad\xbe\xef'
src: "templates/xorg-verbose.conf.j2" src: "templates/xorg-verbose.conf.j2"
dest: "/etc/X11/xorg-verbose.conf" dest: "/etc/X11/xorg-verbose.conf"
- name: Stop VDR
systemd:
name: vdr.service
state: stopped
enabled: yes
notify: ['Start VDR']
- name: Stop xlogin
systemd:
name: xlogin@vdr.service
state: stopped
enabled: yes
- name: Stop x
systemd:
name: x@vt7.service
state: stopped
- name: "start x-verbose@.service" - name: "start x-verbose@.service"
systemd: systemd:
name: "x-verbose@vt7.service" name: "x-verbose@vt7.service"
@ -1516,6 +1502,24 @@ b'\xde\xad\xbe\xef'
state: stopped state: stopped
enabled: false enabled: false
masked: true masked: true
# IDEA: use hooks or requirements instead
# TODO: expand template for xorg.conf (or snippets)
# with respect for the available graphics card driver
# nvidia, noveau, intel, radeon
- name: create xorg.conf (for nvidia driver)
template:
src: templates/xorg.conf.j2
dest: /etc/X11/xorg.conf
backup: yes
- name: enable and start xlogin for the user vdr
systemd:
daemon_reload: yes
name: 'xlogin@{{ vdr.user }}'
enabled: yes
state: started
#+END_SRC #+END_SRC
#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/desktop-session.yml :mkdirp yes :padline no #+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/desktop-session.yml :mkdirp yes :padline no
@ -3162,6 +3166,10 @@ Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware soll
*** tasks *** tasks
**** Install KODI **** Install KODI
#+BEGIN_SRC yaml :tangle roles/kodi/tasks/main.yml :mkdirp yes :padline no #+BEGIN_SRC yaml :tangle roles/kodi/tasks/main.yml :mkdirp yes :padline no
- include: install-kodi.yml tags=install,update,kodi:install
- include: configure-kodi.yml tags=install,update,kodi:configure
#+END_SRC
#+BEGIN_SRC yaml :tangle roles/kodi/tasks/install-kodi.yml :mkdirp yes :padline no
--- ---
- name: apt | install kodi packages - name: apt | install kodi packages
@ -3173,7 +3181,8 @@ Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware soll
- kodi - kodi
- kodi-pvr-vdr-vnsi - kodi-pvr-vdr-vnsi
- kodi-eventclients-xbmc-send - kodi-eventclients-xbmc-send
#+END_SRC
#+BEGIN_SRC yaml :tangle roles/kodi/tasks/configure-kodi.yml :mkdirp yes :padline no
- name: create kodi.service for the user session - name: create kodi.service for the user session
template: template:
src: 'templates/kodi.service.j2' src: 'templates/kodi.service.j2'
@ -3194,6 +3203,23 @@ Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware soll
- .kodi/userdata - .kodi/userdata
- .kodi/userdata/keymaps - .kodi/userdata/keymaps
- name: copy Lircmap.xml if it does not exist yet
copy:
dest: '{{ vdr.home }}/.kodi/userdata/Lircmap.xml'
src: 'files/userdata/Lircmap.xml'
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: "0664"
force: no
- name: copy remote.xml if it does not exist yes
copy:
dest: '{{ vdr.home }}/.kodi/userdata/keymaps/remote.xml'
src: 'files/userdata/keymaps/remote.xml'
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: "0664"
force: no
# TODO: Add configuration files # TODO: Add configuration files
#+END_SRC #+END_SRC
*** templates *** templates

View File

@ -3,7 +3,6 @@
# this is the standard text to put in templates # this is the standard text to put in templates
ansible_managed_file: "*** YAVDR: ANSIBLE MANAGED FILE ***" ansible_managed_file: "*** YAVDR: ANSIBLE MANAGED FILE ***"
branch: unstable branch: unstable
ppa_owner: 'ppa:yavdr' ppa_owner: 'ppa:yavdr'
# a list of all package repositories to be added to the installation # a list of all package repositories to be added to the installation
@ -13,7 +12,6 @@ repositories:
- '{{ ppa_owner }}/{{branch}}-vdr' - '{{ ppa_owner }}/{{branch}}-vdr'
- '{{ ppa_owner }}/{{branch}}-yavdr' - '{{ ppa_owner }}/{{branch}}-yavdr'
- '{{ ppa_owner }}/{{branch}}-kodi' - '{{ ppa_owner }}/{{branch}}-kodi'
# properties of the user vdr and vdr-related options # properties of the user vdr and vdr-related options
vdr: vdr:
user: vdr user: vdr
@ -33,7 +31,6 @@ vdr_plugins:
- vdr-plugin-markad - vdr-plugin-markad
- vdr-plugin-restfulapi - vdr-plugin-restfulapi
- vdr-plugin-softhddevice-vpp - vdr-plugin-softhddevice-vpp
# dictionary of directories for (shared) files. Automatically exported via NFS and Samba if those roles are enabled # dictionary of directories for (shared) files. Automatically exported via NFS and Samba if those roles are enabled
media_dirs: media_dirs:
audio: /srv/audio audio: /srv/audio
@ -42,14 +39,11 @@ media_dirs:
files: /srv/files files: /srv/files
backups: /srv/backups backups: /srv/backups
recordings: '{{ vdr.recdir }}' recordings: '{{ vdr.recdir }}'
nfs: nfs:
insecure: false # set to true for OS X clients or if you plan to use libnfs as unprivileged user (e.g. KODI) insecure: false # set to true for OS X clients or if you plan to use libnfs as unprivileged user (e.g. KODI)
samba: samba:
workgroup: YAVDR workgroup: YAVDR
windows_compatible: '{{ vdr.safe_dirnames }}' # set to true to disable unix extensions, enable follow symlinks and wide links windows_compatible: '{{ vdr.safe_dirnames }}' # set to true to disable unix extensions, enable follow symlinks and wide links
# additional packages you want to install # additional packages you want to install
extra_packages: extra_packages:
- vim - vim
@ -58,7 +52,6 @@ extra_packages:
- w-scan - w-scan
- bpython - bpython
- bpython3 - bpython3
frontend: vdr frontend: vdr
#system: #system:
# shutdown: poweroff # shutdown: poweroff

View File

@ -1,4 +1,3 @@
- name: Restart Samba - name: Restart Samba
systemd: systemd:
name: smbd.service name: smbd.service

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
if (( $EUID != 0 )); then if (( $EUID != 0 )); then
echo "This script must be run using sudo or as root" echo "This script must be run using sudo or as root"
exit exit

View File

@ -1,5 +1,4 @@
#!/usr/bin/env/python #!/usr/bin/env/python
# This Module collects the vendor- and device ids for USB- and PCI(e)-devices and currently loaded kernel modules. # This Module collects the vendor- and device ids for USB- and PCI(e)-devices and currently loaded kernel modules.
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: hardware_facts module: hardware_facts

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
from __future__ import print_function from __future__ import print_function
import ast import ast
import binascii import binascii

View File

@ -0,0 +1,38 @@
- name: create kodi.service for the user session
template:
src: 'templates/kodi.service.j2'
dest: '{{ vdr.home }}/.config/systemd/user/kodi.service'
mode: 0755
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: create kodi user directory
file:
dest: '{{ vdr.home }}/{{ item }}'
state: directory
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: "0775"
with_items:
- .kodi
- .kodi/userdata
- .kodi/userdata/keymaps
- name: copy Lircmap.xml if it does not exist yet
copy:
dest: '{{ vdr.home }}/.kodi/userdata/Lircmap.xml'
src: 'files/userdata/Lircmap.xml'
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: "0664"
force: no
- name: copy remote.xml if it does not exist yes
copy:
dest: '{{ vdr.home }}/.kodi/userdata/keymaps/remote.xml'
src: 'files/userdata/keymaps/remote.xml'
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: "0664"
force: no
# TODO: Add configuration files

View File

@ -0,0 +1,11 @@
---
- name: apt | install kodi packages
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
- kodi
- kodi-pvr-vdr-vnsi
- kodi-eventclients-xbmc-send

View File

@ -1,33 +1,2 @@
--- - include: install-kodi.yml tags=install,update,kodi:install
- include: configure-kodi.yml tags=install,update,kodi:configure
- name: apt | install kodi packages
apt:
name: '{{ item }}'
state: present
install_recommends: no
with_items:
- kodi
- kodi-pvr-vdr-vnsi
- kodi-eventclients-xbmc-send
- name: create kodi.service for the user session
template:
src: 'templates/kodi.service.j2'
dest: '{{ vdr.home }}/.config/systemd/user/kodi.service'
mode: 0755
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: create kodi user directory
file:
dest: '{{ vdr.home }}/{{ item }}'
state: directory
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
mode: "0775"
with_items:
- .kodi
- .kodi/userdata
- .kodi/userdata/keymaps
# TODO: Add configuration files

View File

@ -77,7 +77,6 @@
follow symlinks= yes follow symlinks= yes
wide links= yes wide links= yes
{% endif %} {% endif %}
{% for name, path in media_dirs.iteritems() %} {% for name, path in media_dirs.iteritems() %}
[{{ name }}] [{{ name }}]
path = {{ path }} path = {{ path }}
@ -93,5 +92,4 @@
wide links = yes wide links = yes
{% endfor %} {% endfor %}
include = /etc/samba/smb.conf.custom include = /etc/samba/smb.conf.custom

View File

@ -1,4 +1,3 @@
foo: foo:
- bar - bar
- baz - baz

View File

@ -10,7 +10,6 @@
- vdr - vdr
- vdrctl - vdrctl
- vdr-plugin-dbus2vdr - vdr-plugin-dbus2vdr
- name: add svdrp and svdrp-disc to /etc/services - name: add svdrp and svdrp-disc to /etc/services
lineinfile: lineinfile:
dest: /etc/services dest: /etc/services
@ -19,7 +18,6 @@
with_items: with_items:
- "svdrp 6419/tcp" - "svdrp 6419/tcp"
- "svdrp-disc 6419/udp" - "svdrp-disc 6419/udp"
- name: create vdr recdir - name: create vdr recdir
file: file:
state: directory state: directory
@ -49,7 +47,6 @@
vdr.hide_first_recording_level vdr.hide_first_recording_level
# TODO: set recdir, user etc. in /etc/vdr/conf.d/ # TODO: set recdir, user etc. in /etc/vdr/conf.d/
- name: apt | install additional vdr plugins - name: apt | install additional vdr plugins
apt: apt:
name: '{{ item }}' name: '{{ item }}'
@ -58,7 +55,6 @@
with_items: with_items:
'{{ vdr_plugins | default({}) }}' '{{ vdr_plugins | default({}) }}'
notify: [ 'Restart VDR' ] notify: [ 'Restart VDR' ]
- name: ensure vdr is stopped - name: ensure vdr is stopped
systemd: systemd:
name: vdr.service name: vdr.service

View File

@ -1,7 +1,6 @@
--- ---
# file: roles/yavdr-common/defaults/main.yml # file: roles/yavdr-common/defaults/main.yml
branch: unstable branch: unstable
repositories: repositories:
- 'ppa:yavdr/main' - 'ppa:yavdr/main'
@ -9,16 +8,13 @@ repositories:
- 'ppa:yavdr/{{branch}}-vdr' - 'ppa:yavdr/{{branch}}-vdr'
- 'ppa:yavdr/{{branch}}-kodi' - 'ppa:yavdr/{{branch}}-kodi'
- 'ppa:yavdr/{{branch}}-yavdr' - 'ppa:yavdr/{{branch}}-yavdr'
drivers: drivers:
sundtek: auto sundtek: auto
ddvb-dkms: auto ddvb-dkms: auto
extra_packages: extra_packages:
- vim - vim
- tree - tree
- w-scan - w-scan
vdr: vdr:
user: vdr user: vdr
group: vdr group: vdr

View File

@ -4,12 +4,10 @@
template: template:
src: templates/90-norecommends.j2 src: templates/90-norecommends.j2
dest: /etc/apt/apt.conf.d/90norecommends dest: /etc/apt/apt.conf.d/90norecommends
- name: use bash instead of dash - name: use bash instead of dash
shell: | shell: |
echo "set dash/sh false" | debconf-communicate echo "set dash/sh false" | debconf-communicate
dpkg-reconfigure -f noninteractive dash dpkg-reconfigure -f noninteractive dash
- name: create vdr group - name: create vdr group
group: group:
gid: '{{ vdr.gid }}' gid: '{{ vdr.gid }}'
@ -25,7 +23,6 @@
shell: '/bin/bash' shell: '/bin/bash'
state: present state: present
append: true append: true
- name: disable release-upgrade notifications - name: disable release-upgrade notifications
lineinfile: lineinfile:
dest: /etc/update-manager/release-upgrades dest: /etc/update-manager/release-upgrades
@ -33,7 +30,6 @@
state: present state: present
regexp: '^(Prompt=).*$' regexp: '^(Prompt=).*$'
line: '\1never' line: '\1never'
- name: add yaVDR PPAs - name: add yaVDR PPAs
apt_repository: apt_repository:
repo: '{{ item }}' repo: '{{ item }}'
@ -45,7 +41,6 @@
apt: apt:
upgrade: dist upgrade: dist
update_cache: yes update_cache: yes
- name: apt | install basic packages - name: apt | install basic packages
apt: apt:
name: '{{ item }}' name: '{{ item }}'
@ -68,7 +63,6 @@
- wpasupplicant - wpasupplicant
- usbutils - usbutils
- xfsprogs - xfsprogs
- name: apt | install extra packages - name: apt | install extra packages
apt: apt:
name: '{{ item }}' name: '{{ item }}'
@ -76,7 +70,6 @@
install_recommends: no install_recommends: no
with_items: with_items:
'{{ extra_packages }}' '{{ extra_packages }}'
- name: get information about usb and pci hardware and loaded kernel modules - name: get information about usb and pci hardware and loaded kernel modules
hardware_facts: hardware_facts:
usb: True usb: True
@ -95,7 +88,6 @@
- debug: - debug:
var: gpus var: gpus
verbosity: 1 verbosity: 1
- name: create media directories - name: create media directories
file: file:
dest: '{{ item.value }}' dest: '{{ item.value }}'

View File

@ -11,6 +11,26 @@
src: "templates/xorg-verbose.conf.j2" src: "templates/xorg-verbose.conf.j2"
dest: "/etc/X11/xorg-verbose.conf" dest: "/etc/X11/xorg-verbose.conf"
- name: Stop VDR
systemd:
name: vdr.service
state: stopped
enabled: yes
notify: ['Start VDR']
- name: Stop xlogin
systemd:
name: xlogin@vdr.service
state: stopped
enabled: yes
- name: Stop x
systemd:
name: x@vt7.service
state: stopped
- name: "start x-verbose@.service" - name: "start x-verbose@.service"
systemd: systemd:
name: "x-verbose@vt7.service" name: "x-verbose@vt7.service"
@ -39,3 +59,21 @@
state: stopped state: stopped
enabled: false enabled: false
masked: true masked: true
# IDEA: use hooks or requirements instead
# TODO: expand template for xorg.conf (or snippets)
# with respect for the available graphics card driver
# nvidia, noveau, intel, radeon
- name: create xorg.conf (for nvidia driver)
template:
src: templates/xorg.conf.j2
dest: /etc/X11/xorg.conf
backup: yes
- name: enable and start xlogin for the user vdr
systemd:
daemon_reload: yes
name: 'xlogin@{{ vdr.user }}'
enabled: yes
state: started

View File

@ -1,82 +1,5 @@
--- ---
# file: roles/yavdr-xorg/tasks/main.yml # file: roles/yavdr-xorg/tasks/main.yml
- include: setup-xorg.yml tags:install,update
# IDEA: use hooks or requirements instead
- name: Stop VDR
systemd:
name: vdr.service
state: stopped
enabled: yes
notify: ['Start VDR']
- name: create directory /etc/systemd/system/vdr.service.d/
file:
dest: /etc/systemd/system/vdr.service.d/
state: directory
- name: add dependency to X-server for vdr.service using a drop-in
template:
src: templates/vdr-xorg.conf
dest: /etc/systemd/system/vdr.service.d/vdr-xorg.conf
- name: load environment file for vdr.service
template:
src: templates/systemd/vdr-environ.j2
dest: /etc/systemd/system/vdr.service.d/load-environ.conf
- name: set a login shell for the user vdr
user:
name: '{{ vdr.user }}'
shell: '/bin/bash'
state: present
uid: '{{ vdr.uid }}'
groups: '{{ vdr.group }}'
append: yes
- name: install packages for xorg
apt:
name: '{{ item }}'
state: present
with_items:
- xorg
- xserver-xorg-video-all
- xserver-xorg-input-all
- xlogin
- xterm
- openbox
- tmux
- kiosk-browser
- read-edid
#- yavdr-xorg
- name: Stop xlogin
systemd:
name: xlogin@vdr.service
state: stopped
enabled: yes
- name: Stop x
systemd:
name: x@vt7.service
state: stopped
- include: detect-xorg.yml
# TODO: expand template for xorg.conf (or snippets)
# with respect for the available graphics card driver
# nvidia, noveau, intel, radeon
- name: create xorg.conf (for nvidia driver)
template:
src: templates/xorg.conf.j2
dest: /etc/X11/xorg.conf
backup: yes
- include: desktop-session.yml - include: desktop-session.yml
- include: detect-xorg.yml tags=xorg:detect,install
- name: enable and start xlogin for the user vdr
systemd:
daemon_reload: yes
name: 'xlogin@{{ vdr.user }}'
enabled: yes
state: started

View File

@ -0,0 +1,40 @@
- name: create directory /etc/systemd/system/vdr.service.d/
file:
dest: /etc/systemd/system/vdr.service.d/
state: directory
- name: add dependency to X-server for vdr.service using a drop-in
template:
src: templates/vdr-xorg.conf
dest: /etc/systemd/system/vdr.service.d/vdr-xorg.conf
- name: load environment file for vdr.service
template:
src: templates/systemd/vdr-environ.j2
dest: /etc/systemd/system/vdr.service.d/load-environ.conf
- name: set a login shell for the user vdr
user:
name: '{{ vdr.user }}'
shell: '/bin/bash'
state: present
uid: '{{ vdr.uid }}'
groups: '{{ vdr.group }}'
append: yes
- name: install packages for xorg
apt:
name: '{{ item }}'
state: present
with_items:
- xorg
- xserver-xorg-video-all
- xserver-xorg-input-all
- xlogin
- xterm
- openbox
- tmux
- kiosk-browser
- read-edid
- python3-yavdrfrontend
#- yavdr-xorg

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
# forward environment variables to an environment file and the systemd user session # forward environment variables to an environment file and the systemd user session
env | grep "DISPLAY\|DBUS_SESSION_BUS_ADDRESS\|XDG_RUNTIME_DIR" > ~/.session-env env | grep "DISPLAY\|DBUS_SESSION_BUS_ADDRESS\|XDG_RUNTIME_DIR" > ~/.session-env
systemctl --user import-environment DISPLAY XAUTHORITY XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS systemctl --user import-environment DISPLAY XAUTHORITY XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS

View File

@ -1,3 +1,2 @@
[Service] [Service]
EnvironmentFile=-/var/lib/vdr/.session-env EnvironmentFile=-/var/lib/vdr/.session-env

View File

@ -1,4 +1,3 @@
Section "Device" Section "Device"
Identifier "nvidia" Identifier "nvidia"
Driver "nvidia" Driver "nvidia"

View File

@ -1,4 +1,3 @@
{{ ansible_managed_file | comment }} {{ ansible_managed_file | comment }}
Section "ServerLayout" Section "ServerLayout"