From 4b28eb5fbe9fab884bcc398e92a3bf9f5281739b Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Sat, 12 Nov 2022 15:53:27 +0100 Subject: [PATCH 1/3] :wrench: Add hobbes.n39.eu to inventory --- inventory.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inventory.yml b/inventory.yml index 456f2e2..8efd97a 100644 --- a/inventory.yml +++ b/inventory.yml @@ -10,6 +10,7 @@ all: krypton.n39.eu: oganesson.n39.eu: holmium.n39.eu: + hobbes.n39.eu: children: proxmox: @@ -31,6 +32,7 @@ all: platon.n39.eu: beaker.n39.eu: wittgenstein.n39.eu: + hobbes.n39.eu: ssh_no_jump: hosts: - tau.netz39.de: \ No newline at end of file + tau.netz39.de: From 3ddc2e80f0b0371c6f077096c9926e579279fb91 Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Sat, 12 Nov 2022 15:53:58 +0100 Subject: [PATCH 2/3] :wrench: Link hobbes playbook in main.yml --- main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.yml b/main.yml index cd0dbb5..03db3b3 100644 --- a/main.yml +++ b/main.yml @@ -33,3 +33,6 @@ - name: Holmium specific setup import_playbook: host-holmium.yml + +- name: Hobbes specific setup + import_playbook: host-hobbes.yml From 64bf735c21ed30136739f058fd61189e1b0b5954 Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Sat, 12 Nov 2022 15:54:28 +0100 Subject: [PATCH 3/3] :sparkles: Setup grafana kiosk on hobbes.n39.eu --- host-hobbes.yml | 119 ++++++++++++++++++++++ host_vars/hobbes.n39.eu/vars.yml | 8 ++ host_vars/hobbes.n39.eu/vault | 9 ++ templates/hobbes/grafana-kiosk.service.j2 | 36 +++++++ 4 files changed, 172 insertions(+) create mode 100644 host-hobbes.yml create mode 100644 host_vars/hobbes.n39.eu/vars.yml create mode 100644 host_vars/hobbes.n39.eu/vault create mode 100644 templates/hobbes/grafana-kiosk.service.j2 diff --git a/host-hobbes.yml b/host-hobbes.yml new file mode 100644 index 0000000..fc75062 --- /dev/null +++ b/host-hobbes.yml @@ -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: diff --git a/host_vars/hobbes.n39.eu/vars.yml b/host_vars/hobbes.n39.eu/vars.yml new file mode 100644 index 0000000..ad3650e --- /dev/null +++ b/host_vars/hobbes.n39.eu/vars.yml @@ -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 }}" diff --git a/host_vars/hobbes.n39.eu/vault b/host_vars/hobbes.n39.eu/vault new file mode 100644 index 0000000..5f4b386 --- /dev/null +++ b/host_vars/hobbes.n39.eu/vault @@ -0,0 +1,9 @@ +$ANSIBLE_VAULT;1.1;AES256 +32313738636231313036633334333934643839636563646334336533316436653263623461643438 +6362343635626266313466643465343962663931623662320a316635613231313930343937363064 +33326164333137633039376363643539346463303934333430626431336637326638363233333234 +3132333533376134380a383837616331303536623665383735663531343538366332313236386137 +62306436663934383363616332316262313762633261396535663533636665633532316366386430 +65343830376634633365343337313433643465323662313563366463393664653766623338623635 +30653263303761316238396634346337636461643231303561353133643162633934323161663539 +66646364373034633334 diff --git a/templates/hobbes/grafana-kiosk.service.j2 b/templates/hobbes/grafana-kiosk.service.j2 new file mode 100644 index 0000000..0712910 --- /dev/null +++ b/templates/hobbes/grafana-kiosk.service.j2 @@ -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 +