-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpi_playbook.yaml
114 lines (101 loc) · 3.01 KB
/
rpi_playbook.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
- name: Set up slideshow on Raspberry Pi
hosts: raspberrypi
become: yes
tasks:
- name: Modify boot config for screen
lineinfile:
path: /boot/config.txt
line: "{{ item }}"
insertafter: EOF
with_items:
# - "hdmi_force_hotplug=1"
# - "max_usb_current=1"
- "hdmi_group=2"
- "hdmi_mode=87"
- "hdmi_cvt 1024 600 60 6 0 0 0"
# - "hdmi_drive=1"
# - "hdmi_safe=1"
notify: Reboot system
- name: Modify boot config again
replace:
path: /boot/config.txt
regexp: vc4-kms-v3d
replace: vc4-fkms-v3d
notify: Reboot system
- name: Copy executable to Raspberry Pi
become: no
copy:
src: "target/armv7-unknown-linux-gnueabihf/release/photoframe"
dest: "/home/pi/photoframe"
mode: "0755"
- name: Create env script
copy:
dest: "/etc/photoframe.env"
content: |
PHOTOFRAME_USERNAME={{ PHOTOFRAME_USERNAME }}
PHOTOFRAME_PASSWORD={{ PHOTOFRAME_PASSWORD }}
PHOTOFRAME_OAUTH_TOKEN={{ PHOTOFRAME_OAUTH_TOKEN }}
PHOTOFRAME_INDEX_FILE=/home/pi/.photoframe/index.json
PHOTOFRAME_PHOTO_DIR=/home/pi/.photoframe/photos
- name: Install feh
apt:
name: feh
state: present
update_cache: yes
- name: Create slideshow script
copy:
dest: "/home/pi/slideshow.sh"
content: |
#!/bin/bash
export DISPLAY=:0
xhost +local:
sleep 10
feh -Y -x -q -D 10 -B black -F -Z -z -r /home/pi/.photoframe/photos
mode: "0755"
notify: Reboot system
- name: Set up slideshow to run on startup
lineinfile:
path: "/home/pi/.config/lxsession/LXDE-pi/autostart"
line: "@/home/pi/slideshow.sh"
create: yes
- name: Add systemd service for executable
copy:
dest: "/etc/systemd/system/photoframe.service"
content: |
[Unit]
Description=Background executable service
After=network.target
[Service]
ExecStart=/home/pi/photoframe
EnvironmentFile=/etc/photoframe.env
Restart=on-failure
User=pi
Group=pi
[Install]
WantedBy=multi-user.target
notify: Reload and start service
# - name: Add systemd service for slideshow display
# copy:
# dest: "/etc/systemd/system/slideshow.service"
# content: |
# [Unit]
# Description=Background executable service
# After=network.target
# [Service]
# ExecStart=/home/pi/slideshow.sh
# Restart=on-failure
# User=pi
# Group=pi
# [Install]
# WantedBy=multi-user.target
# notify: Reload and start service
handlers:
- name: Reboot system
reboot:
- name: Reload and start service
systemd:
name: photoframe
daemon_reload: yes
state: restarted
enabled: yes