From efac4618fa395a6b0b1cf7be861bd09c7c331df0 Mon Sep 17 00:00:00 2001 From: Alexander Grothe Date: Mon, 20 Feb 2017 14:29:15 +0100 Subject: [PATCH] Trying some literate programming for this playbook --- Manual.org | 192 +++++++++++++++++++++++++++ roles/yavdr-common/defaults/main.yml | 22 +-- roles/yavdr-common/tasks/main.yml | 14 +- yavdr07.yml | 12 +- 4 files changed, 215 insertions(+), 25 deletions(-) create mode 100644 Manual.org diff --git a/Manual.org b/Manual.org new file mode 100644 index 0000000..580f3fe --- /dev/null +++ b/Manual.org @@ -0,0 +1,192 @@ +#+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 +#+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 +#+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-headless] + + [yavdr-client] + +#+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 +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. +#+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' +#+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*. +#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml +drivers: + sundtek: auto + ddvb-dkms: auto +#+END_SRC +**** Additional Packages +#+BEGIN_SRC yaml :tangle roles/yavdr-common/defaults/main.yml + extra_packages: + - vim + - tree + - w-scan +#+END_SRC +**** VDR +This section allows you to set the recording directory, the user and group that runs the vdr and it's home directory. + - user :: the vdr user name + - group :: the main group for the user vdr + - uid :: the user id for the user vdr + - gid :: the group id for the group vdr + - home :: the home directory for the user vdr + - recdir :: the recording directory used by VDR + - 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 +vdr: + user: vdr + group: vdr + uid: 666 + gid: 666 + home: /var/lib/vdr + recdir: /srv/vdr/video + hide_first_recording_level: true + safe_dirnames: true + override_vdr_charset: false +#+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 +--- +# This playbook sets up the basic packages an directories for a yaVDR installation +#+END_SRC + +#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml +- name: apt| prevent installation of recommended packages + blockinfile: + 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 +- name: add yaVDR PPAs + apt_repository: + repo: '{{ item }}' + state: present + update_cache: yes + with_items: '{{ repositories }}' + +- name: upgrade existing packages + apt: + upgrade: dist + update_cache: yes +#+END_SRC +**** Installing essential packages +#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml +- name: 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 + - 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 }}' + +- 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 }}' + with_items: + - /srv/videos + - /srv/music + - /srv/picture + - /srv/backups +#+END_SRC + diff --git a/roles/yavdr-common/defaults/main.yml b/roles/yavdr-common/defaults/main.yml index 2183084..7803d37 100644 --- a/roles/yavdr-common/defaults/main.yml +++ b/roles/yavdr-common/defaults/main.yml @@ -1,24 +1,28 @@ + +branch: unstable repositories: - branch: unstable - sources: - - 'ppa:yavdr/main' - - 'ppa:yavdr/unstable-main' - - 'ppa:yavdr/unstable-vdr' - - 'ppa:yavdr/unstable-kodi' - - 'ppa:yavdr/unstable-yavdr' + - 'ppa:yavdr/main' + - 'ppa:yavdr/unstable-main' + - 'ppa:yavdr/{{branch}}-vdr' + - 'ppa:yavdr/{{branch}}-kodi' + - 'ppa:yavdr/{{branch}}-yavdr' drivers: sundtek: auto - satip: auto ddvb-dkms: auto - imon: auto +extra_packages: + - vim + - tree + - w-scan vdr: user: vdr group: vdr uid: 666 gid: 666 + home: /var/lib/vdr recdir: /srv/vdr/video hide_first_recording_level: true safe_dirnames: true + override_vdr_charset: false diff --git a/roles/yavdr-common/tasks/main.yml b/roles/yavdr-common/tasks/main.yml index b6a50b2..e792d21 100644 --- a/roles/yavdr-common/tasks/main.yml +++ b/roles/yavdr-common/tasks/main.yml @@ -1,10 +1,6 @@ + --- -# this playbook sets up a minimum yaVDR installation -# -# You can customize the following variables: -# repositories.sources: a list of package repositories to use -# vdr: a dictionary with several customization options for the vdr-configuration. -# See defaults/main.yml for a complete reference +# This playbook sets up the basic packages an directories for a yaVDR installation - name: apt| prevent installation of recommended packages blockinfile: @@ -22,7 +18,7 @@ repo: '{{ item }}' state: present update_cache: yes - with_items: '{{ repositories.sources }}' + with_items: '{{ repositories }}' - name: upgrade existing packages apt: @@ -47,14 +43,10 @@ - vdr - vdr-plugin-dbus2vdr - vdrctl - - vim - - w-scan - wget - wpasupplicant - usbutils - xfsprogs - #- yavdr-firmware - - name: create vdr recdir file: diff --git a/yavdr07.yml b/yavdr07.yml index 5b6bdbf..c2d4884 100644 --- a/yavdr07.yml +++ b/yavdr07.yml @@ -1,9 +1,11 @@ + --- - # this playbook set up an yaVDR 0.7 installation - - name: basic setup for PPAs, packages etc. - hosts: yavdr-full - become: true - roles: +# this playbook sets up a fully featured yaVDR 0.7 installation + +- name: basic setup for PPAs, packages etc. + hosts: yavdr-full + become: true + roles: - yavdr-common - yavdr-network - yavdr-xorg