9702d4c3c3
Including tasks has a performance penalty when compared with importing tasks. If the include has a condition associated with it, then the overhead of the include may be lower than the overhead of skipping all imported tasks. In the case of the check-containers.yml include, the included file only has a single task, so the overhead of skipping this task will not be greater than the overhead of the task import. It therefore makes sense to switch to use import_tasks there. Partially-Implements: blueprint performance-improvements Change-Id: I65d911670649960708b9f6a4c110d1a7df1ad8f7
108 lines
3.1 KiB
YAML
108 lines
3.1 KiB
YAML
---
|
|
- name: Ensuring config directories exist
|
|
file:
|
|
path: "{{ node_config_directory }}/{{ item.key }}"
|
|
state: "directory"
|
|
owner: "{{ config_owner_user }}"
|
|
group: "{{ config_owner_group }}"
|
|
mode: "0770"
|
|
become: true
|
|
when:
|
|
- inventory_hostname in groups[item.value.group]
|
|
- item.value.enabled | bool
|
|
with_dict: "{{ grafana_services }}"
|
|
|
|
- name: Check if extra configuration file exists
|
|
find:
|
|
path: "{{ node_custom_config }}/grafana/"
|
|
delegate_to: localhost
|
|
changed_when: False
|
|
run_once: True
|
|
register: check_extra_conf_grafana
|
|
|
|
- include_tasks: copy-certs.yml
|
|
when:
|
|
- kolla_copy_ca_into_containers | bool
|
|
|
|
- name: Copying over config.json files
|
|
template:
|
|
src: "{{ item.key }}.json.j2"
|
|
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
|
mode: "0660"
|
|
become: true
|
|
when:
|
|
- inventory_hostname in groups[item.value.group]
|
|
- item.value.enabled | bool
|
|
with_dict: "{{ grafana_services }}"
|
|
notify:
|
|
- Restart {{ item.key }} container
|
|
|
|
- name: Copying over grafana.ini
|
|
vars:
|
|
service_name: "{{ item.key }}"
|
|
merge_configs:
|
|
sources:
|
|
- "{{ role_path }}/templates/grafana.ini.j2"
|
|
- "{{ node_custom_config }}/{{ item.key }}.ini"
|
|
- "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/{{ item.key }}.ini"
|
|
dest: "{{ node_config_directory }}/grafana/grafana.ini"
|
|
mode: "0660"
|
|
become: true
|
|
when:
|
|
- inventory_hostname in groups[item.value.group]
|
|
- item.value.enabled | bool
|
|
with_dict: "{{ grafana_services }}"
|
|
notify:
|
|
- Restart {{ item.key }} container
|
|
|
|
- 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:
|
|
- 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
|
|
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'] }}"
|
|
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:
|
|
- Restart grafana container
|
|
|
|
- import_tasks: check-containers.yml
|
|
when: kolla_action != "config"
|