Fix indentations

This commit is contained in:
Alexander Grothe 2017-03-02 09:06:19 +01:00
parent 5219bdc4e5
commit 54c7d091fd
6 changed files with 160 additions and 187 deletions

View File

@ -218,87 +218,81 @@ vdr:
yavdr-common executes the following tasks: yavdr-common executes the following tasks:
**** main.yml **** main.yml
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :exports none :mkdirp yes #+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 # This playbook sets up the basic packages an directories for a yaVDR installation
# file: roles/yavdr-common/tasks/main.yml
#+END_SRC #+END_SRC
***** Disable default installation of recommended packages ***** Disable default installation of recommended packages
This task prevents apt to automatically install all recommended dependencies for 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
- name: apt | prevent automatic installation of recommended packages - name: apt | prevent automatic installation of recommended packages
template: template:
src: templates/90-norecommends.j2 src: templates/90-norecommends.j2
dest: /etc/apt/apt.conf.d/90norecommends dest: /etc/apt/apt.conf.d/90norecommends
#+END_SRC #+END_SRC
***** Setting up the package repositories ***** Setting up the package repositories
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes #+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes
- name: add yaVDR PPAs - name: add yaVDR PPAs
apt_repository: apt_repository:
repo: '{{ item }}' repo: '{{ item }}'
state: present state: present
update_cache: yes update_cache: yes
with_items: '{{ repositories }}' with_items: '{{ repositories }}'
- name: upgrade existing packages - name: upgrade existing packages
apt: apt:
upgrade: dist upgrade: dist
update_cache: yes update_cache: yes
#+END_SRC #+END_SRC
***** Installing essential packages ***** Installing essential 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
- name: apt | install basic packages - name: apt | install basic packages
apt: apt:
name: '{{ item }}' name: '{{ item }}'
state: present state: present
install_recommends: no install_recommends: no
with_items: with_items:
- anacron - anacron
- at - at
- bash-completion - bash-completion
- biosdevname - biosdevname
- linux-firmware - linux-firmware
- psmisc - psmisc
- software-properties-common - software-properties-common
- ssh - ssh
- ubuntu-drivers-common - ubuntu-drivers-common
- wget - wget
- wpasupplicant - wpasupplicant
- usbutils - usbutils
- xfsprogs - xfsprogs
#+END_SRC #+END_SRC
***** install and execute local fact scripts ***** install and execute local fact scripts
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes #+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :mkdirp yes
- name: install and execute local fact scripts - name: create directory for local facts
- include: file:
- tasks/local_facts.yml dest: /etc/ansible/facts.d
state: directory
- name: copy facts script for USB- and PCI(e)-IDs
copy:
src: files/hardware.facts.py
dest: /etc/ansible/facts.d/hardware.facts
mode: '0775'
- name: copy facts script for Sat>IP server detection
copy:
src: files/satip.facts.py
dest: /etc/ansible/facts.d/satip.facts
mode: '0775'
- name: reload ansible local facts
setup: filter=ansible_local
#+END_SRC #+END_SRC
**** local_facts.yml
#+BEGIN_SRC yaml :tangle roles/yavdr-common/tasks/main.yml :exports none :mkdirp yes
---
# file: local_facts.yml
- name: create directory for local facts
file:
dest: /etc/ansible/facts.d
state: directory
- name: copy facts script for USB- and PCI(e)-IDs
copy:
src: files/hardware.facts.py
dest: /etc/ansible/facts.d/hardware.facts
mode: '0775'
- name: copy facts script for Sat>IP server detection
copy:
src: files/satip.facts.py
dest: /etc/ansible/facts.d/satip.facts
mode: '0775'
- name: reload ansible local facts
setup: filter=ansible_local
#+END_SRC
*** files: *** files:
#+BEGIN_SRC python :tangle roles/yavdr-common/files/hardware.facts.py :mkdirp yes #+BEGIN_SRC python :tangle roles/yavdr-common/files/hardware.facts.py :mkdirp yes
#!/usr/bin/env python3 #!/usr/bin/env python3
@ -387,73 +381,73 @@ APT::Install-Suggests "0";
*** tasks *** tasks
**** install the basic vdr packages **** 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
--- ---
# file: roles/vdr/tasks/main.yml # file: roles/vdr/tasks/main.yml
- name: apt | install basic vdr packages - name: apt | install basic vdr packages
apt: apt:
name: '{{ item }}' name: '{{ item }}'
state: present state: present
install_recommends: no install_recommends: no
with_items: with_items:
- vdr - vdr
- vdrctl - vdrctl
- vdr-plugin-dbus2vdr - vdr-plugin-dbus2vdr
#+END_SRC #+END_SRC
**** Add svdrp/svdrp-disc to /etc/services **** Add svdrp/svdrp-disc to /etc/services
#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes #+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes
- name: add svdrp to /etc/services - name: add svdrp to /etc/services
lineinfile: lineinfile:
dest: /etc/services dest: /etc/services
state: present state: present
line: "svdrp 6419/tcp" line: "svdrp 6419/tcp"
- name: add svdrp-disc to /etc/services - name: add svdrp-disc to /etc/services
lineinfile: lineinfile:
dest: /etc/services dest: /etc/services
state: present state: present
line: "svdrp-disc 6419/udp" line: "svdrp-disc 6419/udp"
#+END_SRC #+END_SRC
**** Set up the recording directory for the vdr user **** Set up the recording directory for the vdr user
#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes #+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes
- name: create vdr recdir - name: create vdr recdir
file: file:
state: directory state: directory
owner: '{{ vdr.user }}' owner: '{{ vdr.user }}'
group: '{{ vdr.group }}' group: '{{ vdr.group }}'
mode: 0775 mode: 0775
dest: '{{ vdr.recdir }}' dest: '{{ vdr.recdir }}'
- name: set option to use hide-first-recording-level patch - name: set option to use hide-first-recording-level patch
blockinfile: blockinfile:
dest: /etc/vdr/conf.d/04-vdr-hide-first-recordinglevel.conf dest: /etc/vdr/conf.d/04-vdr-hide-first-recordinglevel.conf
create: true create: true
block: | block: |
[vdr] [vdr]
--hide-first-recording-level --hide-first-recording-level
when: when:
vdr.hide_first_recording_level vdr.hide_first_recording_level
- name: create local dir in recdir - name: create local dir in recdir
file: file:
state: directory state: directory
owner: '{{ vdr.user }}' owner: '{{ vdr.user }}'
group: '{{ vdr.group }}' group: '{{ vdr.group }}'
mode: '0775' mode: '0775'
dest: '{{ vdr.recdir }}/local' dest: '{{ vdr.recdir }}/local'
when: when:
vdr.hide_first_recording_level vdr.hide_first_recording_level
#+END_SRC #+END_SRC
**** Install additional vdr plugins **** Install additional vdr plugins
The additional plugins to install can be set in the variable ~{{vdr_plugins}}~ in the group variables The additional plugins to install can be set in the variable ~{{vdr_plugins}}~ in the group variables
#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes #+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes
- name: install additional vdr plugins - name: install additional vdr plugins
apt: apt:
name: '{{ item }}' name: '{{ item }}'
state: present state: present
install_recommends: no install_recommends: no
with_items: with_items:
'{{ vdr_plugins | default({}) }}' '{{ vdr_plugins | default({}) }}'
#+END_SRC #+END_SRC
*** Set up the directories for files in /srv *** Set up the directories for files in /srv
#+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes #+BEGIN_SRC yaml :tangle roles/vdr/tasks/main.yml :mkdirp yes
@ -541,12 +535,12 @@ After=x@vt7.service
Wants=x@vt7.service Wants=x@vt7.service
BindsTo=x@vt7.service BindsTo=x@vt7.service
#+END_SRC #+END_SRC
#+BEGIN_SRC sh :tangle roles/yavdr-xorg/templates/.xinitrc.j2 :mkdirp yes #+BEGIN_SRC shell :tangle roles/yavdr-xorg/templates/.xinitrc.j2 :mkdirp yes
#!/bin/bash #!/bin/bash
# {{ ansible_managed_file }} # {{ ansible_managed_file }}
exec openbox-session exec openbox-session
#+END_SRC #+END_SRC
#+BEGIN_SRC sh tangle: ansible/yavdr-ansible/roles/yavdr-xorg/templates/autostart.j2 :mkdirp yes #+BEGIN_SRC shell tangle: ansible/yavdr-ansible/roles/yavdr-xorg/templates/autostart.j2 :mkdirp yes
env | grep "DISPLAY\|DBUS_SESSION_BUS_ADDRESS\|XDG_RUNTIME_DIR" > ~/.session-env env | grep "DISPLAY\|DBUS_SESSION_BUS_ADDRESS\|XDG_RUNTIME_DIR" > ~/.session-env
systemctl --user import-environment systemctl --user import-environment
#+END_SRC #+END_SRC
@ -787,7 +781,7 @@ system:
notify: [ 'Update GRUB' ] notify: [ 'Update GRUB' ]
#+END_SRC #+END_SRC
*** templates *** templates
#+BEGIN_SRC sh :tangle roles/grub-config/templates/50-custom.j2 :mkdirp yes #+BEGIN_SRC shell :tangle roles/grub-config/templates/50_custom.j2 :mkdirp yes
#!/bin/sh #!/bin/sh
exec tail -n +3 $0 exec tail -n +3 $0

