Fix redundant extra config files in grafana role
Task `Check if extra configuration file exists` picks up all files in `{{ node_custom_config }}/grafana` including those that get handled specially later on. While `prometheus.yml` and `provisioning.yml` are best excluded from extra config , because their treatment requires more than just copying, `grafana_home_dashboard.json` may simply be treated as extra config, which saves the execution of two additional tasks. Closes-Bug: 2067999 Change-Id: I7bce1fe3d0a96816f1782107b202d6dac7d1291d Signed-off-by: Jan Horstmann <horstmann@osism.tech>
This commit is contained in:
parent
43636d7f34
commit
4178f02e2b
@ -15,6 +15,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
|
||||
@ -68,23 +71,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'] }}"
|
||||
|
@ -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')"
|
||||
|
@ -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",
|
||||
|
5
releasenotes/notes/bug-2067999-5d009f15e1cc3185.yaml
Normal file
5
releasenotes/notes/bug-2067999-5d009f15e1cc3185.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes redundant copying of grafana custom config files.
|
||||
`LP#2067999 <https://launchpad.net/bugs/2067999>`__
|
Loading…
Reference in New Issue
Block a user