Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit c271aa5

Browse files
committed
Merge branch 'release/0.3.0'
2 parents 8846d27 + 3e31017 commit c271aa5

File tree

12 files changed

+193
-24
lines changed

12 files changed

+193
-24
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ansible-rpi 0.2.0
1+
# ansible-rpi 0.3.0
22

33
## Purpose
44

@@ -30,6 +30,7 @@ Make Raspberry Pi up and running in a few command
3030
- Kodi basic installation
3131
- Dynamic sources creation (*may be linked to previously configured network folders*)
3232
- Buffer handling
33+
- Optionnal minimal Openbox setup (*when using a lite image for eg.*)
3334

3435
### Incoming
3536

@@ -55,6 +56,12 @@ cp variables.yml.inc host_vars/my-host.yml
5556

5657
First update the `hosts` file to target your Rpis.
5758

59+
I recommend using an up-to-date Raspbian Lite image.
60+
61+
Make sure that the Rpi is SSHable (**latest raspbian lite images come with SSH
62+
disabled by default, creating a file with name "ssh" in boot partition is
63+
required to enable it.**).
64+
5865
Then the first time run:
5966

6067
```

playbook.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@
1515
- download_server
1616

1717
become: yes
18+
19+
- name: Setup a media center
20+
21+
hosts: media_centers
22+
roles:
23+
- media_center
24+
25+
become: yes

roles/common/tasks/base.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,17 @@
77
apt: upgrade=yes
88
register: upgrade_distribution
99

10-
# See https://www.raspberrypi.org/documentation/configuration/config-txt.md
11-
- name: Update boot config for HDMI
12-
lineinfile: line='hdmi_safe=1'
13-
dest=/boot/config.txt
14-
regexp="^hdmi_safe="
15-
state=present
16-
register: update_config
17-
1810
- name: Rebooting Rpi
1911
shell: sleep 2 && shutdown -r now "Ansible updates triggered"
2012
async: 1
2113
poll: 0
2214
ignore_errors: true
23-
when: (upgrade_distribution|changed) or (update_config|changed)
15+
when: upgrade_distribution|changed
2416

2517
- name: Waiting for server to come back
2618
local_action: wait_for host={{ inventory_hostname }} state=started delay=30 timeout=300
2719
become: false
28-
when: (upgrade_distribution|changed) or (update_config|changed)
20+
when: upgrade_distribution|changed
2921

3022
- name: Setup locale
3123
lineinfile: dest=/etc/locale.gen regexp="^#{{item}}" line="{{item}}"
@@ -45,9 +37,9 @@
4537

4638
- name: Create new Rpi owner
4739
user: name={{ rpi_user_name }}
48-
groups={{ rpi_shared_group }},pi,adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi
40+
groups={{ rpi_shared_group }},pi,adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi,tty
4941
password={{ rpi_user_password_hash }}
50-
shell={{ '/bin/zsh' if with_zsh else '/bin/bash' }}
42+
shell=/bin/bash
5143
append=yes
5244
state=present
5345

roles/common/tasks/hostname.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
- name: Avahi Zeroconf Daemon ports
2828
ufw: rule=allow port=5353 proto=udp
29-
notify: Enable firewall
29+
notify: Reload firewall
3030

3131
- name: Reload facts
3232
setup:

roles/common/tasks/zsh.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@
1717
lineinfile: dest=~/.zshrc regexp="^ZSH_THEME" line="ZSH_THEME=\"{{ rpi_zsh_theme|default('junkfood') }}\"" state=present
1818
become: yes
1919
become_user: "{{ rpi_user_name }}"
20+
21+
- name: Update user default shell
22+
user: name={{ rpi_user_name }}
23+
shell=/bin/zsh
24+
state=present

roles/media_center/defaults/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
kodi_apt_repo: "deb http://http.debian.net/debian jessie-backports main"
1+
kodi_apt_repo: "deb http://pipplware.pplware.pt/pipplware/dists/jessie/main/binary /"
22
kodi_user_dir: /home/{{ rpi_user_name }}/.kodi
3+
openbox_config_dir: /home/{{ rpi_user_name }}/.config/openbox
34

45
# Arrays of filepaths
56
# Inspired by https://github.com/cmprescott/ansible-role-kodi
@@ -12,3 +13,5 @@ kodi_source_videos: []
1213
with_kodi_buffering: False
1314
kodi_read_buffer_factor: 20
1415
kodi_buffer_size: 139460608
16+
17+
with_kodi_desktop: False

roles/media_center/tasks/desktop.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
3+
# https://www.prahladyeri.com/blog/2016/02/minimal-debian-desktop-setup.html
4+
- name: Install packages for a minimal desktop
5+
apt: name={{ item }} state=latest
6+
with_items:
7+
- network-manager
8+
- xorg
9+
- openbox
10+
- xdm
11+
- xbacklight
12+
- pcmanfm
13+
- lxappearance
14+
- lxpanel
15+
- gmrun
16+
- gnome-terminal
17+
18+
- name: Create openbox config directory
19+
file: path="{{ openbox_config_dir }}" owner="{{ rpi_user_name }}" group="{{ rpi_user_name }}" state=directory
20+
register: create_openbox_config
21+
22+
- name: Setting up default Openbox config
23+
shell: cp /etc/xdg/openbox/* "{{ openbox_config_dir }}"
24+
become: yes
25+
become_user: "{{ rpi_user_name }}"
26+
when: create_openbox_config|changed
27+
28+
- name: Enforce lxpanel opening
29+
lineinfile: dest="{{ openbox_config_dir }}/autostart"
30+
regexp="^lxpanel"
31+
line="lxpanel &"
32+
create=yes
33+
state=present
34+
become: yes
35+
become_user: "{{ rpi_user_name }}"

roles/media_center/tasks/main.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,54 @@
11
---
22

3-
- name: Add Kodi Repo if not present
3+
# See https://www.raspberrypi.org/documentation/configuration/config-txt.md
4+
- name: Setup custom config.txt
5+
template: src=system/config.txt.j2 dest=/boot/config.txt owner=root group=root mode=0755
6+
register: update_config
7+
8+
- name: Create 99-input.rules
9+
template: src=system/input-rules dest=/etc/udev/rules.d/99-input.rules owner=root group=root mode=0644
10+
11+
- name: Create 10-permissions.rules
12+
template: src=system/permissions-rules dest=/etc/udev/rules.d/10-permissions.rules owner=root group=root mode=0644
13+
14+
- name: Rebooting Rpi
15+
shell: sleep 2 && shutdown -r now "Ansible updates triggered"
16+
async: 1
17+
poll: 0
18+
ignore_errors: true
19+
when: update_config|changed
20+
21+
- name: Waiting for server to come back
22+
local_action: wait_for host={{ inventory_hostname }} state=started delay=30 timeout=300
23+
become: false
24+
when: update_config|changed
25+
26+
- name: Add Kodi 16 Custom Repo
427
apt_repository: repo={{ kodi_apt_repo }}
5-
when: ansible_os_family == 'Debian' and ansible_distribution_version|int == 8
28+
29+
- name: Add Kodi Repo Key
30+
apt_key:
31+
url: "http://pipplware.pplware.pt/pipplware/key.asc"
32+
state: present
633

734
- name: Update APT package cache
835
apt: update_cache=yes cache_valid_time=3600
936

1037
- name: Install Kodi
11-
apt: state=installed pkg=kodi
38+
apt: state=installed pkg=kodi force=yes
1239

1340
- name: Create current user configuration directories
14-
file: path={{ item }} state=directory owner={{ rpi_user_name }} mode=0755
41+
file: path={{ item }} state=directory owner={{ rpi_user_name }} group={{ rpi_user_name }} mode=0755
1542
with_items:
1643
- "{{ kodi_user_dir }}"
1744
- "{{ kodi_user_dir }}/userdata"
1845

1946
- name: Build sources file
20-
template: src=kodi/sources.xml.j2 dest="{{ kodi_user_dir }}/userdata/sources.xml" owner={{ rpi_user_name }} mode=0600
47+
template: src=kodi/sources.xml.j2 dest="{{ kodi_user_dir }}/userdata/sources.xml" owner={{ rpi_user_name }} group={{ rpi_user_name }} mode=0600
2148

2249
- name: Enable buffering
23-
template: src=kodi/advancedsettings.xml.j2 dest="{{ kodi_user_dir }}/userdata/advancedsettings.xml" owner={{ rpi_user_name }} mode=0600
50+
template: src=kodi/advancedsettings.xml.j2 dest="{{ kodi_user_dir }}/userdata/advancedsettings.xml" owner={{ rpi_user_name }} group={{ rpi_user_name }} mode=0600
2451
when: with_kodi_buffering
52+
53+
- include: desktop.yml
54+
when: with_kodi_desktop
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# {{ ansible_managed }}
2+
#
3+
# For more options and information see
4+
# http://www.raspberrypi.org/documentation/configuration/config-txt.md
5+
# Some settings may impact device functionality. See link above for details
6+
7+
# uncomment if you get no picture on HDMI for a default "safe" mode
8+
#hdmi_safe=1
9+
10+
# uncomment this if your display has a black border of unused pixels visible
11+
# and your display can output without overscan
12+
#disable_overscan=1
13+
14+
# uncomment the following to adjust overscan. Use positive numbers if console
15+
# goes off screen, and negative if there is too much border
16+
#overscan_left=16
17+
#overscan_right=16
18+
#overscan_top=16
19+
#overscan_bottom=16
20+
21+
# uncomment to force a console size. By default it will be display's size minus
22+
# overscan.
23+
#framebuffer_width=1280
24+
#framebuffer_height=720
25+
26+
# uncomment if hdmi display is not detected and composite is being output
27+
hdmi_force_hotplug=1
28+
29+
# uncomment to force a specific HDMI mode (this will force VGA)
30+
#hdmi_group=1
31+
#hdmi_mode=1
32+
33+
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
34+
# DMT (computer monitor) modes
35+
#hdmi_drive=2
36+
37+
# uncomment to increase signal to HDMI, if you have interference, blanking, or
38+
# no display
39+
config_hdmi_boost=4
40+
41+
# uncomment for composite PAL
42+
#sdtv_mode=2
43+
44+
#uncomment to overclock the arm. 700 MHz is the default.
45+
#arm_freq=800
46+
47+
# Uncomment some or all of these to enable the optional hardware interfaces
48+
#dtparam=i2c_arm=on
49+
#dtparam=i2s=on
50+
#dtparam=spi=on
51+
52+
# Uncomment this to enable the lirc-rpi module
53+
#dtoverlay=lirc-rpi
54+
55+
# Additional overlays and parameters are documented /boot/overlays/README
56+
57+
# Enable audio (loads snd_bcm2835)
58+
dtparam=audio=on
59+
60+
##################
61+
# Customizations #
62+
##################
63+
64+
# Allocating 256M of RAM as GPU Memory
65+
gpu_mem=192
66+
67+
# Avoids bringing CEC (enabled TV) out of standby and channel switch when
68+
# rebooting.
69+
hdmi_ignore_cec_init=1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# {{ ansible_managed }}
2+
3+
SUBSYSTEM==input, GROUP=input, MODE=0660
4+
KERNEL==tty[0-9]*, GROUP=tty, MODE=0660
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# {{ ansible_managed }}
2+
3+
# input
4+
KERNEL=="mouse*|mice|event*", MODE="0660", GROUP="input"
5+
KERNEL=="ts[0-9]*|uinput", MODE="0660", GROUP="input"
6+
KERNEL==js[0-9]*, MODE=0660, GROUP=input
7+
# tty
8+
KERNEL==tty[0-9]*, MODE=0666
9+
# vchiq
10+
SUBSYSTEM==vchiq, GROUP=video, MODE=0660

variables.yml.inc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ logwatch_email: youremail@example.com
3737

3838
# SSH
3939

40+
# Changing this implies updating `allowed_ports` by adding the new port
41+
# AND leaving port 22 for the first setup (otherwise ansible may stop)
4042
ssh_port: 22
4143
ssh_public_keys:
4244
- ~/.ssh/id_rsa.pub
@@ -49,6 +51,7 @@ ssh_custom_banner: True
4951
allowed_ports:
5052
- 22
5153
- 6800 # Aria2 Daemon port
54+
# - 8070 # Kodi Remote Connection
5255

5356
# Wifi handling (disabled by default)
5457

@@ -104,9 +107,12 @@ with_vim: True
104107
# kodi_source_videos: []
105108

106109
# Enable buffering for slow networks
110+
# with_kodi_buffering: True
107111

108-
with_kodi_buffering: True
109-
110-
# Default values for a Rpi 3 (1 Gb of RAM):
112+
# Using 418M of RAM maximum (may crash if not available):
111113
# kodi_read_buffer_factor: 20
112114
# kodi_buffer_size: 139460608
115+
116+
# with_kodi_desktop installs a minimal OpenBox desktop based on
117+
# https://www.prahladyeri.com/blog/2016/02/minimal-debian-desktop-setup.html
118+
# with_kodi_desktop: True

0 commit comments

Comments
 (0)