View File

@ -13,10 +13,10 @@ drivers:
sundtek: auto sundtek: auto
ddvb-dkms: auto ddvb-dkms: auto
extra_packages: extra_packages:
- vim - vim
- tree - tree
- w-scan - w-scan
vdr: vdr:
user: vdr user: vdr

View File

@ -1,43 +1,43 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# This script sends a multicast message and awaits responses by Sat>IP servers. # This script sends a multicast message and awaits responses by Sat>IP servers.
# returns the boolean variable 'satip_detected' as json # returns the boolean variable 'satip_detected' as json
import json import json
import socket import socket
import sys import sys
import time import time
SSDP_ADDR = "239.255.255.250" SSDP_ADDR = "239.255.255.250"
SSDP_PORT = 1900 SSDP_PORT = 1900
# SSDP_MX = max delay for server response # SSDP_MX = max delay for server response
# a value of 2s is recommended by the SAT>IP specification 1.2.2 # a value of 2s is recommended by the SAT>IP specification 1.2.2
SSDP_MX = 2 SSDP_MX = 2
SSDP_ST = "urn:ses-com:device:SatIPServer:1" SSDP_ST = "urn:ses-com:device:SatIPServer:1"
ssdpRequest = "\r\n".join(( ssdpRequest = "\r\n".join((
"M-SEARCH * HTTP/1.1", "M-SEARCH * HTTP/1.1",
"HOST: %s:%d" % (SSDP_ADDR, SSDP_PORT), "HOST: %s:%d" % (SSDP_ADDR, SSDP_PORT),
"MAN: \"ssdp:discover\"", "MAN: \"ssdp:discover\"",
"MX: %d" % (SSDP_MX), "MX: %d" % (SSDP_MX),
"ST: %s" % (SSDP_ST), "ST: %s" % (SSDP_ST),
"\r\n")) "\r\n"))
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# according to Sat>IP Specification 1.2.2, p. 20 # according to Sat>IP Specification 1.2.2, p. 20
# a client should send three requests within 100 ms with a ttl of 2 # a client should send three requests within 100 ms with a ttl of 2
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2) sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
sock.settimeout(SSDP_MX + 0.5) sock.settimeout(SSDP_MX + 0.5)
for _ in range(3): for _ in range(3):
sock.sendto(ssdpRequest.encode('ascii'), (SSDP_ADDR, SSDP_PORT)) sock.sendto(ssdpRequest.encode('ascii'), (SSDP_ADDR, SSDP_PORT))
time.sleep(0.03) time.sleep(0.03)
try: try:
response = sock.recv(1000).decode() response = sock.recv(1000).decode()
if response and "SERVER:" in response: if response and "SERVER:" in response:
got_response = True got_response = True
else: else:
raise ValueError('No satip server detected') raise ValueError('No satip server detected')
except (socket.timeout, ValueError): except (socket.timeout, ValueError):
got_response = False got_response = False
finally: finally:
print(json.dumps( print(json.dumps(
{'satip_detected': got_response} {'satip_detected': got_response}
)) ))

