configure_grafana.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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: Create prometheus datasource in grafana
  16. community.grafana.grafana_datasource:
  17. name: "hpc-prometheus-{{ ansible_default_ipv4.address }}"
  18. grafana_url: "http://{{ grafana_svc_ip }}:{{ grafana_svc_port }}"
  19. grafana_user: "{{ hostvars['127.0.0.1']['grafana_username'] }}"
  20. grafana_password: "{{ hostvars['127.0.0.1']['grafana_password'] }}"
  21. ds_type: prometheus
  22. ds_url: "http://{{ ansible_default_ipv4.address }}"
  23. access: direct
  24. delegate_to: localhost
  25. no_log: true
  26. - name: Replace data source in slurm dashboard
  27. replace:
  28. path: "{{ role_path }}/files/{{ item }}"
  29. regexp: '"uid": "hpc.*'
  30. replace: '"uid": "hpc-prometheus-{{ ansible_default_ipv4.address }}"'
  31. with_items: "{{ slurm_dashboard_json_files }}"
  32. delegate_to: localhost
  33. - name: Replace title in slurm dashboard (1/2)
  34. replace:
  35. path: "{{ role_path }}/files/slurm-dashboard-node-exporter.json"
  36. regexp: '"title": "SLURM - Node Exporter Server Metrics.*'
  37. replace: '"title": "SLURM - Node Exporter Server Metrics - ({{ ansible_default_ipv4.address }})",'
  38. delegate_to: localhost
  39. - name: Replace title in slurm dashboard (2/2)
  40. replace:
  41. path: "{{ role_path }}/files/slurm-dashboard.json"
  42. regexp: '"title": "SLURM - CPUs/GPUs, Nodes, Jobs, Scheduler.*'
  43. replace: '"title": "SLURM - CPUs/GPUs, Nodes, Jobs, Scheduler ({{ ansible_default_ipv4.address }})",'
  44. delegate_to: localhost
  45. - name: Import Slurm Grafana dashboards
  46. community.grafana.grafana_dashboard:
  47. grafana_url: "http://{{ grafana_svc_ip }}:{{ grafana_svc_port }}"
  48. grafana_user: "{{ hostvars['127.0.0.1']['grafana_username'] }}"
  49. grafana_password: "{{ hostvars['127.0.0.1']['grafana_password'] }}"
  50. state: present
  51. commit_message: Updated by ansible
  52. overwrite: yes
  53. path: "{{ role_path }}/files/{{ item }}"
  54. with_items: "{{ slurm_dashboard_json_files }}"
  55. delegate_to: localhost
  56. no_log: true