Merge "Fix redundant extra config files in grafana role"

This commit is contained in:
Zuul 2024-08-22 11:36:10 +00:00 committed by Gerrit Code Review
commit 7050ce0210
4 changed files with 21 additions and 29 deletions

View File

@ -12,6 +12,9 @@
- name: Check if extra configuration file exists
find:
path: "{{ node_custom_config }}/grafana/"
excludes:
- "prometheus.yaml"
- "provisioning.yaml"
delegate_to: localhost
changed_when: False
run_once: True
@ -59,23 +62,6 @@
notify:
- Restart grafana container
- name: Check if custom grafana home dashboard exists
stat:
path: "{{ node_custom_config }}/grafana/grafana_home_dashboard.json"
delegate_to: localhost
register: grafana_custom_dashboard_file
run_once: True
- name: Copying over grafana home dashboard if exists
become: true
template:
src: "{{ node_custom_config }}/grafana/grafana_home_dashboard.json"
dest: "{{ node_config_directory }}/grafana/grafana_home_dashboard.json"
mode: "0660"
when: grafana_custom_dashboard_file.stat.exists
notify:
- Restart grafana container
- name: Configuring Prometheus as data source for Grafana
vars:
service: "{{ grafana_services['grafana'] }}"

View File

@ -57,4 +57,4 @@
register: grafana_response
changed_when: grafana_response.status == 200
run_once: true
when: grafana_custom_dashboard_file.stat.exists
when: "'grafana_home_dashboard.json' in check_extra_conf_grafana.files | map(attribute='path') | map('basename')"

View File

@ -7,21 +7,22 @@
"owner": "grafana",
"perm": "0600"
},
{% if check_extra_conf_grafana is defined %}{% if check_extra_conf_grafana.matched > 0 %}{% for plugin in check_extra_conf_grafana.files %}
{% if check_extra_conf_grafana is defined %}
{% for extra_conf in check_extra_conf_grafana.files | map(attribute='path') | map('basename') %}
{
"source": "{{ container_config_directory }}/{{ plugin.path | basename }}",
"dest": "/etc/grafana/{{ plugin.path | basename }}",
"owner": "grafana",
"perm": "0600"
},
{% endfor %}{% endif %}{% endif %}
{
"source": "{{ container_config_directory }}/grafana_home_dashboard.json",
"source": "{{ container_config_directory }}/{{ extra_conf }}",
{% if extra_conf == 'grafana_home_dashboard.json' %}
"dest": "/usr/share/grafana/public/dashboards/home.json",
"owner": "root",
"perm": "0644",
"optional": true
"perm": "0644"
{% else %}
"dest": "/etc/grafana/{{ extra_conf }}",
"owner": "grafana",
"perm": "0600"
{% endif %}
},
{% endfor %}
{% endif %}
{
"source": "{{ container_config_directory }}/prometheus.yaml",
"dest": "/etc/grafana/provisioning/datasources/prometheus.yaml",

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes redundant copying of grafana custom config files.
`LP#2067999 <https://launchpad.net/bugs/2067999>`__