From 35a81cdd60788471696c11a27de419b35a2c6373 Mon Sep 17 00:00:00 2001 From: L3D Date: Thu, 2 Jul 2020 15:23:14 +0200 Subject: [PATCH] change to use enviroment file and use a workaround for https://github.com/grafana/grafana-kiosk/issues/40 --- tasks/config.yml | 14 ++++++++++++-- templates/{config.yml => config.yml.j2} | 0 templates/grafana-kiosk.env.j2 | 3 +++ ...fana-kiosk.service => grafana-kiosk.service.j2} | 11 +++++------ vars/main.yml | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) rename templates/{config.yml => config.yml.j2} (100%) create mode 100644 templates/grafana-kiosk.env.j2 rename templates/{grafana-kiosk.service => grafana-kiosk.service.j2} (65%) diff --git a/tasks/config.yml b/tasks/config.yml index b844c70..4b756c0 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -8,7 +8,7 @@ - name: deploy grafana-kiosk config become: true template: - src: templates/config.yml + src: templates/config.yml.j2 dest: /etc/grafana-kiosk/config.yml mode: 0644 backup: true @@ -17,9 +17,19 @@ - name: deploy systemd file become: true template: - src: templates/grafana-kiosk.service + src: templates/grafana-kiosk.service.j2 dest: /etc/systemd/system/grafana-kiosk.service mode: 0664 owner: root group: root notify: systemctl restart grafana-kiosk.service + +- name: deploy env vars + become: true + template: + src: templates/grafana-kiosk.env.j2 + dest: "/home/{{ grafana_kiosk.user }}/.grafana-kiosk.env" + mode: 0755 + owner: "{{ grafana_kiosk.user }}" + notify: systemctl restart grafana-kiosk.service + diff --git a/templates/config.yml b/templates/config.yml.j2 similarity index 100% rename from templates/config.yml rename to templates/config.yml.j2 diff --git a/templates/grafana-kiosk.env.j2 b/templates/grafana-kiosk.env.j2 new file mode 100644 index 0000000..b558587 --- /dev/null +++ b/templates/grafana-kiosk.env.j2 @@ -0,0 +1,3 @@ +#!/bin/bash +export {{ grafana_kiosk.display }} +export XAUTHORITY=/home/{{ grafana_kiosk.user }}/.Xauthority diff --git a/templates/grafana-kiosk.service b/templates/grafana-kiosk.service.j2 similarity index 65% rename from templates/grafana-kiosk.service rename to templates/grafana-kiosk.service.j2 index 8d79c5f..f45fb73 100644 --- a/templates/grafana-kiosk.service +++ b/templates/grafana-kiosk.service.j2 @@ -9,13 +9,12 @@ User={{ grafana_kiosk.user }} Restart = always RestartSec=5s Type=simple -Environment="{{ grafana_kiosk.display }}" -Environment="XAUTHORITY=/home/{{ grafana_kiosk.user }}/.Xauthority" -ExecStart= +EnvironmentFile=/home/{{ grafana_kiosk.user }}/.grafana-kiosk.env +ExecStart=/bin/bash -c " {%- if not grafana_kiosk.general.autofit | bool -%} - KIOSK_AUTOFIT={{ grafana_kiosk.general.autofit | ternary("true", "false") }}{{ ' ' }} - {%- endif -%} -/usr/bin/grafana-kiosk -c /etc/grafana-kiosk/config.yml + KIOSK_AUTOFIT={{ grafana_kiosk.general.autofit | ternary("true", "false") }}{{ '; '}} +{%- endif -%} +/usr/bin/grafana-kiosk -c /etc/grafana-kiosk/config.yml" [Install] WantedBy=graphical.target diff --git a/vars/main.yml b/vars/main.yml index 55f7716..bd8df81 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -32,5 +32,5 @@ _dl_matrix: 'armv6l': "grafana-kiosk.linux.armv6" 'armv5l': "grafana-kiosk.linux.armv5" -playbook_version_number: 13 # should be an integer +playbook_version_number: 14 # should be an integer playbook_version_path: 'role-grafana-kiosk_roles-ansible_github.com.version' # unique string