View File

@ -1,15 +0,0 @@
---
# file: local_facts.yml
- name: create directory for local facts
file:
dest: /etc/ansible/facts.d
state: directory
- name: copy facts script for USB- and PCI(e)-IDs
copy:
src: files/hardware.facts.py
dest: /etc/ansible/facts.d/hardware.facts
mode: '0775'
- name: get local facts
setup:

View File

@ -1,11 +1,12 @@
--- ---
# This playbook sets up the basic packages an directories for a yaVDR installation # This playbook sets up the basic packages an directories for a yaVDR installation
# file: roles/yavdr-common/tasks/main.yml # file: roles/yavdr-common/tasks/main.yml
- name: apt | prevent automatic installation of recommended packages - name: apt | prevent automatic installation of recommended packages
template: template:
src: templates/90-norecommends.j2 src: templates/90-norecommends.j2
dest: /etc/apt/apt.conf.d/90norecommends dest: /etc/apt/apt.conf.d/90norecommends
- name: add yaVDR PPAs - name: add yaVDR PPAs
apt_repository: apt_repository:
@ -39,13 +40,6 @@
- usbutils - usbutils
- xfsprogs - xfsprogs
- name: install and execute local fact scripts
- include:
- tasks/local_facts.yml
---
# file: local_facts.yml
- name: create directory for local facts - name: create directory for local facts
file: file:
dest: /etc/ansible/facts.d dest: /etc/ansible/facts.d