2016-07-27 07:02:04 +00:00
|
|
|
---
|
|
|
|
- name: Ensuring config directories exist
|
|
|
|
file:
|
2017-01-23 11:40:29 -03:00
|
|
|
path: "{{ node_config_directory }}/{{ item.key }}"
|
2016-07-27 07:02:04 +00:00
|
|
|
state: "directory"
|
2016-08-24 00:28:08 +07:00
|
|
|
owner: "{{ config_owner_user }}"
|
|
|
|
group: "{{ config_owner_group }}"
|
|
|
|
mode: "0770"
|
|
|
|
become: true
|
2017-01-23 11:40:29 -03:00
|
|
|
when:
|
|
|
|
- inventory_hostname in groups[item.value.group]
|
|
|
|
- item.value.enabled | bool
|
|
|
|
with_dict: "{{ grafana_services }}"
|
2016-07-27 07:02:04 +00:00
|
|
|
|
2018-02-27 14:30:11 +01:00
|
|
|
- name: Check if extra configuration file exists
|
2019-11-19 09:34:23 +00:00
|
|
|
find:
|
|
|
|
path: "{{ node_custom_config }}/grafana/"
|
|
|
|
delegate_to: localhost
|
2018-02-27 14:30:11 +01:00
|
|
|
changed_when: False
|
|
|
|
run_once: True
|
|
|
|
register: check_extra_conf_grafana
|
|
|
|
|
2020-04-10 13:53:19 -07:00
|
|
|
- include_tasks: copy-certs.yml
|
2019-12-18 15:49:28 -08:00
|
|
|
when:
|
|
|
|
- kolla_copy_ca_into_containers | bool
|
|
|
|
|
2016-07-27 07:02:04 +00:00
|
|
|
- name: Copying over config.json files
|
|
|
|
template:
|
2017-01-23 11:40:29 -03:00
|
|
|
src: "{{ item.key }}.json.j2"
|
|
|
|
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
2016-08-24 00:28:08 +07:00
|
|
|
mode: "0660"
|
|
|
|
become: true
|
2017-01-23 11:40:29 -03:00
|
|
|
when:
|
|
|
|
- inventory_hostname in groups[item.value.group]
|
|
|
|
- item.value.enabled | bool
|
|
|
|
with_dict: "{{ grafana_services }}"
|
|
|
|
notify:
|
2019-03-26 09:56:29 +00:00
|
|
|
- Restart {{ item.key }} container
|
2016-07-27 07:02:04 +00:00
|
|
|
|
|
|
|
- name: Copying over grafana.ini
|
2017-06-12 09:18:20 +08:00
|
|
|
vars:
|
|
|
|
service_name: "{{ item.key }}"
|
2016-07-27 07:02:04 +00:00
|
|
|
merge_configs:
|
|
|
|
sources:
|
|
|
|
- "{{ role_path }}/templates/grafana.ini.j2"
|
2017-01-23 11:40:29 -03:00
|
|
|
- "{{ node_custom_config }}/{{ item.key }}.ini"
|
|
|
|
- "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/{{ item.key }}.ini"
|
2016-07-27 07:02:04 +00:00
|
|
|
dest: "{{ node_config_directory }}/grafana/grafana.ini"
|
2016-08-24 00:28:08 +07:00
|
|
|
mode: "0660"
|
|
|
|
become: true
|
2017-01-23 11:40:29 -03:00
|
|
|
when:
|
|
|
|
- inventory_hostname in groups[item.value.group]
|
|
|
|
- item.value.enabled | bool
|
|
|
|
with_dict: "{{ grafana_services }}"
|
|
|
|
notify:
|
2019-03-26 09:56:29 +00:00
|
|
|
- Restart {{ item.key }} container
|
2017-01-23 11:40:29 -03:00
|
|
|
|
2018-02-27 14:30:11 +01:00
|
|
|
- name: Copying over extra configuration file
|
|
|
|
become: true
|
|
|
|
template:
|
|
|
|
src: "{{ item.path }}"
|
|
|
|
dest: "{{ node_config_directory }}/grafana/{{ item.path | basename }}"
|
|
|
|
mode: "0660"
|
|
|
|
when:
|
|
|
|
- item is defined
|
|
|
|
with_items:
|
|
|
|
- "{{ check_extra_conf_grafana.files }}"
|
|
|
|
notify:
|
2019-09-25 08:52:56 +02:00
|
|
|
- Restart grafana container
|
2018-02-27 14:30:11 +01:00
|
|
|
|
2017-07-21 11:30:39 +08:00
|
|
|
- name: Check if custom grafana home dashboard exists
|
2019-11-19 09:34:23 +00:00
|
|
|
stat:
|
|
|
|
path: "{{ node_custom_config }}/grafana/grafana_home_dashboard.json"
|
|
|
|
delegate_to: localhost
|
2017-07-21 11:30:39 +08:00
|
|
|
register: grafana_custom_dashboard_file
|
|
|
|
run_once: True
|
|
|
|
|
|
|
|
- name: Copying over grafana home dashboard if exists
|
|
|
|
template:
|
|
|
|
src: "{{ node_custom_config }}/grafana/grafana_home_dashboard.json"
|
|
|
|
dest: "{{ node_config_directory }}/grafana/grafana_home_dashboard.json"
|
2019-03-22 19:18:45 +00:00
|
|
|
mode: "0660"
|
2017-07-21 11:30:39 +08:00
|
|
|
when: grafana_custom_dashboard_file.stat.exists
|
|
|
|
notify:
|
2019-09-25 08:52:56 +02:00
|
|
|
- Restart grafana container
|
2017-07-21 11:30:39 +08:00
|
|
|
|
2018-04-18 15:52:09 -04:00
|
|
|
- name: Configuring Prometheus as data source for Grafana
|
|
|
|
vars:
|
|
|
|
service: "{{ grafana_services['grafana'] }}"
|
|
|
|
template:
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: "{{ node_config_directory }}/grafana/prometheus.yaml"
|
|
|
|
mode: "0660"
|
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups[service.group]
|
|
|
|
- service.enabled | bool
|
|
|
|
- enable_prometheus | bool
|
|
|
|
with_first_found:
|
|
|
|
- "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/prometheus.yaml"
|
|
|
|
- "{{ node_custom_config }}/grafana/prometheus.yaml"
|
|
|
|
- "prometheus.yaml.j2"
|
|
|
|
notify:
|
2019-09-25 08:52:56 +02:00
|
|
|
- Restart grafana container
|
2020-12-22 16:35:43 +01:00
|
|
|
|
|
|
|
- name: Configuring dashboards provisioning
|
|
|
|
vars:
|
|
|
|
service: "{{ grafana_services['grafana'] }}"
|
|
|
|
template:
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: "{{ node_config_directory }}/grafana/provisioning.yaml"
|
|
|
|
mode: "0660"
|
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups[service.group]
|
|
|
|
- service.enabled | bool
|
|
|
|
with_first_found:
|
|
|
|
- "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/provisioning.yaml"
|
|
|
|
- "{{ node_custom_config }}/grafana/provisioning.yaml"
|
|
|
|
- "{{ role_path }}/templates/provisioning.yaml.j2"
|
|
|
|
notify:
|
|
|
|
- Restart grafana container
|
|
|
|
|
|
|
|
- name: Check if the folder for custom grafana dashboards exists
|
|
|
|
stat:
|
|
|
|
path: "{{ node_custom_config }}/grafana/dashboards"
|
|
|
|
delegate_to: localhost
|
|
|
|
register: grafana_custom_dashboards_folder
|
|
|
|
run_once: True
|
|
|
|
|
|
|
|
- name: Remove templated Grafana dashboards
|
|
|
|
become: true
|
|
|
|
vars:
|
|
|
|
service: "{{ grafana_services['grafana'] }}"
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ node_config_directory }}/grafana/dashboards/"
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups[service.group]
|
|
|
|
- service.enabled | bool
|
|
|
|
|
|
|
|
- name: Create custom Grafana dashboards folder
|
|
|
|
become: true
|
|
|
|
vars:
|
|
|
|
service: "{{ grafana_services['grafana'] }}"
|
|
|
|
file:
|
|
|
|
dest: "{{ node_config_directory }}/grafana/dashboards/"
|
|
|
|
state: "directory"
|
|
|
|
mode: "0770"
|
|
|
|
when:
|
|
|
|
- grafana_custom_dashboards_folder.stat.exists
|
|
|
|
- grafana_custom_dashboards_folder.stat.isdir
|
|
|
|
- inventory_hostname in groups[service.group]
|
|
|
|
- service.enabled | bool
|
|
|
|
|
|
|
|
- name: Copying over custom dashboards
|
|
|
|
vars:
|
|
|
|
service: "{{ grafana_services['grafana'] }}"
|
|
|
|
copy:
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: "{{ node_config_directory }}/grafana/dashboards/"
|
|
|
|
mode: "0660"
|
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- grafana_custom_dashboards_folder.stat.exists
|
|
|
|
- grafana_custom_dashboards_folder.stat.isdir
|
|
|
|
- inventory_hostname in groups[service.group]
|
|
|
|
- service.enabled | bool
|
|
|
|
with_fileglob:
|
|
|
|
- "{{ node_custom_config }}/grafana/dashboards/*.json"
|
|
|
|
notify:
|
|
|
|
- Restart grafana container
|