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

Commit 415cb14

Browse files
committed
Merge branch 'release/0.3.1'
2 parents c271aa5 + 526284d commit 415cb14

File tree

10 files changed

+102
-79
lines changed

10 files changed

+102
-79
lines changed

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# ansible-rpi 0.3.0
1+
# ansible-rpi 0.3.1
22

33
## Purpose
44

5-
Make Raspberry Pi up and running in a few command
5+
Make Raspberry Pi up and running in a few command.
6+
7+
Tested on a Rpi 3 B+ and a Rpi 1 B.
68

79
## Roles
810

@@ -12,7 +14,7 @@ Make Raspberry Pi up and running in a few command
1214
- Locale setup
1315
- System upgrade (*including kernel*)
1416
- Adding some useful packages (*curl, vim, tmux, git…*)
15-
- UFW firewall rules allowing user-specified ports
17+
- UFW firewall rules allowing user-specified ports and protocols
1618
- Logwatch for system status emails (*via SSMTP*)
1719
- SSH with key-only authentification
1820
- Custom sudo user for rpi (*thus disabling pi as Rpi sudoer*)
@@ -27,18 +29,14 @@ Make Raspberry Pi up and running in a few command
2729
- RPC interface for remote monitoring with optionnal SSL encryption
2830
- Shared downloads directory (*may be replaced by a previously configured network folder*)
2931
- `media_center`: Turn your Raspberry into a decent customizable media center
30-
- Kodi basic installation
32+
- Kodi basic installation with separate user
3133
- Dynamic sources creation (*may be linked to previously configured network folders*)
32-
- Buffer handling
33-
- Optionnal minimal Openbox setup (*when using a lite image for eg.*)
34+
- Buffer handling optimized for a Raspberry
35+
- Optionnal `kodi` user with `kodi-standalone` and a minimal Openbox setup
3436

3537
### Incoming
3638

37-
- `swarm_node`: Run Docker containers in a Rpis Swarm
38-
39-
### TODO
40-
41-
- Use as an ansible module
39+
- `swarm_node`: Setup a Rpi as a Docker Machine and join a Docker Swarm
4240

4341
## Setup
4442

@@ -56,7 +54,7 @@ cp variables.yml.inc host_vars/my-host.yml
5654

5755
First update the `hosts` file to target your Rpis.
5856

