diff --git a/Manual.org b/Manual.org index 4ec25ab..9c58044 100644 --- a/Manual.org +++ b/Manual.org @@ -1,14 +1,19 @@ # -*- mode: org; -*- +# Local Variables: +# org-src-preserve-indentation: t +# End: :DOCUMENT_OPTIONS: #+HTML_HEAD: #+HTML_HEAD: - #+HTML_HEAD: #+HTML_HEAD: #+HTML_HEAD: #+HTML_HEAD: #+OPTIONS: ^:nil -#+PROPERTY: header-args :mkdirp yes +# Local Variables: +# org-src-preserve-indentation: t +# End: +#+PROPERTY: header-args :mkdirp yes #+TITLE: Ansible Playbooks for yaVDR 0.7 #+Author: Alexander Grothe :END: @@ -166,7 +171,7 @@ The ~yavdr07.yml~ playbook sets up a fully-featured yaVDR installation: #+END_SRC ** yavdr07-headless.yml For a headless server installation ~yavdr07-headless.yml~ is a good choice -#+BEGIN_SRC yaml :tangle yavdr07-headless.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle yavdr07-headless.yml :mkdirp yes :padline no --- # file: yavdr07-headless.yml # this playbook set up a headless yaVDR 0.7 installation @@ -189,14 +194,15 @@ For a headless server installation ~yavdr07-headless.yml~ is a good choice * Hosts This playbook can either be used to run the installation on the localhost or any other PC in the network that can be accessed via ssh. Simply add the host names or IP addresses to the hosts file in the respective section: -#+BEGIN_SRC conf :tangle localhost_inventory :mkdirp yes +#+BEGIN_SRC conf :tangle localhost_inventory :mkdirp yes :padline no [localhost] localhost connection=local #+END_SRC * Group Variables ** default text for templates used by ansible -#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes +#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes :padline no +--- # file: group_vars/all # this is the standard text to put in templates @@ -279,7 +285,7 @@ grub: ** install-dependencies *** tasks **** main.yml -#+BEGIN_SRC yaml :tangle roles/install-packages/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/install-packages/tasks/main.yml :mkdirp yes :padline no --- - name: apt | install packages @@ -295,7 +301,7 @@ grub: install nvidia-381 from ppa:graphics-drivers/ppa *** tasks **** main.yml -#+BEGIN_SRC yaml :tangle roles/nvidia-381/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/nvidia-381/tasks/main.yml :mkdirp yes :padline no --- - name: add ppa:graphics-drivers/ppa @@ -317,8 +323,9 @@ install nvidia-381 from ppa:graphics-drivers/ppa This role is used to set up a basic yaVDR installation. It creates the directories, installs the vdr and other useful packages. *** default variables This section is for reference only, please use the files in ~global_vars~ for customizations. -#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes :padline no --- + # file: roles/yavdr-common/defaults/main.yml #+END_SRC @@ -376,7 +383,9 @@ yavdr-common executes the following tasks: **** main.yml ***** Disable default installation of recommended packages This task prevents apt to automatically install all recommended dependencies for packages: - #+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes + #+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes :padline no +--- + - name: apt | prevent automatic installation of recommended packages template: src: templates/90-norecommends.j2 @@ -503,7 +512,7 @@ yavdr-common executes the following tasks: with_dict: '{{ media_dirs }}' #+END_SRC *** templates -#+BEGIN_SRC c :tangle roles/yavdr-common/templates/90-norecommends.j2 :mkdirp yes +#+BEGIN_SRC c :tangle roles/yavdr-common/templates/90-norecommends.j2 :mkdirp yes :padline no {{ ansible_managed_file | comment('c') }} // Recommends are as of now still abused in many packages APT::Install-Recommends "0"; @@ -512,7 +521,7 @@ APT::Install-Suggests "0"; ** vdr *** tasks **** install the basic vdr packages -#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes :padline no --- # file: roles/vdr/tasks/main.yml @@ -584,14 +593,163 @@ The additional plugins to install can be set in the variable ~{{vdr_plugins}}~ i '{{ vdr_plugins | default({}) }}' notify: [ 'Restart VDR' ] #+END_SRC +**** expand template for remote.conf +#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes +- name: ensure vdr is stopped + systemd: + name: vdr.service + state: stopped + notify: [ 'Start VDR' ] + +- name: 'vdr configuration | expand template for remote.conf' + template: + src: templates/remote.conf.j2 + dest: '/var/lib/vdr/remote.conf' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + mode: 0644 +#+END_SRC + +*** templates +**** remote.conf +#+BEGIN_SRC conf :tangle roles/vdr/templates/remote.conf.j2 :mkdirp yes :padline no +LIRC.Up KEY_UP +LIRC.Down KEY_DOWN +LIRC.Menu KEY_MENU +LIRC.Ok KEY_OK +LIRC.Back KEY_ESC +LIRC.Left KEY_LEFT +LIRC.Right KEY_RIGHT +LIRC.Red KEY_RED +LIRC.Green KEY_GREEN +LIRC.Yellow KEY_YELLOW +LIRC.Blue KEY_BLUE +LIRC.0 KEY_0 +LIRC.1 KEY_1 +LIRC.2 KEY_2 +LIRC.3 KEY_3 +LIRC.4 KEY_4 +LIRC.5 KEY_5 +LIRC.6 KEY_6 +LIRC.7 KEY_7 +LIRC.8 KEY_8 +LIRC.9 KEY_9 +LIRC.Info KEY_INFO +LIRC.Play KEY_PLAY +LIRC.Pause KEY_PAUSE +LIRC.Play/Pause KEY_PLAYPAUSE +LIRC.Stop KEY_STOP +LIRC.Record KEY_RECORD +LIRC.FastFwd KEY_FASTFORWARD +LIRC.FastRew KEY_REWIND +LIRC.Next KEY_NEXT +LIRC.Prev KEY_BACK +LIRC.Power KEY_POWER2 +LIRC.Channel+ KEY_CHANNELUP +LIRC.Channel- KEY_CHANNELDOWN +LIRC.PrevChannel KEY_PREVIOUS +LIRC.Volume+ KEY_VOLUMEUP +LIRC.Volume- KEY_VOLUMEDOWN +LIRC.Mute KEY_MUTE +LIRC.Subtitles KEY_SUBTITLE +LIRC.Schedule KEY_EPG +LIRC.Channels KEY_CHANNEL +LIRC.Commands KEY_FAVORITES +LIRC.Audio KEY_MODE +LIRC.Timers KEY_TIME +LIRC.Recordings KEY_PVR +LIRC.Setup KEY_SETUP +LIRC.User0 KEY_TEXT +LIRC.User1 KEY_PROG1 +LIRC.User2 KEY_PROG2 +LIRC.User3 KEY_PROG3 +LIRC.User4 KEY_PROG4 +LIRC.User5 KEY_AUDIO +LIRC.User6 KEY_VIDEO +LIRC.User7 KEY_IMAGES +LIRC.User8 KEY_FN +LIRC.User9 KEY_SCREEN + +XKeySym.Up Up +XKeySym.Down Down +XKeySym.Menu Home +XKeySym.Menu Tab +XKeySym.Menu KP_Home +XKeySym.Ok Return +XKeySym.Ok KP_Enter +XKeySym.Back BackSpace +XKeySym.Back KP_Separator +XKeySym.Left Left +XKeySym.Right Right +XKeySym.Up KP_Up +XKeySym.Down KP_Down +XKeySym.Left KP_Left +XKeySym.Right KP_Right +XKeySym.Red F1 +XKeySym.Green F2 +XKeySym.Yellow F3 +XKeySym.Blue F4 +XKeySym.0 0 +XKeySym.1 1 +XKeySym.2 2 +XKeySym.3 3 +XKeySym.4 4 +XKeySym.5 5 +XKeySym.6 6 +XKeySym.7 7 +XKeySym.8 8 +XKeySym.9 9 +XKeySym.0 KP_0 +XKeySym.1 KP_1 +XKeySym.2 KP_2 +XKeySym.3 KP_3 +XKeySym.4 KP_4 +XKeySym.5 KP_5 +XKeySym.6 KP_6 +XKeySym.7 KP_7 +XKeySym.8 KP_8 +XKeySym.9 KP_9 +XKeySym.Info End +XKeySym.Info KP_End +XKeySym.Pause F9 +XKeySym.FastFwd F6 +XKeySym.FastRew F5 +XKeySym.Power Pause +XKeySym.Volume+ F12 +XKeySym.Volume- F11 +XKeySym.Volume+ KP_Add +XKeySym.Volume- KP_Subtract +XKeySym.Mute F10 +XKeySym.User1 F5 +XKeySym.User2 F6 +XKeySym.User3 F7 +XKeySym.User4 F8 +XKeySym.User5 Print +XKeySym.User6 Scroll_Lock +XKeySym.User7 Insert +XKeySym.User8 KP_Divide +XKeySym.User9 KP_Multiply +XKeySym.Audio Menu +XKeySym.Channel+ Prior +XKeySym.Channel- Next +XKeySym.Channel+ KP_Prior +XKeySym.Channel- KP_Next +XKeySym.Volume+ XF86AudioRaiseVolume +XKeySym.Volume- XF86AudioLowerVolume +XKeySym.Mute XF86AudioMute +XKeySym.Stop XF86AudioStop +XKeySym.Play/Pause XF86AudioPlay +XKeySym.Prev XF86AudioPrev +XKeySym.Next XF86AudioNext +#+END_SRC ** STARTED yavdr-network *** default variables -#+BEGIN_SRC yaml :tangle roles/yavdr-network/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/yavdr-network/main.yml :mkdirp yes :padline no install_avahi: true #+END_SRC *** tasks -#+BEGIN_SRC yaml :tangle roles/yavdr-network/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/yavdr-network/tasks/main.yml :mkdirp yes :padline no --- # this playbook sets up network services for a yaVDR installation @@ -615,10 +773,32 @@ install_avahi: true # register: wol # with_items: '{% for interface in ansible_interfaces if interface != 'lo' and interface != 'bond0' %}' +- name: restart autofs + systemd: + name: autofs + state: restarted + enabled: yes + masked: no + +- name: ensure autofs is running + systemd: + name: autofs + state: started + enabled: yes + masked: no + +- name: start avahi-linker + systemd: + name: avahi-linker + state: started + enabled: yes + masked: no #+END_SRC ** nfs-server *** tasks -#+BEGIN_SRC yaml :tangle roles/nfs-server/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/nfs-server/tasks/main.yml :mkdirp yes :padline no +--- + - name: install nfs server packages apt: name: '{{ item }}' @@ -635,7 +815,7 @@ install_avahi: true notify: [ 'Restart NFS Kernel Server' ] #+END_SRC *** templates -#+BEGIN_SRC conf :tangle roles/nfs-server/templates/nfs-exports.j2 :mkdirp yes +#+BEGIN_SRC conf :tangle roles/nfs-server/templates/nfs-exports.j2 :mkdirp yes :padline no /srv *(rw,fsid=0,sync,no_subtree_check,all_squash,anongid={{ vdr.gid }},anonuid={{ vdr.uid }}) {% for name, path in media_dirs.iteritems() %} {{ path }} *(rw,fsid={{ loop.index }},sync,no_subtree_check,all_squash,anongid={{ vdr.gid }},anonuid={{ vdr.uid }}{{ ',insecure' if nfs.insecure else '' }}) @@ -644,7 +824,7 @@ install_avahi: true ** TODO yavdr-remote *** default variables *** tasks -#+BEGIN_SRC yaml :tangle roles/yavdr-remote/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/yavdr-remote/tasks/main.yml :mkdirp yes :padline no --- # This role is used to set up the yaVDR remote control configuration. @@ -1063,11 +1243,10 @@ b'\xde\xad\xbe\xef' #+END_SRC *** default variables *** tasks -#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/main.yml :mkdirp yes :padline no --- # file: roles/yavdr-xorg/tasks/main.yml - # TODO: use hooks or requirements instead - name: Stop VDR systemd: @@ -1098,6 +1277,8 @@ b'\xde\xad\xbe\xef' - xlogin - xterm - openbox + - tmux + - kiosk-browser #- yavdr-xorg - name: "stop x@vt7.service" @@ -1107,7 +1288,7 @@ b'\xde\xad\xbe\xef' - name: "expand template for x-verbose@.service" template: - src: "templates/x-verbose@.service.j2" + src: "templates/systemd/system/x-verbose@.service.j2" dest: "/etc/systemd/system/x-verbose@.service" - name: "start x-verbose@.service" @@ -1145,36 +1326,30 @@ b'\xde\xad\xbe\xef' - '{{ vdr.home }}/.config/systemd/user' - '{{ vdr.home }}/.config/openbox/' -### TODO: move to yavdr-xorg package? ### - name: create folder for customizations of vdr.service file: state: directory dest: /etc/systemd/system/vdr.service.d mode: '0775' -- name: create folder for systemd user configuration - file: - state: directory - dest: '{{ vdr.home }}/.config/systemd/user' - mode: '0775' - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - -- name: create folder for openbox configuration - file: - state: directory - dest: '{{ vdr.home }}/.config/openbox' - mode: '0775' - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - - 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/ -### END TODO ### -- name: create .xinitrc for vdr user +- name: create folders for user configuration files + file: + state: directory + dest: '{{ item }}' + mode: '0775' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + with_items: + - '{{ vdr.home }}/.config/systemd/user' + - '{{ vdr.home }}/.config/openbox' + - '{{ vdr.home }}/.config/pulse' + +- name: expand template for .xinitrc for vdr user template: src: 'templates/.xinitrc.j2' dest: '{{ vdr.home }}/.xinitrc' @@ -1182,9 +1357,9 @@ b'\xde\xad\xbe\xef' owner: '{{ vdr.user }}' group: '{{ vdr.group }}' -- name: populate autostart for openbox +- name: expand template for openbox autostart template: - src: 'templates/autostart.j2' + src: 'templates/openbox/autostart.j2' dest: '{{ vdr.home }}/.config/openbox/autostart' mode: 0755 owner: '{{ vdr.user }}' @@ -1192,20 +1367,29 @@ b'\xde\xad\xbe\xef' - name: expand rc.xml for openbox template: - src: 'templates/openbox_rc.xml.j2' + src: 'templates/openbox/rc.xml.j2' dest: '{{ vdr.home }}/.config/openbox/rc.xml' mode: 0755 owner: '{{ vdr.user }}' group: '{{ vdr.group }}' -- name: create yavdr.target for the user session +- name: create yavdr-desktop.target for the user session template: - src: 'templates/yavdr-desktop.target.j2' + src: 'templates/systemd/user/yavdr-desktop.target.j2' dest: '{{ vdr.home }}/.config/systemd/user/yavdr-desktop.target' mode: 0755 owner: '{{ vdr.user }}' group: '{{ vdr.group }}' +- name: disable pulseaudio autospawning + lineinfile: + path: '{{ vdr.home }}/.config/pulse/client.conf' + line: 'autospawn = no' + create: yes + state: present + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + - name: set a login shell for the user vdr user: name: '{{ vdr.user }}' @@ -1215,6 +1399,11 @@ b'\xde\xad\xbe\xef' groups: '{{ vdr.group }}' append: yes +- name: create tmux.service for the session + template: + src: roles/yavdr-xorg/templates/systemd/user/tmux.service.j2 + dest: '{{ vdr.home }}/.config/systemd/user/tmux.service' + # TODO: run xorg-debug and parse xrandr output # TODO: expand template for xorg.conf (or snippets) # with respect for the available graphics card driver @@ -1229,7 +1418,8 @@ b'\xde\xad\xbe\xef' #+END_SRC *** templates **** xorg -#+BEGIN_SRC conf :tangle "roles/yavdr-xorg/templates/x-verbose@.service.j2" +***** x-verbose@.service +#+BEGIN_SRC conf :tangle "roles/yavdr-xorg/templates/systemd/system/x-verbose@.service.j2" :padline no [Unit] Description=X with verbose logging on %I Wants=graphical.target @@ -1239,8 +1429,8 @@ Before=graphical.target Type=forking ExecStart=/usr/bin/x-daemon -logverbose 6 -noreset %I #+END_SRC - -#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/vdr-xorg.conf :mkdirp yes +***** Drop-in snippet for vdr.service +#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/vdr-xorg.conf :mkdirp yes :padline no # file: roles/yavdr-xorg/templates/vdr-xorg.conf # {{ ansible_managed_file }} @@ -1249,13 +1439,14 @@ After=x@vt7.service Wants=x@vt7.service #BindsTo=x@vt7.service #+END_SRC -#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/.xinitrc.j2 :mkdirp yes +#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/.xinitrc.j2 :mkdirp yes :padline no #!/bin/bash # {{ ansible_managed_file }} exec openbox-session #+END_SRC - -#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/yavdr-desktop.target.j2 :mkdirp yes +**** Systemd User Session +***** yavdr-desktop.target +#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/systemd/user/yavdr-desktop.target.j2 :mkdirp yes :padline no [Unit] Description=yaVDR Desktop Requires=default.target @@ -1265,13 +1456,87 @@ AllowIsolate=yes #+END_SRC #+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/xorg.conf.yavdr :mkdirp yes +#+END_SRC +***** detect-second-display +#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/user/detect-second-display.service.j2 :mkdirp yes :padline no +[Unit] +Description=Detect second DISPLAY using xrandr + +[Service] +Type=oneshot +ExecStart=/bin/bash -c 'export DISPLAY=$DISPLAY.1; xrandr -q | grep "connected" && echo "DISPLAY=$DISPLAY" > ~/.second_display || rm -f ~/.second_display' + +[Install] +WantedBy=yavdr-desktop.target +#+END_SRC +***** openbox-second.service +#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/user/openbox-second.service.j2 :mkdirp yes :padline no +[Unit] +Description=Start openbox on the second DISPLAY if it exists +After=detect-second-display.service +Wants=detect-second-display.service +Before=yavdr-frontend.service +ConditionFileNotEmpty=%h/.second_display + +[Service] +PassEnvironment=XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS +EnvironmentFile=%h/.second_display +ExecStart=/usr/bin/openbox --config-file %h/.config/openbox/rc.xml + +[Install] +WantedBy=yavdr-desktop.target +#+END_SRC +***** osd2web.service +#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/user/osd2web.service.j2 :mkdirp yes :padline no +[Unit] +Description=Start a kiosk browser on the second DISPLAY if it exists +After=detect-second-display.service openbox-second.service +Wants=detect-second-display.service openbox-second.service +ConditionFileNotEmpty=%h/.second_display + +[Service] +EnvironmentFile=%h/.second_display +PassEnvironment=XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS +ExecStart=/usr/bin/on_vdr -o -c 'kiosk-browser "http://localhost:4444/skins/horchiTft/index.html?theme=blue&onlyView=1"' + +[Install] +WantedBy=yavdr-desktop.target +#+END_SRC +***** tmux.service +#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/systemd/user/tmux.service.j2 :mkdirp yes :padline no +[Unit] +Description=Start tmux in detached session + +[Service] +EnvironmentFile=-%h/.session-env +Type=forking +ExecStart=/usr/bin/tmux new-session -s use-session -d +ExecStop=/usr/bin/tmux kill-session -t %u +Restart=always + +[Install] +WantedBy=default.target #+END_SRC **** openbox -****** autostart -#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/autostart.j2 :mkdirp yes +***** autostart +#+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/openbox/autostart.j2 :mkdirp yes :shebang #!/bin/bash +# forward environment variables to an environment file and the systemd user session 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 +enabled_services=("tmux.service" "detect-second-display.service" "openbox-second.service" "osd2web.service") +disabled_services=() + +# enable configured services for the user session +for service in "${enabled_services[@]}"; do + systemctl --user enable "$service" +done + +# disable unwanted services for the user session +for service in "${disabled_services[@]}"; do + systemctl --user disable "$service" +done + if which dbus-update-activation-environment >/dev/null 2>&1; then dbus-update-activation-environment DISPLAY XAUTHORITY XDG_RUNTIME_DIR fi @@ -1279,8 +1544,8 @@ fi # start systemd units for the yavdr user session systemctl --user isolate yavdr-desktop.target #+END_SRC -****** rc.xml -#+BEGIN_SRC xml :tangle roles/yavdr-xorg/templates/openbox_rc.xml.j2 :mkdirp yes :padline no +***** rc.xml +#+BEGIN_SRC xml :tangle roles/yavdr-xorg/templates/openbox/rc.xml.j2 :mkdirp yes :padline no - yes + no no @@ -2099,9 +2364,11 @@ systemctl --user isolate yavdr-desktop.target #+END_SRC + ** samba-install *** tasks -#+BEGIN_SRC yaml :tangle roles/samba-install/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/samba-install/tasks/main.yml :mkdirp yes :padline no +--- # file: roles/samba-install/tasks/main.yml - name: install samba server @@ -2118,7 +2385,8 @@ systemctl --user isolate yavdr-desktop.target #+END_SRC ** samba-config *** tasks -#+BEGIN_SRC yaml :tangle roles/samba-config/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/samba-config/tasks/main.yml :mkdirp yes :padline no +--- # file: roles/samba-config/tasks/main.yml # TODO: @@ -2140,7 +2408,7 @@ systemctl --user isolate yavdr-desktop.target *** templates **** smb.conf ***** global settings -#+BEGIN_SRC yaml :tangle roles/samba-config/templates/smb.conf.j2 :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/samba-config/templates/smb.conf.j2 :mkdirp yes :padline no {{ ansible_managed_file | comment }} #======================= Global Settings ======================= @@ -2257,7 +2525,7 @@ from http://www.vdr-portal.de/board18-vdr-hardware/board102-dvb-karten/120817-tr ** autoinstall-ubuntu-drivers The tool ubuntu-drivers is used to install the matching driver version for nvidia graphics cards, virtualbox guest additions and Intel and AMD microcode updates. *** tasks -#+BEGIN_SRC yaml :tangle roles/autoinstall-ubuntu-drivers/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/autoinstall-ubuntu-drivers/tasks/main.yml :padline no --- # file roles/autoinstall-ubuntu-drivers/tasks/main.yml - name: apt | install ubuntu-drivers-common @@ -2277,7 +2545,7 @@ The tool ubuntu-drivers is used to install the matching driver version for nvidi ** autoinstall-satip If a Sat>IP Server responds to a discovery request, the package vdr-plugin-satip is installed. *** tasks -#+BEGIN_SRC yaml :tangle roles/autoinstall-satip/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/autoinstall-satip/tasks/main.yml :padline no --- # file roles/autoinstall-satip/tasks/main.yml @@ -2297,7 +2565,7 @@ If a Sat>IP Server responds to a discovery request, the package vdr-plugin-satip ** autoinstall-targavfd *** tasks -#+BEGIN_SRC yaml :tangle roles/autoinstall-targavfd/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/autoinstall-targavfd/tasks/main.yml :padline no --- # file roles/autoinstall-targavfd/tasks/main.yml @@ -2310,7 +2578,7 @@ If a Sat>IP Server responds to a discovery request, the package vdr-plugin-satip #+END_SRC ** autoinstall-imonlcd *** tasks -#+BEGIN_SRC yaml :tangle roles/autoinstall-imonlcd/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/autoinstall-imonlcd/tasks/main.yml :padline no --- # file roles/autoinstall-imonlcd/tasks/main.yml @@ -2324,7 +2592,7 @@ If a Sat>IP Server responds to a discovery request, the package vdr-plugin-satip #+END_SRC ** autoinstall-libcecdaemon *** tasks -#+BEGIN_SRC yaml :tangle roles/autoinstall-libcecdaemon/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/autoinstall-libcecdaemon/tasks/main.yml :padline no --- # file roles/autoinstall-libcec-daemon/tasks/main.yml @@ -2336,7 +2604,7 @@ If a Sat>IP Server responds to a discovery request, the package vdr-plugin-satip #+END_SRC ** autoinstall-pvr350 *** tasks -#+BEGIN_SRC yaml :tangle roles/autoinstall-pvr350/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/autoinstall-pvr350/tasks/main.yml :padline no --- # file roles/autoinstall-pvr350/tasks/main.yml @@ -2351,7 +2619,7 @@ If a Sat>IP Server responds to a discovery request, the package vdr-plugin-satip ** TODO autoinstall-dvbhddevice Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware sollte in yavdr-firmware stecken *** tasks -#+BEGIN_SRC yaml :tangle roles/autoinstall-dvbhddevice/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/autoinstall-dvbhddevice/tasks/main.yml :padline no --- # file roles/autoinstall-dvbhddevice/tasks/main.yml @@ -2366,7 +2634,7 @@ Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware soll ** autoinstall-dvbsddevice *** tasks -#+BEGIN_SRC yaml :tangle roles/autoinstall-dvbsddevice/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/autoinstall-dvbsddevice/tasks/main.yml :padline no --- # file roles/autoinstall-dvbsddevice/tasks/main.yml @@ -2380,7 +2648,7 @@ Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware soll ** dvd *** tasks **** install libdvd-pkg -#+BEGIN_SRC yaml :tangle roles/dvd/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/dvd/tasks/main.yml :mkdirp yes :padline no --- # file: roles/dvd/tasks/main.yml @@ -2401,7 +2669,7 @@ Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware soll ** kodi *** tasks **** Install KODI -#+BEGIN_SRC yaml :tangle roles/kodi/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/kodi/tasks/main.yml :mkdirp yes :padline no --- - name: change udev rule to allow KODI to eject optical disks @@ -2430,7 +2698,7 @@ Problem: woher kommt der Treiber (AFAIK noch nicht im Kernel)? Die Firmware soll #+END_SRC *** templates **** kodi.service -#+BEGIN_SRC conf :tangle roles/kodi/templates/kodi.service.j2 :mkdirp yes +#+BEGIN_SRC conf :tangle roles/kodi/templates/kodi.service.j2 :mkdirp yes :padline no [Unit] Description=Start kodi in user session @@ -2445,8 +2713,9 @@ SuccessExitStatus=0 127 Restart=on-failure #+END_SRC ** template-test -#+BEGIN_SRC yaml :tangle roles/template-test/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/template-test/tasks/main.yml :padline no --- + - name: show vars debug: var: '{{ system }}' @@ -2680,7 +2949,7 @@ system: #+END_SRC ** grub-config *** default variables -#+BEGIN_SRC yaml :tangle roles/grub-config/defaults/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/grub-config/defaults/main.yml :mkdirp yes :padline no system: shutdown: poweroff grub: @@ -2688,7 +2957,9 @@ grub: boot_options: quiet nosplash #+END_SRC *** tasks -#+BEGIN_SRC yaml :tangle roles/grub-config/tasks/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/grub-config/tasks/main.yml :mkdirp yes :padline no +--- + - name: custom grub configuration for timeout and reboot halt template: src: templates/50_custom.j2 @@ -2707,7 +2978,7 @@ grub: notify: [ 'Update GRUB' ] #+END_SRC *** templates -#+BEGIN_SRC shell :tangle roles/grub-config/templates/50_custom.j2 :mkdirp yes +#+BEGIN_SRC shell :tangle roles/grub-config/templates/50_custom.j2 :mkdirp yes :padline no #!/bin/sh exec tail -n +3 $0 @@ -2726,7 +2997,9 @@ else fi #+END_SRC *** handlers -#+BEGIN_SRC yaml :tangle roles/grub-config/handlers/main.yml :mkdirp yes +#+BEGIN_SRC yaml :tangle roles/grub-config/handlers/main.yml :mkdirp yes :padline no +--- + - name: Update GRUB command: update-grub failed_when: ('error' in grub_register_update.stderr) @@ -2738,9 +3011,7 @@ fi * Modules This section contains custom modules for the yaVDR Playbooks. They are used to collect facts about the system and configure applications and daemons. ** hardware_facts.py -#+BEGIN_SRC python :tangle library/hardware_facts.py -#!/usr/bin/env python - +#+BEGIN_SRC python :tangle library/hardware_facts.py :shebang #!/usr/bin/env/python # This Module collects the vendor- and device ids for USB- and PCI(e)-devices and currently loaded kernel modules. DOCUMENTATION = ''' --- @@ -2867,9 +3138,7 @@ if __name__ == '__main__': main() #+END_SRC ** satip_facts.py -#+BEGIN_SRC python :tangle library/satip_facts.py -#!/usr/bin/env python2 - +#+BEGIN_SRC python :tangle library/satip_facts.py :shebang #!/usr/bin/env python2 DOCUMENTATION = ''' --- module: hardware_facts @@ -2935,8 +3204,7 @@ if __name__ == '__main__': ** xrandr_facts.py - [ ] support multiple screens (-d :0.0 .. :0.n) -#+BEGIN_SRC python :tangle library/xrandr_facts.py -#!/usr/bin/env python2 +#+BEGIN_SRC python :tangle library/xrandr_facts.py :shebang #!/usr/bin/env python2 from __future__ import print_function import ast import binascii diff --git a/group_vars/all b/group_vars/all index dd92388..3a23e6e 100644 --- a/group_vars/all +++ b/group_vars/all @@ -1,3 +1,4 @@ +--- # file: group_vars/all # this is the standard text to put in templates diff --git a/handlers/main.yml b/handlers/main.yml index 840b674..d7fd733 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,4 @@ + - name: Restart Samba systemd: name: smbd.service diff --git a/install-yavdr.sh b/install-yavdr.sh index d3bd2d8..d8aa931 100755 --- a/install-yavdr.sh +++ b/install-yavdr.sh @@ -1,4 +1,5 @@ #!/bin/bash + if (( $EUID != 0 )); then echo "This script must be run using sudo or as root" exit diff --git a/library/hardware_facts.py b/library/hardware_facts.py old mode 100644 new mode 100755 index d4b8bd2..c02736a --- a/library/hardware_facts.py +++ b/library/hardware_facts.py @@ -1,4 +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. DOCUMENTATION = ''' diff --git a/library/satip_facts.py b/library/satip_facts.py old mode 100644 new mode 100755 diff --git a/library/xrandr_facts.py b/library/xrandr_facts.py old mode 100644 new mode 100755 index f9cf680..2b45c66 --- a/library/xrandr_facts.py +++ b/library/xrandr_facts.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 + from __future__ import print_function import ast import binascii diff --git a/roles/grub-config/handlers/main.yml b/roles/grub-config/handlers/main.yml index a7e3e2c..b6d741c 100644 --- a/roles/grub-config/handlers/main.yml +++ b/roles/grub-config/handlers/main.yml @@ -1,3 +1,5 @@ +--- + - name: Update GRUB command: update-grub failed_when: ('error' in grub_register_update.stderr) diff --git a/roles/grub-config/tasks/main.yml b/roles/grub-config/tasks/main.yml index 6a24bad..c7c40f3 100644 --- a/roles/grub-config/tasks/main.yml +++ b/roles/grub-config/tasks/main.yml @@ -1,3 +1,5 @@ +--- + - name: custom grub configuration for timeout and reboot halt template: src: templates/50_custom.j2 diff --git a/roles/nfs-server/tasks/main.yml b/roles/nfs-server/tasks/main.yml index cc0be13..fff57cf 100644 --- a/roles/nfs-server/tasks/main.yml +++ b/roles/nfs-server/tasks/main.yml @@ -1,3 +1,5 @@ +--- + - name: install nfs server packages apt: name: '{{ item }}' diff --git a/roles/samba-config/tasks/main.yml b/roles/samba-config/tasks/main.yml index b1cfcb0..cd38366 100644 --- a/roles/samba-config/tasks/main.yml +++ b/roles/samba-config/tasks/main.yml @@ -1,3 +1,4 @@ +--- # file: roles/samba-config/tasks/main.yml # TODO: diff --git a/roles/samba-install/tasks/main.yml b/roles/samba-install/tasks/main.yml index 2c6358a..21ea28b 100644 --- a/roles/samba-install/tasks/main.yml +++ b/roles/samba-install/tasks/main.yml @@ -1,3 +1,4 @@ +--- # file: roles/samba-install/tasks/main.yml - name: install samba server diff --git a/roles/template-test/tasks/main.yml b/roles/template-test/tasks/main.yml index a2a30b2..b9ed95a 100644 --- a/roles/template-test/tasks/main.yml +++ b/roles/template-test/tasks/main.yml @@ -1,4 +1,5 @@ --- + - name: show vars debug: var: '{{ system }}' diff --git a/roles/vdr/tasks/main.yml b/roles/vdr/tasks/main.yml index e4b3c69..327cdeb 100644 --- a/roles/vdr/tasks/main.yml +++ b/roles/vdr/tasks/main.yml @@ -61,3 +61,17 @@ with_items: '{{ vdr_plugins | default({}) }}' notify: [ 'Restart VDR' ] + +- name: ensure vdr is stopped + systemd: + name: vdr.service + state: stopped + notify: [ 'Start VDR' ] + +- name: 'vdr configuration | expand template for remote.conf' + template: + src: templates/remote.conf.j2 + dest: '/var/lib/vdr/remote.conf' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + mode: 0644 diff --git a/roles/yavdr-common/defaults/main.yml b/roles/yavdr-common/defaults/main.yml index 1f53b94..17c5dac 100644 --- a/roles/yavdr-common/defaults/main.yml +++ b/roles/yavdr-common/defaults/main.yml @@ -1,4 +1,5 @@ --- + # file: roles/yavdr-common/defaults/main.yml branch: unstable diff --git a/roles/yavdr-common/tasks/main.yml b/roles/yavdr-common/tasks/main.yml index 24d4dab..96268d5 100644 --- a/roles/yavdr-common/tasks/main.yml +++ b/roles/yavdr-common/tasks/main.yml @@ -1,3 +1,5 @@ +--- + - name: apt | prevent automatic installation of recommended packages template: src: templates/90-norecommends.j2 diff --git a/roles/yavdr-network/tasks/main.yml b/roles/yavdr-network/tasks/main.yml index 7efe237..6f9e8e7 100644 --- a/roles/yavdr-network/tasks/main.yml +++ b/roles/yavdr-network/tasks/main.yml @@ -20,3 +20,24 @@ # shell: 'ethtool {{ item }} | grep -Po "(?<=Supports\sWake-on:\s).*$"' # register: wol # with_items: '{% for interface in ansible_interfaces if interface != 'lo' and interface != 'bond0' %}' + +- name: restart autofs + systemd: + name: autofs + state: restarted + enabled: yes + masked: no + +- name: ensure autofs is running + systemd: + name: autofs + state: started + enabled: yes + masked: no + +- name: start avahi-linker + systemd: + name: avahi-linker + state: started + enabled: yes + masked: no diff --git a/roles/yavdr-xorg/tasks/main.yml b/roles/yavdr-xorg/tasks/main.yml index ceb5782..9e30d58 100644 --- a/roles/yavdr-xorg/tasks/main.yml +++ b/roles/yavdr-xorg/tasks/main.yml @@ -1,7 +1,6 @@ --- # file: roles/yavdr-xorg/tasks/main.yml - # TODO: use hooks or requirements instead - name: Stop VDR systemd: @@ -32,6 +31,8 @@ - xlogin - xterm - openbox + - tmux + - kiosk-browser #- yavdr-xorg - name: "stop x@vt7.service" @@ -41,7 +42,7 @@ - name: "expand template for x-verbose@.service" template: - src: "templates/x-verbose@.service.j2" + src: "templates/systemd/system/x-verbose@.service.j2" dest: "/etc/systemd/system/x-verbose@.service" - name: "start x-verbose@.service" @@ -79,36 +80,30 @@ - '{{ vdr.home }}/.config/systemd/user' - '{{ vdr.home }}/.config/openbox/' -### TODO: move to yavdr-xorg package? ### - name: create folder for customizations of vdr.service file: state: directory dest: /etc/systemd/system/vdr.service.d mode: '0775' -- name: create folder for systemd user configuration - file: - state: directory - dest: '{{ vdr.home }}/.config/systemd/user' - mode: '0775' - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - -- name: create folder for openbox configuration - file: - state: directory - dest: '{{ vdr.home }}/.config/openbox' - mode: '0775' - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - - 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/ -### END TODO ### -- name: create .xinitrc for vdr user +- name: create folders for user configuration files + file: + state: directory + dest: '{{ item }}' + mode: '0775' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + with_items: + - '{{ vdr.home }}/.config/systemd/user' + - '{{ vdr.home }}/.config/openbox' + - '{{ vdr.home }}/.config/pulse' + +- name: expand template for .xinitrc for vdr user template: src: 'templates/.xinitrc.j2' dest: '{{ vdr.home }}/.xinitrc' @@ -116,9 +111,9 @@ owner: '{{ vdr.user }}' group: '{{ vdr.group }}' -- name: populate autostart for openbox +- name: expand template for openbox autostart template: - src: 'templates/autostart.j2' + src: 'templates/openbox/autostart.j2' dest: '{{ vdr.home }}/.config/openbox/autostart' mode: 0755 owner: '{{ vdr.user }}' @@ -126,20 +121,29 @@ - name: expand rc.xml for openbox template: - src: 'templates/openbox_rc.xml.j2' + src: 'templates/openbox/rc.xml.j2' dest: '{{ vdr.home }}/.config/openbox/rc.xml' mode: 0755 owner: '{{ vdr.user }}' group: '{{ vdr.group }}' -- name: create yavdr.target for the user session +- name: create yavdr-desktop.target for the user session template: - src: 'templates/yavdr-desktop.target.j2' + src: 'templates/systemd/user/yavdr-desktop.target.j2' dest: '{{ vdr.home }}/.config/systemd/user/yavdr-desktop.target' mode: 0755 owner: '{{ vdr.user }}' group: '{{ vdr.group }}' +- name: disable pulseaudio autospawning + lineinfile: + path: '{{ vdr.home }}/.config/pulse/client.conf' + line: 'autospawn = no' + create: yes + state: present + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + - name: set a login shell for the user vdr user: name: '{{ vdr.user }}' @@ -149,6 +153,11 @@ groups: '{{ vdr.group }}' append: yes +- name: create tmux.service for the session + template: + src: roles/yavdr-xorg/templates/systemd/user/tmux.service.j2 + dest: '{{ vdr.home }}/.config/systemd/user/tmux.service' + # TODO: run xorg-debug and parse xrandr output # TODO: expand template for xorg.conf (or snippets) # with respect for the available graphics card driver diff --git a/roles/yavdr-xorg/templates/openbox/autostart.j2 b/roles/yavdr-xorg/templates/openbox/autostart.j2 old mode 100644 new mode 100755 index f3b16c7..160c8e3 --- a/roles/yavdr-xorg/templates/openbox/autostart.j2 +++ b/roles/yavdr-xorg/templates/openbox/autostart.j2 @@ -4,7 +4,7 @@ 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 -enabled_services=("detect-second-display.service" "openbox-second.service" "osd2web.service") +enabled_services=("tmux.service" "detect-second-display.service" "openbox-second.service" "osd2web.service") disabled_services=() # enable configured services for the user session diff --git a/roles/yavdr-xorg/templates/yavdr-desktop.target.j2 b/roles/yavdr-xorg/templates/systemd/user/yavdr-desktop.target.j2 similarity index 100% rename from roles/yavdr-xorg/templates/yavdr-desktop.target.j2 rename to roles/yavdr-xorg/templates/systemd/user/yavdr-desktop.target.j2