browbeat/ansible/install/roles/grafana-dashboards/tasks/main.yml

91 lines
3.5 KiB
YAML

---
#
# Generate & Upload Browbeat OpenStack Grafana Dashboards
#
# check that grafana_apikey is entered prior to playbook run
- name: Check Grafana API key
fail:
msg="** Edit grafana_apikey in ../install/group_vars/all.yml before running **"
when: grafana_apikey is none
- name: Check Cloud Name
fail:
msg: "The Cloud name {{dashboard_cloud_name}} is reserved for a service, please use a different one"
when: item == dashboard_cloud_name
with_items: "{{forbidden_cloud_names}}"
# Templated Cloud Specific Dashboards
- name: Generate Cloud Specific CPU/Memory/Disk/Network/Log Dashboards from GrafYaml Templates
template:
src: "cloud_specific_{{item}}.yaml.j2"
dest: "{{role_path}}/files/cloud_specific_{{item}}.yaml"
when: upload_cloud_specific|bool
with_items: "{{cloud_specific_dashboards}}"
- name: Upload Cloud Specific CPU/Memory/Disk/Network/Log Dashboards via GrafYaml
shell: |
. {{browbeat_venv}}/bin/activate
grafana-dashboard --grafana-url http://{{grafana_host}}:{{grafana_port}} --grafana-apikey {{grafana_apikey}} update {{role_path}}/files/cloud_specific_{{item}}.yaml
when: upload_cloud_specific|bool
with_items: "{{cloud_specific_dashboards}}"
- name: Remove leftover yaml file(s) from Cloud Specific CPU/Memory/Disk/Network/Log Dashboards
file:
path: "{{role_path}}/files/cloud_specific_{{item}}.yaml"
state: absent
when: upload_cloud_specific|bool
with_items: "{{cloud_specific_dashboards}}"
# Templated General Performance Dashboards
- name: Generate General Performance Dashboards
template:
src: "{{role_path}}/templates/{{item.template_name}}_general_system_performance.yaml.j2"
dest: "{{role_path}}/files/{{item.process_list_name}}_general_system_performance.yaml"
when: upload_general|bool
with_items: "{{general_dashboards}}"
- name: Upload General Performance Dashboards to Grafana
shell: |
. {{browbeat_venv}}/bin/activate
grafana-dashboard --grafana-url http://{{grafana_host}}:{{grafana_port}} --grafana-apikey {{grafana_apikey}} update {{role_path}}/files/{{item.process_list_name}}_general_system_performance.yaml
when: upload_general|bool
with_items: "{{general_dashboards}}"
- name: Remove leftover yaml file(s) from General Performance Dashboards
file:
path: "{{role_path}}/files/{{item.process_list_name}}_general_system_performance.yaml"
state: absent
when: upload_general|bool
with_items: "{{general_dashboards}}"
# Static Dashboards:
- name: Upload Static Dashboards to Grafana via GrafYaml
shell: |
. {{browbeat_venv}}/bin/activate
grafana-dashboard --grafana-url http://{{grafana_host}}:{{grafana_port}} --grafana-apikey {{grafana_apikey}} update {{role_path}}/files/{{item}}.yaml
when: upload_static|bool
with_items: "{{static_dashboards}}"
# Templated Dashboards
- name: Generate Templated Dashboards
template:
src: "{{item}}.yaml.j2"
dest: "{{role_path}}/files/{{item}}.yaml"
when: upload_templated|bool
with_items: "{{templated_dashboards}}"
- name: Upload Generated Templated Dashboards via GrafYaml
shell: |
. {{browbeat_venv}}/bin/activate
grafana-dashboard --grafana-url http://{{grafana_host}}:{{grafana_port}} --grafana-apikey {{grafana_apikey}} update {{role_path}}/files/{{item}}.yaml
when: upload_templated|bool
with_items: "{{templated_dashboards}}"
- name: Remove leftover yaml file(s) from Generated Templated Dashboards
file:
path: "{{role_path}}/files/{{item}}.yaml"
state: absent
when: upload_templated|bool
with_items: "{{templated_dashboards}}"