Setup grafana kiosk on hobbes.n39.eu

This commit is contained in:
Stefan Haun 2022-11-12 15:54:28 +01:00
parent 3ddc2e80f0
commit 64bf735c21
4 changed files with 172 additions and 0 deletions

119
host-hobbes.yml Normal file
View file

@ -0,0 +1,119 @@
---
- hosts: hobbes.n39.eu
become: true
vars:
ansible_python_interpreter: /usr/bin/python3
roles:
tasks:
- name: Install packages needed for the system
# This is a list of all packages,
# unless they are installed by a specific role
ansible.builtin.apt:
state: present
name:
# This is needed for the user-executed tasks
- acl
# Regular packages
- lightdm
- accountsservice
- unclutter
- lxde
- chromium
- rng-tools
- name: Remove the screensavers
ansible.builtin.apt:
state: absent
name:
- xscreensaver
- name: Set MAC address for proper DHCP recognition
# Uses mac variable from inventory
ansible.builtin.template:
src: templates/network-interfaces-dhcp-mac.j2
dest: /etc/network/interfaces.d/hobbes-mac
owner: root
group: root
mode: '0644'
- name: Disable IPv6
# Because it is not working....
ansible.builtin.copy:
src: files/sysctl-no-ipv6.conf
dest: /etc/sysctl.d/99-systcl-no-ipv6.conf
owner: root
group: root
mode: '0644'
### Kiosk setup
#
# https://github.com/grafana/grafana-kiosk
- name: Ensure kiosk user is there
ansible.builtin.user:
name: "{{ kiosk_user }}"
groups: audio,plugdev,input,netdev
append: yes
- name: Create bin directory
file:
path: "/home/{{ kiosk_user }}/bin"
owner: "{{ kiosk_user }}"
mode: '0755'
state: directory
- name: Download grafana-kiosk
ansible.builtin.get_url:
url: "https://github.com/grafana/grafana-kiosk/releases/download/{{ kiosk_software_version }}/grafana-kiosk.linux.{{ kiosk_software_arch }}"
dest: "/home/{{ kiosk_user }}/bin/grafana-kiosk"
mode: '0755'
force: no
- name: Setup autologin in lightdm
ansible.builtin.blockinfile:
path: /etc/lightdm/lightdm.conf
block: |
[Seat:seat0]
autologin-user = pi
autologin-user-timeout = 0
autologin-in-background = False
- name: Remove autostart
# None of the things in autostart are needed or wanted
ansible.builtin.file:
path: /etc/xdg/lxsession/LXDE/autostart
state: absent
- name: Add systemd service
ansible.builtin.template:
src: templates/hobbes/grafana-kiosk.service.j2
dest: /etc/systemd/system/grafana-kiosk.service
owner: root
group: root
mode: '0644'
- name: Enable and start kiosk service
ansible.builtin.service:
name: grafana-kiosk.service
enabled: true
state: started
- name: Set default systemd target to graphical
ansible.builtin.file:
src: /lib/systemd/system/graphical.target
dest: /etc/systemd/system/default.target
state: link
force: yes
handlers:

View file

@ -0,0 +1,8 @@
server_admin: "admin+hobbes@netz39.de"
mac: "b8:27:eb:f9:43:43"
kiosk_user: pi
kiosk_software_version: v1.0.5
kiosk_software_arch: "armv7"
kiosk_url: "https://grafana.n39.eu/d/xpLj6UD4z/hobbes-space-monitor?orgId=1"
kiosk_grafana_user: "{{ vault_kiosk_grafana_user }}"
kiosk_grafana_pass: "{{ vault_kiosk_grafana_pass }}"

View file

@ -0,0 +1,9 @@
$ANSIBLE_VAULT;1.1;AES256
32313738636231313036633334333934643839636563646334336533316436653263623461643438
6362343635626266313466643465343962663931623662320a316635613231313930343937363064
33326164333137633039376363643539346463303934333430626431336637326638363233333234
3132333533376134380a383837616331303536623665383735663531343538366332313236386137
62306436663934383363616332316262313762633261396535663533636665633532316366386430
65343830376634633365343337313433643465323662313563366463393664653766623338623635
30653263303761316238396634346337636461643231303561353133643162633934323161663539
66646364373034633334

View file

@ -0,0 +1,36 @@
[Unit]
Description=Grafana Kiosk
Documentation=https://github.com/grafana/grafana-kiosk
Documentation=https://grafana.com/blog/2019/05/02/grafana-tutorial-how-to-create-kiosks-to-display-dashboards-on-a-tv
After=network.target
Wants=graphical.target
After=graphical.target
[Service]
User={{ kiosk_user }}
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/{{ kiosk_user }}/.Xauthority"
# These should work according to the docs, but are nowhere in the code?
#Environment="KIOSK_MODE=full"
#Environment="KIOSK_AUTOFIT=false"
#Environment="KIOSK_LXDE_ENABLED=true"
#Environment="KIOSK_LXDE_HOME=/home/{{ kiosk_user }}"
#Environment="KIOSK_URL={{ kiosk_url }}"
#Environment="KIOSK_LOGIN_METHOD=local"
#Environment="KIOSK_LOGIN_USER={{ kiosk_grafana_user }}"
#Environment="KIOSK_LOGIN_PASSWORD={{ kiosk_grafana_pass }}"
# Disable screensaver etc.
ExecStartPre=xset s off
ExecStartPre=xset -dpms
ExecStartPre=xset s noblank
ExecStart=/home/{{ kiosk_user }}/bin/grafana-kiosk -kiosk-mode=full -autofit=false -lxde-home=/home/{{ kiosk_user }} -URL="{{ kiosk_url }}" -login-method=local -username={{ kiosk_grafana_user }} --password={{ kiosk_grafana_pass }}
Restart=on-failure
RestartSec=30s
[Install]
WantedBy=graphical.target