59-
I recommend using an up-to-date Raspbian Lite image.
57+
I recommend using an up-to-date [Raspbian Lite image](https://downloads.raspberrypi.org/raspbian_lite_latest).
6058

6159
Make sure that the Rpi is SSHable (**latest raspbian lite images come with SSH
6260
disabled by default, creating a file with name "ssh" in boot partition is

roles/common/tasks/firewall.yml

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

33
- name: Allow specific ports connections
4-
ufw: rule=allow port={{ item }} proto=tcp
4+
ufw: rule=allow port={{ item.port }} proto={{ item.proto }}
55
with_items:
66
- "{{ allowed_ports }}"
77

roles/download_server/tasks/main.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,4 @@
5353
notify: Restart aria2
5454

5555
- name: Enable aria2 daemon on boot
56-
service: name=aria2 enabled=true state=started
57-
58-
- service:
59-
name: aria2
60-
state: restarted
56+
service: name=aria2 enabled=true state=restarted

roles/media_center/defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
kodi_apt_repo: "deb http://pipplware.pplware.pt/pipplware/dists/jessie/main/binary /"
2-
kodi_user_dir: /home/{{ rpi_user_name }}/.kodi
32
openbox_config_dir: /home/{{ rpi_user_name }}/.config/openbox
43

54
# Arrays of filepaths
@@ -14,4 +13,5 @@ with_kodi_buffering: False
1413
kodi_read_buffer_factor: 20
1514
kodi_buffer_size: 139460608
1615

17-
with_kodi_desktop: False
16+
kodi_username: kodi
17+
kodi_user_dir: "/home/{{ kodi_username }}/.kodi"

roles/media_center/handlers/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
3+
- name: Restart kodi
4+
service: name=kodi state=restarted

roles/media_center/tasks/base.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
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

roles/media_center/tasks/desktop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
- gmrun
1616
- gnome-terminal
1717

18-
- name: Create openbox config directory
18+
- name: "Create openbox config directory for {{ rpi_user_name }}"
1919
file: path="{{ openbox_config_dir }}" owner="{{ rpi_user_name }}" group="{{ rpi_user_name }}" state=directory
2020
register: create_openbox_config
2121

22-
- name: Setting up default Openbox config
22+
- name: "Setting up default Openbox config for {{ rpi_user_name }}"
2323
shell: cp /etc/xdg/openbox/* "{{ openbox_config_dir }}"
2424
become: yes
2525
become_user: "{{ rpi_user_name }}"

roles/media_center/tasks/kodi.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
3+
- name: Add Kodi 16 Custom Repo
4+
apt_repository: repo={{ kodi_apt_repo }}
5+
6+
- name: Add Kodi Repo Key
7+
apt_key:
8+
url: "http://pipplware.pplware.pt/pipplware/key.asc"
9+
state: present
10+
11+
- name: Update APT package cache
12+
apt: update_cache=yes cache_valid_time=3600
13+
14+
- name: Install Kodi
15+
apt: state=installed pkg=kodi force=yes
16+
17+
- name: Add new user for media center
18+
user:
19+
name: "{{ kodi_username }}"
20+
comment: "Kodi session"
21+
password: "{{ kodi_password_hash }}"
22+
groups: cdrom,audio,video,plugdev,users,dialout,dip,input,netdev,{{ rpi_shared_group }}
23+
state: present
24+
append: yes
25+
26+
- name: "Create openbox config directory for {{ kodi_username }}"
27+
file: path="/home/{{ kodi_username }}/.config/openbox" owner="{{ kodi_username }}" group="{{ kodi_username }}" state=directory
28+
29+
- name: Enforce Kodi opening in standalone mode
30+
lineinfile: dest="/home/{{ kodi_username }}/.config/openbox/autostart"
31+
regexp="^/usr/bin/kodi-standalone"
32+
line="/usr/bin/kodi-standalone &"
33+
create=yes
34+
state=present
35+
become: yes
36+
become_user: "{{ kodi_username }}"
37+
38+
- name: Create current user configuration directories
39+
file: path={{ item }} state=directory owner={{ kodi_username }} group={{ kodi_username }} mode=0755
40+
with_items:
41+
- "{{ kodi_user_dir }}"
42+
- "{{ kodi_user_dir }}/userdata"
43+
44+
- name: Build sources file
45+
template: src=kodi/sources.xml.j2 dest="{{ kodi_user_dir }}/userdata/sources.xml" owner={{ kodi_username }} group={{ kodi_username }} mode=0600
46+
47+
- name: Enable buffering
48+
template: src=kodi/advancedsettings.xml.j2 dest="{{ kodi_user_dir }}/userdata/advancedsettings.xml" owner={{ kodi_username }} group={{ kodi_username }} mode=0600
49+
when: with_kodi_buffering

roles/media_center/tasks/main.yml

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,5 @@
11
---
22

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
27-
apt_repository: repo={{ kodi_apt_repo }}
28-
29-
- name: Add Kodi Repo Key
30-
apt_key:
31-
url: "http://pipplware.pplware.pt/pipplware/key.asc"
32-
state: present
33-
34-
- name: Update APT package cache
35-
apt: update_cache=yes cache_valid_time=3600
36-
37-
- name: Install Kodi
38-
apt: state=installed pkg=kodi force=yes
39-
40-
- name: Create current user configuration directories
41-
file: path={{ item }} state=directory owner={{ rpi_user_name }} group={{ rpi_user_name }} mode=0755
42-
with_items:
43-
- "{{ kodi_user_dir }}"
44-
- "{{ kodi_user_dir }}/userdata"
45-
46-
- name: Build sources file
47-
template: src=kodi/sources.xml.j2 dest="{{ kodi_user_dir }}/userdata/sources.xml" owner={{ rpi_user_name }} group={{ rpi_user_name }} mode=0600
48-
49-
- name: Enable buffering
50-
template: src=kodi/advancedsettings.xml.j2 dest="{{ kodi_user_dir }}/userdata/advancedsettings.xml" owner={{ rpi_user_name }} group={{ rpi_user_name }} mode=0600
51-
when: with_kodi_buffering
52-
3+
- include: base.yml
534
- include: desktop.yml
54-
when: with_kodi_desktop
5+
- include: kodi.yml

variables.yml.inc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ ssh_custom_banner: True
4949
# Firewall
5050

5151
allowed_ports:
52-
- 22
53-
- 6800 # Aria2 Daemon port
54-
# - 8070 # Kodi Remote Connection
52+
- { port: 22, proto: 'tcp' }
53+
- { port: 6800, proto: 'tcp' } # Aria2 Daemon port
54+
# - { port: 8070, proto: 'tcp' } # Kodi HTTPServer Connection
55+
# - { port: 9777, proto: 'udp' } # Kodi EventServer Connection
5556

5657
# Wifi handling (disabled by default)
5758

@@ -113,6 +114,6 @@ with_vim: True
113114
# kodi_read_buffer_factor: 20
114115
# kodi_buffer_size: 139460608
115116

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
117+
# Kodi session name and password are updatable (_default password is `kodi`_)
118+
# kodi_username: kodi
119+
# kodi_password_hash: $6$iLBM8EeXOMRMb0I3$gRrJmyVcCeMl.JT7DKLG1XIYDl6/qq6FB99t.IO2Hy87ykxKLSZ0GUVqK/.N7N5gfQMJHiBAAApCM.geeia1z.

0 commit comments

Comments
 (0)