configure_grafana.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Include k8s_start_services variables
  16. include_vars: ../../k8s_start_services/vars/main.yml
  17. - name: Create prometheus datasource in grafana
  18. community.grafana.grafana_datasource:
  19. name: "hpc-prometheus-{{ ansible_default_ipv4.address }}"
  20. grafana_url: "http://{{ grafana_svc_ip }}:{{ grafana_svc_port }}"
  21. grafana_user: "{{ hostvars['127.0.0.1']['grafana_username'] }}"
  22. grafana_password: "{{ hostvars['127.0.0.1']['grafana_password'] }}"
  23. ds_type: prometheus
  24. ds_url: "http://{{ ansible_default_ipv4.address }}:{{ nginx_listen_port }}"
  25. access: direct
  26. delegate_to: localhost
  27. no_log: true
  28. - name: Replace data source in slurm dashboard
  29. replace:
  30. path: "{{ role_path }}/files/{{ item }}"
  31. regexp: '"uid": "hpc.*'
  32. replace: '"uid": "hpc-prometheus-{{ ansible_default_ipv4.address }}"'
  33. with_items: "{{ slurm_dashboard_json_files }}"
  34. delegate_to: localhost
  35. - name: Replace title in slurm dashboard (1/2)
  36. replace:
  37. path: "{{ role_path }}/files/slurm-dashboard-node-exporter.json"
  38. regexp: '"title": "SLURM - Node Exporter Server Metrics.*'
  39. replace: '"title": "SLURM - Node Exporter Server Metrics - ({{ ansible_default_ipv4.address }})",'
  40. delegate_to: localhost
  41. - name: Replace title in slurm dashboard (2/2)
  42. replace:
  43. path: "{{ role_path }}/files/slurm-dashboard.json"
  44. regexp: '"title": "SLURM - CPUs/GPUs, Nodes, Jobs, Scheduler.*'
  45. replace: '"title": "SLURM - CPUs/GPUs, Nodes, Jobs, Scheduler ({{ ansible_default_ipv4.address }})",'
  46. delegate_to: localhost
  47. - name: Import Slurm Grafana dashboards
  48. community.grafana.grafana_dashboard:
  49. grafana_url: "http://{{ grafana_svc_ip }}:{{ grafana_svc_port }}"
  50. grafana_user: "{{ hostvars['127.0.0.1']['grafana_username'] }}"
  51. grafana_password: "{{ hostvars['127.0.0.1']['grafana_password'] }}"
  52. state: present
  53. commit_message: Updated by ansible
  54. overwrite: yes
  55. path: "{{ role_path }}/files/{{ item }}"
  56. with_items: "{{ slurm_dashboard_json_files }}"
  57. delegate_to: localhost
  58. no_log: true