From 9fe824e452f74f141d67c1009b9b25334588128b Mon Sep 17 00:00:00 2001 From: Alexander Grothe Date: Wed, 22 Feb 2017 15:27:48 +0100 Subject: [PATCH 1/3] cleanup and test basic functionality --- Manual.org | 414 ++++++++++++++++++----- group_vars/all | 36 ++ roles/vdr/tasks/main.yml | 61 ++++ roles/yavdr-common/defaults/main.yml | 26 +- roles/yavdr-common/tasks/main.yml | 81 +---- roles/yavdr-network/main.yml | 7 + roles/yavdr-network/tasks/main.yml | 44 +-- roles/yavdr-remote/tasks/main.yml | 18 +- roles/yavdr-xorg/tasks/main.yml | 93 ++--- roles/yavdr-xorg/templates/.xinitrc.j2 | 1 + roles/yavdr-xorg/templates/vdr-xorg.conf | 7 + yavdr07.yml | 18 +- 12 files changed, 540 insertions(+), 266 deletions(-) create mode 100644 group_vars/all create mode 100644 roles/vdr/tasks/main.yml create mode 100644 roles/yavdr-network/main.yml create mode 100644 roles/yavdr-xorg/templates/vdr-xorg.conf diff --git a/Manual.org b/Manual.org index 580f3fe..39545d2 100644 --- a/Manual.org +++ b/Manual.org @@ -1,61 +1,115 @@ +# -*- mode: org; -*- +#+HTML_HEAD: +#+HTML_HEAD: + +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: +#+HTML_HEAD: #+OPTIONS: ^:nil * Installing and configuring yaVDR with Ansible This is an experimental feature which allows to set up a yaVDR installation based on a normal Ubuntu Server 16.04.x installation using [[http://ansible.com][Ansible]]. * Playbooks -To set up a fully-featured yaVDR installation you can use the yavdr07.yml Playbook: -#+BEGIN_SRC yaml :tangle yavdr07.yml :mkdirp yes :exports none - --- - # this playbook sets up a fully featured yaVDR 0.7 installation -#+END_SRC +To set up a fully-featured yaVDR installation you can use the ~yavdr07.yml~ Playbook: #+BEGIN_SRC yaml :tangle yavdr07.yml :mkdirp yes - - name: basic setup for PPAs, packages etc. - hosts: yavdr-full - become: true - roles: - - yavdr-common - - yavdr-network - - yavdr-xorg - - grub +--- +# file: yavdr07.yml +# this playbook sets up a complete yaVDR 0.7 installation + +- name: set up yaVDR + hosts: all + become: true + roles: + - yavdr-common + - vdr + - yavdr-network + - yavdr-xorg + - yavdr-remote + - grub #+END_SRC * 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 hosts :mkdirp yes - [yavdr-full] - localhost connection=local +[yavdr-full] +#localhost connection=local +192.168.1.116 - [yavdr-headless] +[yavdr-headless] - [yavdr-client] +[yavdr-client] +#+END_SRC +* Group Variables +#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes :exports none +ansible_managed_file: "*** YAVDR: ANSIBLE MANAGED FILE ***" + +branch: unstable +ppa_owner: 'ppa:yavdr' +repositories: + - '{{ ppa_owner }}/main' + - '{{ ppa_owner }}/unstable-main' + - '{{ ppa_owner }}/{{branch}}-vdr' + - '{{ ppa_owner }}/{{branch}}-yavdr' + - '{{ ppa_owner }}/{{branch}}-kodi' + +drivers: + sundtek: auto + ddvb-dkms: auto + +vdr: + user: vdr + group: vdr + uid: 666 + gid: 666 + home: /var/lib/vdr + recdir: /srv/vdr/video + hide_first_recording_level: false + safe_dirnames: true + override_vdr_charset: false + +vdr_plugins: + - vdr-plugin-devstatus + - vdr-plugin-markad + - vdr-plugin-restfulapi + - vdr-plugin-softhddevice + +extra_packages: + - vim + - tree + - w-scan #+END_SRC * Roles ** yavdr-common This role is used to set up a basic yaVDR installation. It creates the directories, installs the vdr and other useful packages. -*** Variables +*** default variables Several variables can be set to customize the configuration. **** Repositories -You can provide a list of package repositories which provide the necessary packages. Feel free to use own PPAs if you need special customization to the VDR and it's plugins. +You can set a list of package repositories which provide the necessary packages. Feel free to use own PPAs if you need special customization to the VDR and it's plugins. #+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml - branch: unstable - repositories: - - 'ppa:yavdr/main' - - 'ppa:yavdr/unstable-main' - - 'ppa:yavdr/{{branch}}-vdr' - - 'ppa:yavdr/{{branch}}-kodi' - - 'ppa:yavdr/{{branch}}-yavdr' +--- +# file: roles/yavdr-common/defaults/main.yml + +branch: unstable +repositories: + - 'ppa:yavdr/main' + - 'ppa:yavdr/unstable-main' + - 'ppa:yavdr/{{branch}}-vdr' + - 'ppa:yavdr/{{branch}}-kodi' + - 'ppa:yavdr/{{branch}}-yavdr' #+END_SRC **** Drivers -Using autodetection to automatically install drivers can be very useful but if you know you need a certain driver, you can simply set it's value to *true*. If you don't want a driver to be installed, set it's value to *false*. +Automatically installed drivers can be very useful, but if you know you need a certain driver, you can simply set it's value to *true*. If you don't want a driver to be installed, set it's value to *false*. #+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml drivers: - sundtek: auto - ddvb-dkms: auto + sundtek: auto + ddvb-dkms: auto #+END_SRC **** Additional Packages +Add additional packages you would like to have on your installation to this list #+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml extra_packages: - vim @@ -81,20 +135,20 @@ vdr: gid: 666 home: /var/lib/vdr recdir: /srv/vdr/video - hide_first_recording_level: true + hide_first_recording_level: false safe_dirnames: true override_vdr_charset: false #+END_SRC -*** Tasks +*** tasks yavdr-common executes the following tasks: **** Disable default installation of recommended packages #+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :exports none --- # This playbook sets up the basic packages an directories for a yaVDR installation #+END_SRC - +This configuration file prevents apt to automatically install all recommended dependencies when installing packages: #+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml -- name: apt| prevent installation of recommended packages +- name: apt | prevent automatic installation of recommended packages blockinfile: dest: /etc/apt/apt.conf.d/90norecommends create: yes @@ -121,72 +175,246 @@ yavdr-common executes the following tasks: #+END_SRC **** Installing essential packages #+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml -- name: install basic packages +- name: apt | install basic packages + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - anacron + - at + - bash-completion + - biosdevname + - linux-firmware + - psmisc + - software-properties-common + - ssh + - ubuntu-drivers-common + - wget + - wpasupplicant + - usbutils + - xfsprogs +#+END_SRC +** vdr +*** tasks +#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes +--- +# file: roles/vdr/tasks/main.yml + +- name: apt | install basic vdr packages + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - vdr + - vdrctl + - vdr-plugin-dbus2vdr + +- name: create vdr recdir + file: + state: directory + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + mode: 0775 + dest: '{{ vdr.recdir }}' + +- name: set option to use hide-first-recording-level patch + blockinfile: + dest: /etc/vdr/conf.d/04-vdr-hide-first-recordinglevel.conf + create: true + block: | + [vdr] + --hide-first-recording-level + when: + vdr.hide_first_recording_level + +- name: create local dir in recdir + file: + state: directory + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + mode: '0775' + dest: '{{ vdr.recdir }}/local' + when: + vdr.hide_first_recording_level + +- name: install additional vdr plugins + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + '{{ vdr_plugins }}' +#+END_SRC +*** Set up the directories for files in /srv +#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml +- name: create directories for media files + file: + state: directory + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + mode: 0777 + dest: '{{ item }}' + with_items: + - /srv/videos + - /srv/music + - /srv/picture + - /srv/backups +#+END_SRC + +** yavdr-network +*** default variables + +#+BEGIN_SRC yaml :tangle roles/yavdr-network/main.yml :mkdirp yes +install_avahi: true +install_epgd: true +install_mariadb: true +install_nfs_client: true +install_nfs_server: true +install_samba_client: true +install_samba_server: true +#+END_SRC +*** tasks +#+BEGIN_SRC yaml :tangle roles/yavdr-network/tasks/main.yml :mkdirp yes +--- +# this playbook sets up network services for a yaVDR installation +# +- name: install network packages apt: name: '{{ item }}' state: present install_recommends: no with_items: - - anacron - - at - - bash-completion + - avahi-daemon + - avahi-utils - biosdevname - - linux-firmware - - psmisc - - software-properties-common - - ssh - - ubuntu-drivers-common - - vdr - - vdr-plugin-dbus2vdr - - vdrctl - - wget - - wpasupplicant - - usbutils - - xfsprogs -#+END_SRC -**** Set up the VDR directories -#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml -- name: create vdr recdir - file: - state: directory - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - mode: 0775 - dest: '{{ vdr.recdir }}' + - ethtool + - nfs-common + - vdr-addon-avahi-linker + - wakeonlan -- name: set option to use hide-first-recording-level patch - blockinfile: - dest: /etc/vdr/conf.d/04-vdr-hide-first-recordinglevel.conf - create: true - block: | - [vdr] - --hide-first-recording-level - when: - vdr.hide_first_recording_level - -- name: create local dir in recdir - file: - state: directory - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - mode: 0775 - dest: '{{ vdr.recdir }}/local' - when: - vdr.hide_first_recording_level -#+END_SRC -**** Set up the directories for files in /srv -#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml -- name: create directories for media files - file: - state: directory - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - mode: 0775 - dest: '{{ item }}' +- name: install and configure nfs-kernel-server + apt: + name: "{{ item }}" + state: present + install_recommends: no with_items: - - /srv/videos - - /srv/music - - /srv/picture - - /srv/backups -#+END_SRC + - nfs-kernel-server + when: + - '{{ install_nfs_server }}' +# Does this really work? We need a way to check if an interface supports WOL - Python Skript? +# - name: check WOL capabilities of network interfaces +# shell: 'ethtool {{ item }} | grep -Po "(?<=Supports\sWake-on:\s).*$"' +# register: wol +# with_items: '{% for interface in ansible_interfaces if interface != 'lo' and interface != 'bond0' %}' + +#+END_SRC +** yavdr-remote +*** default variables +*** tasks +*** templates +*** files +** yavdr-xorg +*** default variables +*** tasks +#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/main.yml :mkdirp yes +--- +# file: roles/yavdr-xorg/tasks/main.yml + +- name: install packages for xorg + apt: + name: '{{ item }}' + state: present + with_items: + - xorg + - xserver-xorg-video-all + - xserver-xorg-input-all + - xlogin + - xterm + #- yavdr-xorg + - openbox + +# TODO: move to yavdr-xorg package? +- name: create folders for user session + file: + state: directory + dest: '{{ item }}' + mode: '0775' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + with_items: + - '{{ vdr.home }}/.config/systemd/user' + - '{{ vdr.home }}/.config/openbox/autostart' + +### 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: 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: set up .xinitrc for vdr user + template: + src: 'templates/.xinitrc.j2' + dest: '/var/lib/vdr/.xinitrc' + mode: 0755 + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + +- name: set up autostart for openbox + template: + src: 'templates/autostart.j2' + dest: '/var/lib/vdr/.config/openbox/autostart' + mode: 0755 + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + +- name: set a login shell for the vdr user + user: + name: '{{ vdr.user }}' + shell: '/bin/bash' + state: present + uid: '{{ vdr.uid }}' + groups: '{{ vdr.group }}' + append: yes + +- name: enable and start xlogin for vdr user + systemd: + daemon_reload: yes + name: 'xlogin@{{ vdr.user }}' + enabled: yes + state: started +#+END_SRC +*** templates +#+BEGIN_SRC jinja2 :tangle roles/yavdr-xorg/templates/vdr-xorg.conf :mkdirp yes +# file: roles/yavdr-xorg/templates/vdr-xorg.conf +# {{ ansible_managed_file }} + +[Unit] +After=x@vt7.service +Wants=x@vt7.service +BindsTo=x@vt7.service +#+END_SRC +#+BEGIN_SRC jinja2 :tangle roles/yavdr-xorg/templates/.xinitrc.j2 :mkdirp yes +#!/bin/bash +# {{ ansible_managed_file }} +exec openbox-session +#+END_SRC +#+BEGIN_SRC jinja2 tangle: ansible/yavdr-ansible/roles/yavdr-xorg/templates/autostart.j2 :mkdirp yes +env | grep "DISPLAY\|DBUS_SESSION_BUS_ADDRESS\|XDG_RUNTIME_DIR" > ~/.session-env +systemctl --user import-environment +#+END_SRC +*** files +** grub +*** default variables +*** tasks +*** templates +*** files diff --git a/group_vars/all b/group_vars/all new file mode 100644 index 0000000..d7c68f8 --- /dev/null +++ b/group_vars/all @@ -0,0 +1,36 @@ +ansible_managed_file: "*** YAVDR: ANSIBLE MANAGED FILE ***" + +branch: unstable +ppa_owner: 'ppa:yavdr' +repositories: + - '{{ ppa_owner }}/main' + - '{{ ppa_owner }}/unstable-main' + - '{{ ppa_owner }}/{{branch}}-vdr' + - '{{ ppa_owner }}/{{branch}}-yavdr' + - '{{ ppa_owner }}/{{branch}}-kodi' + +drivers: + sundtek: auto + ddvb-dkms: auto + +vdr: + user: vdr + group: vdr + uid: 666 + gid: 666 + home: /var/lib/vdr + recdir: /srv/vdr/video + hide_first_recording_level: false + safe_dirnames: true + override_vdr_charset: false + +vdr_plugins: + - vdr-plugin-devstatus + - vdr-plugin-markad + - vdr-plugin-restfulapi + - vdr-plugin-softhddevice + +extra_packages: + - vim + - tree + - w-scan diff --git a/roles/vdr/tasks/main.yml b/roles/vdr/tasks/main.yml new file mode 100644 index 0000000..f43f4b6 --- /dev/null +++ b/roles/vdr/tasks/main.yml @@ -0,0 +1,61 @@ +--- +# file: roles/vdr/tasks/main.yml + +- name: apt | install basic vdr packages + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - vdr + - vdrctl + - vdr-plugin-dbus2vdr + +- name: create vdr recdir + file: + state: directory + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + mode: 0775 + dest: '{{ vdr.recdir }}' + +- name: set option to use hide-first-recording-level patch + blockinfile: + dest: /etc/vdr/conf.d/04-vdr-hide-first-recordinglevel.conf + create: true + block: | + [vdr] + --hide-first-recording-level + when: + vdr.hide_first_recording_level + +- name: create local dir in recdir + file: + state: directory + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + mode: '0775' + dest: '{{ vdr.recdir }}/local' + when: + vdr.hide_first_recording_level + +- name: install additional vdr plugins + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + '{{ vdr_plugins }}' + +- name: create directories for media files + file: + state: directory + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + mode: 0777 + dest: '{{ item }}' + with_items: + - /srv/videos + - /srv/music + - /srv/picture + - /srv/backups diff --git a/roles/yavdr-common/defaults/main.yml b/roles/yavdr-common/defaults/main.yml index 7803d37..1f53b94 100644 --- a/roles/yavdr-common/defaults/main.yml +++ b/roles/yavdr-common/defaults/main.yml @@ -1,20 +1,22 @@ +--- +# file: roles/yavdr-common/defaults/main.yml branch: unstable repositories: - - 'ppa:yavdr/main' - - 'ppa:yavdr/unstable-main' - - 'ppa:yavdr/{{branch}}-vdr' - - 'ppa:yavdr/{{branch}}-kodi' - - 'ppa:yavdr/{{branch}}-yavdr' + - 'ppa:yavdr/main' + - 'ppa:yavdr/unstable-main' + - 'ppa:yavdr/{{branch}}-vdr' + - 'ppa:yavdr/{{branch}}-kodi' + - 'ppa:yavdr/{{branch}}-yavdr' drivers: - sundtek: auto - ddvb-dkms: auto + sundtek: auto + ddvb-dkms: auto -extra_packages: - - vim - - tree - - w-scan + extra_packages: + - vim + - tree + - w-scan vdr: user: vdr @@ -23,6 +25,6 @@ vdr: gid: 666 home: /var/lib/vdr recdir: /srv/vdr/video - hide_first_recording_level: true + hide_first_recording_level: false safe_dirnames: true override_vdr_charset: false diff --git a/roles/yavdr-common/tasks/main.yml b/roles/yavdr-common/tasks/main.yml index e792d21..b8b2f73 100644 --- a/roles/yavdr-common/tasks/main.yml +++ b/roles/yavdr-common/tasks/main.yml @@ -1,8 +1,7 @@ - --- # This playbook sets up the basic packages an directories for a yaVDR installation -- name: apt| prevent installation of recommended packages +- name: apt | prevent automatic installation of recommended packages blockinfile: dest: /etc/apt/apt.conf.d/90norecommends create: yes @@ -25,66 +24,22 @@ upgrade: dist update_cache: yes -- name: install basic packages +- name: apt | install basic packages apt: - name: '{{ item }}' - state: present - install_recommends: no + name: '{{ item }}' + state: present + install_recommends: no with_items: - - anacron - - at - - bash-completion - - biosdevname - - linux-firmware - - psmisc - - software-properties-common - - ssh - - ubuntu-drivers-common - - vdr - - vdr-plugin-dbus2vdr - - vdrctl - - wget - - wpasupplicant - - usbutils - - xfsprogs - -- name: create vdr recdir - file: - state: directory - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - mode: 0775 - dest: '{{ vdr.recdir }}' - -- name: set option to use hide-first-recording-level patch - blockinfile: - dest: /etc/vdr/conf.d/04-vdr-hide-first-recordinglevel.conf - create: true - block: | - [vdr] - --hide-first-recording-level - when: - vdr.hide_first_recording_level - -- name: create local dir in recdir - file: - state: directory - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - mode: 0775 - dest: '{{ vdr.recdir }}/local' - when: - vdr.hide_first_recording_level - -- name: create directories for media files - file: - state: directory - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - mode: 0775 - dest: '{{ item }}' - with_items: - - /srv/videos - - /srv/music - - /srv/picture - - /srv/backups + - anacron + - at + - bash-completion + - biosdevname + - linux-firmware + - psmisc + - software-properties-common + - ssh + - ubuntu-drivers-common + - wget + - wpasupplicant + - usbutils + - xfsprogs diff --git a/roles/yavdr-network/main.yml b/roles/yavdr-network/main.yml new file mode 100644 index 0000000..e17e534 --- /dev/null +++ b/roles/yavdr-network/main.yml @@ -0,0 +1,7 @@ +install_avahi: true +install_epgd: true +install_mariadb: true +install_nfs_client: true +install_nfs_server: true +install_samba_client: true +install_samba_server: true diff --git a/roles/yavdr-network/tasks/main.yml b/roles/yavdr-network/tasks/main.yml index db50dcf..4da68ca 100644 --- a/roles/yavdr-network/tasks/main.yml +++ b/roles/yavdr-network/tasks/main.yml @@ -23,42 +23,10 @@ with_items: - nfs-kernel-server when: - - install_nfs_server + - '{{ install_nfs_server }}' -#- name: install and configure mariadb-server -# apt: -# name: "{{ item }}" -# state: present -# install_recommends: no -# with_items: -# - mariadb-server -# - mariadb-client -# - python-mysqldb -# when: -# - install_mariadb -# -#- name: create a new database with name epg2vdr -# mysql_db: -# name: epg2vdr -# state: present -# encoding: utf-8 -# when: -# - install_mariadb -# -# mysql_user: -# name: epg2vdr -# password: epg -# priv: 'epg2vdr.*:ALL,GRANT' -# host_all: yes -# state: present -# when: -# - install_mariadb -# -#- name: Install and configure vdr-epg-daemon -# apt: -# name: "{{ item }}" -# state: present -# with_items: -# - vdr-epg-daemon -# when: -# - install_epgd +# Does this really work? We need a way to check if an interface supports WOL - Python Skript? +# - name: check WOL capabilities of network interfaces +# shell: 'ethtool {{ item }} | grep -Po "(?<=Supports\sWake-on:\s).*$"' +# register: wol +# with_items: '{% for interface in ansible_interfaces if interface != 'lo' and interface != 'bond0' %}' diff --git a/roles/yavdr-remote/tasks/main.yml b/roles/yavdr-remote/tasks/main.yml index 2405e5f..eafe769 100644 --- a/roles/yavdr-remote/tasks/main.yml +++ b/roles/yavdr-remote/tasks/main.yml @@ -1,26 +1,22 @@ --- - # This role is used to set up the yaVDR remote control configuration. - name: install yavdr-remote - tag: install apt: - name: yavdr-remote - state: present + name: yavdr-remote + state: present - name: install lirc - tag: install apt: - name: lircd - state: present + name: lircd + state: present when: - - install_lircd is defined and install_lircd + - install_lircd is defined and install_lircd - name: install eventlircd - tag: install apt: - name: eventlircd - state: present + name: eventlircd + state: present when: install_eventlircd is defined and install_eventlircd diff --git a/roles/yavdr-xorg/tasks/main.yml b/roles/yavdr-xorg/tasks/main.yml index aa9b7f8..ed86239 100644 --- a/roles/yavdr-xorg/tasks/main.yml +++ b/roles/yavdr-xorg/tasks/main.yml @@ -1,61 +1,72 @@ --- -# this playbook sets up a graphical user session for a yaVDR installation +# file: roles/yavdr-xorg/tasks/main.yml -- name: install xorg packages +- name: install packages for xorg apt: - name: "{{ item }}" - state: present - install_recommends: no + name: '{{ item }}' + state: present with_items: - - openbox - - xlogin - - xorg - - xserver-xorg-input-all - - xserver-xorg-video-all - - xterm + - xorg + - xserver-xorg-video-all + - xserver-xorg-input-all + - xlogin + - xterm + #- yavdr-xorg + - openbox -- name: create /etc/yavdr +# TODO: move to yavdr-xorg package? +- name: create folders for user session file: - path: /etc/yavdr - state: directory - mode: 0755 + state: directory + dest: '{{ item }}' + mode: '0775' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + with_items: + - '{{ vdr.home }}/.config/systemd/user' + - '{{ vdr.home }}/.config/openbox/autostart' -- name: check if /etc/yavdr/autoinstalled exists - stat: path=/etc/yavdr/autoinstalled - register: ubuntu_drivers_autoinstalled +### 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: install drivers using ubuntu-drivers autodetection - shell: ubuntu-drivers --package-list /etc/yavdr/autoinstalled autoinstall - when: not ubuntu_drivers_autoinstalled.stat.exists +- 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: set up .xinitrc for user vdr +- name: set up .xinitrc for vdr user template: src: 'templates/.xinitrc.j2' dest: '/var/lib/vdr/.xinitrc' mode: 0755 - owner: vdr - group: vdr - -- name: create directories for desktop session - file: - state: directory - owner: vdr - group: vdr - mode: 0644 - path: '{{ item }}' - with_items: - - /var/lib/vdr/.config/openbox/ - - /var/lib/vdr/.config/systemd/user/ + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' - name: set up autostart for openbox template: src: 'templates/autostart.j2' dest: '/var/lib/vdr/.config/openbox/autostart' mode: 0755 - owner: vdr - group: vdr + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' -- name: enable xlogin@vt7.service - service: - name: xlogin@vdr.service - enabled: yes +- name: set a login shell for the vdr user + user: + name: '{{ vdr.user }}' + shell: '/bin/bash' + state: present + uid: '{{ vdr.uid }}' + groups: '{{ vdr.group }}' + append: yes + +- name: enable and start xlogin for vdr user + systemd: + daemon_reload: yes + name: 'xlogin@{{ vdr.user }}' + enabled: yes + state: started diff --git a/roles/yavdr-xorg/templates/.xinitrc.j2 b/roles/yavdr-xorg/templates/.xinitrc.j2 index 8badcc6..deb9862 100644 --- a/roles/yavdr-xorg/templates/.xinitrc.j2 +++ b/roles/yavdr-xorg/templates/.xinitrc.j2 @@ -1,2 +1,3 @@ #!/bin/bash +# {{ ansible_managed_file }} exec openbox-session diff --git a/roles/yavdr-xorg/templates/vdr-xorg.conf b/roles/yavdr-xorg/templates/vdr-xorg.conf new file mode 100644 index 0000000..73ca70f --- /dev/null +++ b/roles/yavdr-xorg/templates/vdr-xorg.conf @@ -0,0 +1,7 @@ +# file: roles/yavdr-xorg/templates/vdr-xorg.conf +# {{ ansible_managed_file }} + +[Unit] +After=x@vt7.service +Wants=x@vt7.service +BindsTo=x@vt7.service diff --git a/yavdr07.yml b/yavdr07.yml index c2d4884..76edf75 100644 --- a/yavdr07.yml +++ b/yavdr07.yml @@ -1,12 +1,14 @@ - --- -# this playbook sets up a fully featured yaVDR 0.7 installation +# file: yavdr07.yml +# this playbook sets up a complete yaVDR 0.7 installation -- name: basic setup for PPAs, packages etc. - hosts: yavdr-full +- name: set up yaVDR + hosts: all become: true roles: - - yavdr-common - - yavdr-network - - yavdr-xorg - - grub + - yavdr-common + - vdr + - yavdr-network + - yavdr-xorg + - yavdr-remote + - grub From 228ac70b5e89e4556b192aabbd97ed8611b0e67d Mon Sep 17 00:00:00 2001 From: Alexander Grothe Date: Thu, 23 Feb 2017 13:15:04 +0100 Subject: [PATCH 2/3] add role for samba-install, grub-config, update network and handlers --- Manual.org | 334 ++++++++++++++++-- group_vars/all | 23 ++ handlers/main.yml | 7 + roles/grub-config/defaults/main.yml | 4 + roles/grub-config/handlers/main.yml | 7 + roles/grub-config/tasks/main.yml | 16 + roles/grub-config/templates/50-custom.j2 | 16 + roles/samba-config/tasks/main.yml | 17 + roles/samba-config/templates/smb.conf.j2 | 91 +++++ roles/samba-install/tasks/main.yml | 12 + roles/yavdr-common/files/90-norecommends.j2 | 4 + roles/yavdr-common/tasks/main.yml | 11 +- .../yavdr-common/templates/90-norecommends.j2 | 4 + roles/yavdr-network/tasks/main.yml | 10 - yavdr07-headless.yml | 25 +- yavdr07.yml | 20 +- 16 files changed, 530 insertions(+), 71 deletions(-) create mode 100644 handlers/main.yml create mode 100644 roles/grub-config/defaults/main.yml create mode 100644 roles/grub-config/handlers/main.yml create mode 100644 roles/grub-config/tasks/main.yml create mode 100644 roles/grub-config/templates/50-custom.j2 create mode 100644 roles/samba-config/tasks/main.yml create mode 100644 roles/samba-config/templates/smb.conf.j2 create mode 100644 roles/samba-install/tasks/main.yml create mode 100644 roles/yavdr-common/files/90-norecommends.j2 create mode 100644 roles/yavdr-common/templates/90-norecommends.j2 diff --git a/Manual.org b/Manual.org index 39545d2..738bbc2 100644 --- a/Manual.org +++ b/Manual.org @@ -10,7 +10,10 @@ * Installing and configuring yaVDR with Ansible This is an experimental feature which allows to set up a yaVDR installation based on a normal Ubuntu Server 16.04.x installation using [[http://ansible.com][Ansible]]. +This Manual is written in org-mode for Emacs and can rewrite the complete ansible configuration if you call ~org-babel-tangle~ from within emacs. + * Playbooks +** yavdr07.yml To set up a fully-featured yaVDR installation you can use the ~yavdr07.yml~ Playbook: #+BEGIN_SRC yaml :tangle yavdr07.yml :mkdirp yes --- @@ -21,14 +24,43 @@ To set up a fully-featured yaVDR installation you can use the ~yavdr07.yml~ Play hosts: all become: true roles: - - yavdr-common - - vdr - - yavdr-network - - yavdr-xorg - - yavdr-remote - - grub -#+END_SRC + - yavdr-common # install and configure the basic system + - vdr # install vdr and related packages + - yavdr-network # enable network client capabilities + - samba-install # install samba server + - samba-config # configure samba server + #- nfs-server # install nfs server + #- nfs-config # configure nfs server + - yavdr-xorg # graphical session + - yavdr-remote # remote configuration files, services and scripts + - grub-config # configure grub + + handlers: + - include: handlers/main.yml +#+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 +--- +# file: yavdr07-headless.yml +# this playbook set up a headless yaVDR 0.7 installation + +- name: set up a headless yaVDR server + hosts: all + become: true + roles: + - yavdr-common + - vdr + - yavdr-network + - samba-server + - samba-config + - nfs-server + - nfs-config + - grub-config + handlers: + - include: handlers/main.yml +#+END_SRC * 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: @@ -43,11 +75,15 @@ This playbook can either be used to run the installation on the localhost or any #+END_SRC * Group Variables -#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes :exports none +#+BEGIN_SRC yaml :tangle group_vars/all :mkdirp yes +# file: group_vars/all + +# this is the standard text to put in templates ansible_managed_file: "*** YAVDR: ANSIBLE MANAGED FILE ***" branch: unstable ppa_owner: 'ppa:yavdr' +# a list of all package repositories to be added to the installation repositories: - '{{ ppa_owner }}/main' - '{{ ppa_owner }}/unstable-main' @@ -59,6 +95,14 @@ drivers: sundtek: auto ddvb-dkms: auto +# dictionary of directories for (shared) files. Automatically exported via NFS and Samba if those roles are enabled +media_dirs: + audio: /srv/audio + video: /srv/audio + pictures: /srv/audio + files: /srv/files + +# properties of the user vdr and vdr-related options vdr: user: vdr group: vdr @@ -70,16 +114,27 @@ vdr: safe_dirnames: true override_vdr_charset: false +# add the vdr plugins you want to install vdr_plugins: - vdr-plugin-devstatus - vdr-plugin-markad - vdr-plugin-restfulapi - vdr-plugin-softhddevice +samba: + workgroup: YAVDR + +# additional packages you want to install extra_packages: - vim - tree - w-scan + +system: + shutdown: poweroff + grub: + timeout: 0 + boot_options: quiet nosplash #+END_SRC * Roles ** yavdr-common @@ -89,7 +144,7 @@ Several variables can be set to customize the configuration. **** Repositories You can set a list of package repositories which provide the necessary packages. Feel free to use own PPAs if you need special customization to the VDR and it's plugins. -#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml +#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes --- # file: roles/yavdr-common/defaults/main.yml @@ -103,14 +158,14 @@ repositories: #+END_SRC **** Drivers Automatically installed drivers can be very useful, but if you know you need a certain driver, you can simply set it's value to *true*. If you don't want a driver to be installed, set it's value to *false*. -#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml +#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes drivers: sundtek: auto ddvb-dkms: auto #+END_SRC **** Additional Packages Add additional packages you would like to have on your installation to this list -#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml +#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes extra_packages: - vim - tree @@ -127,7 +182,7 @@ This section allows you to set the recording directory, the user and group that - hide_first_recording_level :: let vdr hide the first directory level of it's recording directory so the content of multiple directories is shown merged together - safe_dirnames :: replace special characters which are not compatible with Windows file systems and Samba shares - override_vdr_charset :: workaround for channels with weird EPG encodings, e.g. Sky -#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml +#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml :mkdirp yes vdr: user: vdr group: vdr @@ -141,26 +196,23 @@ vdr: #+END_SRC *** tasks yavdr-common executes the following tasks: -**** Disable default installation of recommended packages -#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :exports none +#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :exports none :mkdirp yes --- # This playbook sets up the basic packages an directories for a yaVDR installation +# file: roles/yavdr-common/tasks/main.yml #+END_SRC +**** Disable default installation of recommended packages + This configuration file prevents apt to automatically install all recommended dependencies when installing packages: -#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes - name: apt | prevent automatic installation of recommended packages - blockinfile: + template: + src: templates/90-norecommends.j2 dest: /etc/apt/apt.conf.d/90norecommends - create: yes - state: present - marker: "// *** {mark} ANSIBLE MANAGED BLOCK ***" - block: | - // Recommends are as of now still abused in many packages - APT::Install-Recommends "0"; - APT::Install-Suggests "0"; + #+END_SRC **** Setting up the package repositories -#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes - name: add yaVDR PPAs apt_repository: repo: '{{ item }}' @@ -174,7 +226,7 @@ This configuration file prevents apt to automatically install all recommended de update_cache: yes #+END_SRC **** Installing essential packages -#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes - name: apt | install basic packages apt: name: '{{ item }}' @@ -195,6 +247,13 @@ This configuration file prevents apt to automatically install all recommended de - usbutils - xfsprogs #+END_SRC +*** templates +#+BEGIN_SRC shell :tangle roles/yavdr-common/templates/90-norecommends.j2 :mkdirp yes +// {{ ansible_managed_file }} +// Recommends are as of now still abused in many packages +APT::Install-Recommends "0"; +APT::Install-Suggests "0"; +#+END_SRC ** vdr *** tasks #+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes @@ -248,7 +307,7 @@ This configuration file prevents apt to automatically install all recommended de '{{ vdr_plugins }}' #+END_SRC *** Set up the directories for files in /srv -#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml +#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes - name: create directories for media files file: state: directory @@ -294,6 +353,16 @@ install_samba_server: true - vdr-addon-avahi-linker - wakeonlan +# Does this really work? We need a way to check if an interface supports WOL - Python Skript? +# - name: check WOL capabilities of network interfaces +# shell: 'ethtool {{ item }} | grep -Po "(?<=Supports\sWake-on:\s).*$"' +# register: wol +# with_items: '{% for interface in ansible_interfaces if interface != 'lo' and interface != 'bond0' %}' + +#+END_SRC +** nfs-server +*** tasks +#+BEGIN_SRC yaml :tanlge roles/nfs-server/tasks/main.yml :mkdirp yes - name: install and configure nfs-kernel-server apt: name: "{{ item }}" @@ -303,13 +372,6 @@ install_samba_server: true - nfs-kernel-server when: - '{{ install_nfs_server }}' - -# Does this really work? We need a way to check if an interface supports WOL - Python Skript? -# - name: check WOL capabilities of network interfaces -# shell: 'ethtool {{ item }} | grep -Po "(?<=Supports\sWake-on:\s).*$"' -# register: wol -# with_items: '{% for interface in ansible_interfaces if interface != 'lo' and interface != 'bond0' %}' - #+END_SRC ** yavdr-remote *** default variables @@ -394,7 +456,7 @@ install_samba_server: true state: started #+END_SRC *** templates -#+BEGIN_SRC jinja2 :tangle roles/yavdr-xorg/templates/vdr-xorg.conf :mkdirp yes +#+BEGIN_SRC conf :tangle roles/yavdr-xorg/templates/vdr-xorg.conf :mkdirp yes # file: roles/yavdr-xorg/templates/vdr-xorg.conf # {{ ansible_managed_file }} @@ -403,18 +465,212 @@ After=x@vt7.service Wants=x@vt7.service BindsTo=x@vt7.service #+END_SRC -#+BEGIN_SRC jinja2 :tangle roles/yavdr-xorg/templates/.xinitrc.j2 :mkdirp yes +#+BEGIN_SRC sh :tangle roles/yavdr-xorg/templates/.xinitrc.j2 :mkdirp yes #!/bin/bash # {{ ansible_managed_file }} exec openbox-session #+END_SRC -#+BEGIN_SRC jinja2 tangle: ansible/yavdr-ansible/roles/yavdr-xorg/templates/autostart.j2 :mkdirp yes +#+BEGIN_SRC sh tangle: ansible/yavdr-ansible/roles/yavdr-xorg/templates/autostart.j2 :mkdirp yes env | grep "DISPLAY\|DBUS_SESSION_BUS_ADDRESS\|XDG_RUNTIME_DIR" > ~/.session-env systemctl --user import-environment #+END_SRC *** files -** grub -*** default variables +** samba-install *** tasks +#+BEGIN_SRC yaml :tangle roles/samba-install/tasks/main.yml :mkdirp yes +# file: roles/samba-install/tasks/main.yml + +- name: install samba server + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - samba + - samba-common + - samba-common-bin + - tdb-tools + +#+END_SRC +** samba-config +*** tasks +#+BEGIN_SRC yaml :tangle roles/samba-config/tasks/main.yml :mkdirp yes +# file: roles/samba-config/tasks/main.yml + +# TODO: +#- name: divert original smbd.conf + +- name: create smb.conf.custom + file: + state: touch + dest: '/etc/samba/smb.conf.custom' + notify: [ 'Restart Samba' ] + +- name: expand template for smb.conf + template: + src: 'templates/smb.conf.j2' + dest: '/etc/samba/smb.conf' + #validate: 'testparm -s %s' + notify: [ 'Restart Samba' ] +#+END_SRC +*** templates +#+BEGIN_SRC yaml :tangle roles/samba-config/templates/smb.conf.j2 :mkdirp yes +# {{ ansible_managed_file }} + +#======================= Global Settings ======================= + +[global] + +## Browsing/Identification ### + +# Change this to the workgroup/NT-domain name your Samba server will part of + workgroup = {{ samba.workgroup }} + +# server string is the equivalent of the NT Description field + server string = %h server (Samba, Ubuntu) + +# This will prevent nmbd to search for NetBIOS names through DNS. + dns proxy = no + +#### Debugging/Accounting #### + +# This tells Samba to use a separate log file for each machine +# that connects + log file = /var/log/samba/log.%m + +# Cap the size of the individual log files (in KiB). + max log size = 1000 + +# We want Samba to log a minimum amount of information to syslog. Everything +# should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log +# through syslog you should set the following parameter to something higher. + syslog = 0 + +# Do something sensible when Samba crashes: mail the admin a backtrace + panic action = /usr/share/samba/panic-action %d + + +####### Authentication ####### + +# "security = user" is always a good idea. This will require a Unix account +# in this server for every user accessing the server. See +# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html +# in the samba-doc package for details. +# security = user + +# You may wish to use password encryption. See the section on +# 'encrypt passwords' in the smb.conf(5) manpage before enabling. + encrypt passwords = true + +# If you are using encrypted passwords, Samba will need to know what +# password database type you are using. + passdb backend = tdbsam + + obey pam restrictions = yes + +# This boolean parameter controls whether Samba attempts to sync the Unix +# password with the SMB password when the encrypted SMB password in the +# passdb is changed. + unix password sync = yes + +# For Unix password sync to work on a Debian GNU/Linux system, the following +# parameters must be set (thanks to Ian Kahan < for +# sending the correct chat script for the passwd program in Debian Sarge). + passwd program = /usr/bin/passwd %u + passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . + +# This boolean controls whether PAM will be used for password changes +# when requested by an SMB client instead of the program listed in +# 'passwd program'. The default is 'no'. + pam password change = yes + +# This option controls how unsuccessful authentication attempts are mapped +# to anonymous connections + map to guest = bad user + +{% for name, path in media_dirs.iteritems() %} +[{{ name }}] + path = {{ path }} + comment = {{ name }} on %h + browseable = yes + guest ok = yes + writeable = yes + browseable = yes + create mode = 0664 + directory mode = 0775 + force user = {{ vdr.user }} + force group = {{ vdr.group }} + follow symlinks = yes + wide links = yes + +{% endfor %} + +include = /etc/samba/smb.conf.custom +#+END_SRC +** grub-config +*** default variables +#+BEGIN_SRC yaml :tangle roles/grub-config/defaults/main.yml :mkdirp yes +system: + shutdown: poweroff + grub: + timeout: 0 +#+END_SRC +*** tasks +#+BEGIN_SRC yaml :tangle roles/grub-config/tasks/main.yml :mkdirp yes +- name: custom grub configuration for timeout and reboot halt + template: + src: templates/50_custom.j2 + dest: /etc/grub.d/50_custom + mode: '0775' + notify: [ 'Update GRUB' ] + +# TODO: add special case if plymouth is used +- name: let the system boot quietly + lineinfile: + dest: /etc/default/grub + state: present + regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")' + line: '\1{{ system.grub.boot_options}}"' + backrefs: yes + notify: [ 'Update GRUB' ] +#+END_SRC *** templates -*** files +#+BEGIN_SRC sh :tangle roles/grub-config/templates/50-custom.j2 :mkdirp yes +#!/bin/sh +exec tail -n +3 $0 + +# This file is configured by the ansible configuration for yaVDR + +{% if system.shutdown is defined and system.shutdown == 'reboot' %} +menuentry "PowerOff" { + halt +} +{% endif %} + +if [ "${recordfail}" = 1 ]; then + set timeout={{ 3 if system.grub.timeout < 3 else system.grub.timeout }} +else + set timeout={{ system.grub.timeout if system.grub.timeout is defined else 0 }} +fi +#+END_SRC +*** handlers +#+BEGIN_SRC yaml :tangle roles/grub-config/handlers/main.yml :mkdirp yes +- name: Update GRUB + command: update-grub + failed_when: ('error' in grub_register_update.stderr) + register: grub_register_update + + # TODO: Do we need to use grub-set-default? + # https://github.com/yavdr/yavdr-utils/blob/master/events/actions/update-grub +#+END_SRC +* Handlers +#+BEGIN_SRC yaml :tangle handlers/main.yml :mkdirp yes +- name: Restart Samba + systemd: + name: smbd.service + state: restarted + enabled: yes + #masked: no + register: samba_reload + +#+END_SRC diff --git a/group_vars/all b/group_vars/all index d7c68f8..2e05d43 100644 --- a/group_vars/all +++ b/group_vars/all @@ -1,7 +1,11 @@ +# file: group_vars/all + +# this is the standard text to put in templates ansible_managed_file: "*** YAVDR: ANSIBLE MANAGED FILE ***" branch: unstable ppa_owner: 'ppa:yavdr' +# a list of all package repositories to be added to the installation repositories: - '{{ ppa_owner }}/main' - '{{ ppa_owner }}/unstable-main' @@ -13,6 +17,14 @@ drivers: sundtek: auto ddvb-dkms: auto +# dictionary of directories for (shared) files. Automatically exported via NFS and Samba if those roles are enabled +media_dirs: + audio: /srv/audio + video: /srv/audio + pictures: /srv/audio + files: /srv/files + +# properties of the user vdr and vdr-related options vdr: user: vdr group: vdr @@ -24,13 +36,24 @@ vdr: safe_dirnames: true override_vdr_charset: false +# add the vdr plugins you want to install vdr_plugins: - vdr-plugin-devstatus - vdr-plugin-markad - vdr-plugin-restfulapi - vdr-plugin-softhddevice +samba: + workgroup: YAVDR + +# additional packages you want to install extra_packages: - vim - tree - w-scan + +system: + shutdown: poweroff + grub: + timeout: 0 + boot_options: quiet nosplash diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..ae933c4 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,7 @@ +- name: Restart Samba + systemd: + name: smbd.service + state: restarted + enabled: yes + #masked: no + register: samba_reload diff --git a/roles/grub-config/defaults/main.yml b/roles/grub-config/defaults/main.yml new file mode 100644 index 0000000..e800fd2 --- /dev/null +++ b/roles/grub-config/defaults/main.yml @@ -0,0 +1,4 @@ +system: + shutdown: poweroff + grub: + timeout: 0 diff --git a/roles/grub-config/handlers/main.yml b/roles/grub-config/handlers/main.yml new file mode 100644 index 0000000..a7e3e2c --- /dev/null +++ b/roles/grub-config/handlers/main.yml @@ -0,0 +1,7 @@ +- name: Update GRUB + command: update-grub + failed_when: ('error' in grub_register_update.stderr) + register: grub_register_update + + # TODO: Do we need to use grub-set-default? + # https://github.com/yavdr/yavdr-utils/blob/master/events/actions/update-grub diff --git a/roles/grub-config/tasks/main.yml b/roles/grub-config/tasks/main.yml new file mode 100644 index 0000000..d1593a1 --- /dev/null +++ b/roles/grub-config/tasks/main.yml @@ -0,0 +1,16 @@ +- name: custom grub configuration for timeout and reboot halt + template: + src: templates/50_custom.j2 + dest: /etc/grub.d/50_custom + mode: '0775' + notify: [ 'Update GRUB' ] + +# TODO: add special case if plymouth is used +- name: let the system boot quietly + lineinfile: + dest: /etc/default/grub + state: present + regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")' + line: '\1{{ system.grub.boot_options}}"' + backrefs: yes + notify: [ 'Update GRUB' ] diff --git a/roles/grub-config/templates/50-custom.j2 b/roles/grub-config/templates/50-custom.j2 new file mode 100644 index 0000000..461f370 --- /dev/null +++ b/roles/grub-config/templates/50-custom.j2 @@ -0,0 +1,16 @@ +#!/bin/sh +exec tail -n +3 $0 + +# This file is configured by the ansible configuration for yaVDR + +{% if system.shutdown is defined and system.shutdown == 'reboot' %} +menuentry "PowerOff" { + halt +} +{% endif %} + +if [ "${recordfail}" = 1 ]; then + set timeout={{ 3 if system.grub.timeout < 3 else system.grub.timeout }} +else + set timeout={{ system.grub.timeout if system.grub.timeout is defined else 0 }} +fi diff --git a/roles/samba-config/tasks/main.yml b/roles/samba-config/tasks/main.yml new file mode 100644 index 0000000..7e36013 --- /dev/null +++ b/roles/samba-config/tasks/main.yml @@ -0,0 +1,17 @@ +# file: roles/samba-config/tasks/main.yml + +# TODO: +#- name: divert original smbd.conf + +- name: create smb.conf.custom + file: + state: touch + dest: '/etc/samba/smb.conf.custom' + notify: [ 'Restart Samba' ] + +- name: expand template for smb.conf + template: + src: 'templates/smb.conf.j2' + dest: '/etc/samba/smb.conf' + #validate: 'testparm -s %s' + notify: [ 'Restart Samba' ] diff --git a/roles/samba-config/templates/smb.conf.j2 b/roles/samba-config/templates/smb.conf.j2 new file mode 100644 index 0000000..42dabcf --- /dev/null +++ b/roles/samba-config/templates/smb.conf.j2 @@ -0,0 +1,91 @@ +# {{ ansible_managed_file }} + +#======================= Global Settings ======================= + +[global] + +## Browsing/Identification ### + +# Change this to the workgroup/NT-domain name your Samba server will part of + workgroup = {{ samba.workgroup }} + +# server string is the equivalent of the NT Description field + server string = %h server (Samba, Ubuntu) + +# This will prevent nmbd to search for NetBIOS names through DNS. + dns proxy = no + +#### Debugging/Accounting #### + +# This tells Samba to use a separate log file for each machine +# that connects + log file = /var/log/samba/log.%m + +# Cap the size of the individual log files (in KiB). + max log size = 1000 + +# We want Samba to log a minimum amount of information to syslog. Everything +# should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log +# through syslog you should set the following parameter to something higher. + syslog = 0 + +# Do something sensible when Samba crashes: mail the admin a backtrace + panic action = /usr/share/samba/panic-action %d + + +####### Authentication ####### + +# "security = user" is always a good idea. This will require a Unix account +# in this server for every user accessing the server. See +# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html +# in the samba-doc package for details. +# security = user + +# You may wish to use password encryption. See the section on +# 'encrypt passwords' in the smb.conf(5) manpage before enabling. + encrypt passwords = true + +# If you are using encrypted passwords, Samba will need to know what +# password database type you are using. + passdb backend = tdbsam + + obey pam restrictions = yes + +# This boolean parameter controls whether Samba attempts to sync the Unix +# password with the SMB password when the encrypted SMB password in the +# passdb is changed. + unix password sync = yes + +# For Unix password sync to work on a Debian GNU/Linux system, the following +# parameters must be set (thanks to Ian Kahan < for +# sending the correct chat script for the passwd program in Debian Sarge). + passwd program = /usr/bin/passwd %u + passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . + +# This boolean controls whether PAM will be used for password changes +# when requested by an SMB client instead of the program listed in +# 'passwd program'. The default is 'no'. + pam password change = yes + +# This option controls how unsuccessful authentication attempts are mapped +# to anonymous connections + map to guest = bad user + +{% for name, path in media_dirs.iteritems() %} +[{{ name }}] + path = {{ path }} + comment = {{ name }} on %h + browseable = yes + guest ok = yes + writeable = yes + browseable = yes + create mode = 0664 + directory mode = 0775 + force user = {{ vdr.user }} + force group = {{ vdr.group }} + follow symlinks = yes + wide links = yes + +{% endfor %} + +include = /etc/samba/smb.conf.custom diff --git a/roles/samba-install/tasks/main.yml b/roles/samba-install/tasks/main.yml new file mode 100644 index 0000000..2c6358a --- /dev/null +++ b/roles/samba-install/tasks/main.yml @@ -0,0 +1,12 @@ +# file: roles/samba-install/tasks/main.yml + +- name: install samba server + apt: + name: '{{ item }}' + state: present + install_recommends: no + with_items: + - samba + - samba-common + - samba-common-bin + - tdb-tools diff --git a/roles/yavdr-common/files/90-norecommends.j2 b/roles/yavdr-common/files/90-norecommends.j2 new file mode 100644 index 0000000..a4b9ce7 --- /dev/null +++ b/roles/yavdr-common/files/90-norecommends.j2 @@ -0,0 +1,4 @@ +// {{ ansible_managed_file }} +// Recommends are as of now still abused in many packages +APT::Install-Recommends "0"; +APT::Install-Suggests "0"; diff --git a/roles/yavdr-common/tasks/main.yml b/roles/yavdr-common/tasks/main.yml index b8b2f73..a7a00a3 100644 --- a/roles/yavdr-common/tasks/main.yml +++ b/roles/yavdr-common/tasks/main.yml @@ -1,16 +1,11 @@ --- # This playbook sets up the basic packages an directories for a yaVDR installation +# file: roles/yavdr-common/tasks/main.yml - name: apt | prevent automatic installation of recommended packages - blockinfile: + template: + src: templates/90-norecommends.j2 dest: /etc/apt/apt.conf.d/90norecommends - create: yes - state: present - marker: "// *** {mark} ANSIBLE MANAGED BLOCK ***" - block: | - // Recommends are as of now still abused in many packages - APT::Install-Recommends "0"; - APT::Install-Suggests "0"; - name: add yaVDR PPAs apt_repository: diff --git a/roles/yavdr-common/templates/90-norecommends.j2 b/roles/yavdr-common/templates/90-norecommends.j2 new file mode 100644 index 0000000..a4b9ce7 --- /dev/null +++ b/roles/yavdr-common/templates/90-norecommends.j2 @@ -0,0 +1,4 @@ +// {{ ansible_managed_file }} +// Recommends are as of now still abused in many packages +APT::Install-Recommends "0"; +APT::Install-Suggests "0"; diff --git a/roles/yavdr-network/tasks/main.yml b/roles/yavdr-network/tasks/main.yml index 4da68ca..b058c4e 100644 --- a/roles/yavdr-network/tasks/main.yml +++ b/roles/yavdr-network/tasks/main.yml @@ -15,16 +15,6 @@ - vdr-addon-avahi-linker - wakeonlan -- name: install and configure nfs-kernel-server - apt: - name: "{{ item }}" - state: present - install_recommends: no - with_items: - - nfs-kernel-server - when: - - '{{ install_nfs_server }}' - # Does this really work? We need a way to check if an interface supports WOL - Python Skript? # - name: check WOL capabilities of network interfaces # shell: 'ethtool {{ item }} | grep -Po "(?<=Supports\sWake-on:\s).*$"' diff --git a/yavdr07-headless.yml b/yavdr07-headless.yml index acb28d4..cd2e867 100644 --- a/yavdr07-headless.yml +++ b/yavdr07-headless.yml @@ -1,9 +1,18 @@ --- - # this playbook set up an yaVDR 0.7 installation - - name: basic setup for PPAs, packages etc. - hosts: yavdr-full - become: true - roles: - - yavdr-common - - yavdr-network - - grub +# file: yavdr07-headless.yml +# this playbook set up a headless yaVDR 0.7 installation + +- name: set up a headless yaVDR server + hosts: all + become: true + roles: + - yavdr-common + - vdr + - yavdr-network + - samba-server + - samba-config + - nfs-server + - nfs-config + - grub-config + handlers: + - include: handlers/main.yml diff --git a/yavdr07.yml b/yavdr07.yml index 76edf75..c70545f 100644 --- a/yavdr07.yml +++ b/yavdr07.yml @@ -6,9 +6,17 @@ hosts: all become: true roles: - - yavdr-common - - vdr - - yavdr-network - - yavdr-xorg - - yavdr-remote - - grub + - yavdr-common # install and configure the basic system + - vdr # install vdr and related packages + - yavdr-network # enable network client capabilities + - samba-install # install samba server + - samba-config # configure samba server + #- nfs-server # install nfs server + #- nfs-config # configure nfs server + - yavdr-xorg # graphical session + - yavdr-remote # remote configuration files, services and scripts + - grub-config # configure grub + + + handlers: + - include: handlers/main.yml From bf6b434fcec48818360b9d4c055fb766a54d10e4 Mon Sep 17 00:00:00 2001 From: Alexander Grothe Date: Thu, 23 Feb 2017 13:15:32 +0100 Subject: [PATCH 3/3] delete old grub role --- roles/grub/defaults/main.yml | 4 ---- roles/grub/handlers/main.yml | 7 ------- roles/grub/tasks/main.yml | 15 --------------- roles/grub/templates/50_custom.j2 | 17 ----------------- 4 files changed, 43 deletions(-) delete mode 100644 roles/grub/defaults/main.yml delete mode 100644 roles/grub/handlers/main.yml delete mode 100644 roles/grub/tasks/main.yml delete mode 100644 roles/grub/templates/50_custom.j2 diff --git a/roles/grub/defaults/main.yml b/roles/grub/defaults/main.yml deleted file mode 100644 index adcb1d7..0000000 --- a/roles/grub/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -system: - shutdown: reboot - grub: - timeout: 0 diff --git a/roles/grub/handlers/main.yml b/roles/grub/handlers/main.yml deleted file mode 100644 index a7e3e2c..0000000 --- a/roles/grub/handlers/main.yml +++ /dev/null @@ -1,7 +0,0 @@ -- name: Update GRUB - command: update-grub - failed_when: ('error' in grub_register_update.stderr) - register: grub_register_update - - # TODO: Do we need to use grub-set-default? - # https://github.com/yavdr/yavdr-utils/blob/master/events/actions/update-grub diff --git a/roles/grub/tasks/main.yml b/roles/grub/tasks/main.yml deleted file mode 100644 index 5277c73..0000000 --- a/roles/grub/tasks/main.yml +++ /dev/null @@ -1,15 +0,0 @@ -- name: custom grub configuration for timeout and reboot halt - template: - src: templates/50_custom.j2 - dest: /etc/grub.d/50_custom - mode: '0775' - notify: [ 'Update GRUB' ] - -- name: let the system boot quietly - lineinfile: - dest: /etc/default/grub - state: present - regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")' - line: '\1quiet nosplash"' - backrefs: yes - notify: [ 'Update GRUB' ] diff --git a/roles/grub/templates/50_custom.j2 b/roles/grub/templates/50_custom.j2 deleted file mode 100644 index a7e5be3..0000000 --- a/roles/grub/templates/50_custom.j2 +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -exec tail -n +3 $0 - -# This file is configured by the ansible configuration for yaVDR - -{% if system.shutdown is defined and system.shutdown == 'reboot' %} -menuentry "PowerOff" { - halt -} -{% endif %} - -if [ "${recordfail}" = 1 ]; then - set timeout={{ 3 if system.grub.timeout < 3 else system.grub.timeout }} -else - set timeout={{ system.grub.timeout if system.grub.timeout is defined else 0 }} -fi -