From fd61a615bcd7ee3fa0a457f3a9a1e5913df6b7d2 Mon Sep 17 00:00:00 2001 From: ginta1337 Date: Mon, 28 Oct 2024 00:09:35 +0300 Subject: [PATCH 1/2] Introduce grafana_dashboard_files variable --- defaults/main.yml | 12 ++++++++++-- tasks/install.yml | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 785069d..d78305c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -89,14 +89,22 @@ grafana_smtp_user: "" grafana_smtp_password: "" grafana_smtp_from_address: "" -# A list of template files on the Ansible controller server to install into the dashboards directory. +# A list of template files on the Ansible controller server to install into the dashboard provisioning directory. # # Example: # grafana_provisioning_dashboard_template_files: -# - name: /path/to/my-dashboard.json +# - name: /path/to/my-dashboard-provisioning.json # name: my-dashboard.json grafana_provisioning_dashboard_template_files: [] +# A list of files on the Ansible controller server to install into the dashboards directory. +# +# Example: +# grafana_dashboard_files: +# - name: /path/to/my-dashboard.json +# name: my-dashboard.json +grafana_dashboard_files: [] + # A list of provisioning datasources. # See `../templates/provisioning/datasources.yaml.j2` grafana_provisioning_datasources: [] diff --git a/tasks/install.yml b/tasks/install.yml index bf365d2..b230d1a 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -49,7 +49,7 @@ delay: "{{ devture_playbook_help_geturl_retries_delay }}" until: result is not failed -- name: Ensure dashboard templates installed +- name: Ensure provisioning dashboard templates installed ansible.builtin.template: src: "{{ item.path }}" dest: "{{ grafana_config_path }}/provisioning/dashboards/{{ item.name }}" @@ -58,6 +58,15 @@ group: "{{ grafana_gid }}" with_items: "{{ grafana_provisioning_dashboard_template_files }}" +- name: Ensure dashboard files installed + ansible.builtin.file: + path: "{{ item.path }}" + dest: "{{ grafana_config_path }}/dashboards/{{ item.name }}" + mode: "0440" + owner: "{{ grafana_uid }}" + group: "{{ grafana_gid }}" + with_items: "{{ grafana_dashboard_files }}" + - name: Ensure Grafana image is pulled community.docker.docker_image: name: "{{ grafana_container_image }}" From 09c3af14b6a416ec5f3687805bfd8579b800ddcb Mon Sep 17 00:00:00 2001 From: ginta1337 Date: Mon, 28 Oct 2024 01:15:35 +0300 Subject: [PATCH 2/2] Use copy module to put dashboards --- tasks/install.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/install.yml b/tasks/install.yml index b230d1a..b509cba 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -59,8 +59,8 @@ with_items: "{{ grafana_provisioning_dashboard_template_files }}" - name: Ensure dashboard files installed - ansible.builtin.file: - path: "{{ item.path }}" + ansible.builtin.copy: + src: "{{ item.path }}" dest: "{{ grafana_config_path }}/dashboards/{{ item.name }}" mode: "0440" owner: "{{ grafana_uid }}"