configure_prometheus_pod.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright 2020 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: Copy the slurm exporter config file
  16. copy:
  17. src: "{{ slurm_config_file }}"
  18. dest: "{{ installation_dir }}"
  19. owner: root
  20. group: root
  21. mode: "{{ file_permission }}"
  22. - name: Add the host IP to config file
  23. lineinfile:
  24. dest: "{{ installation_dir }}/{{ slurm_config_file }}"
  25. regexp: "http:"
  26. insertafter: "- targets"
  27. line: " - http://{{ inventory_hostname }}:8080/metrics"
  28. state: present
  29. backup: yes
  30. backrefs: yes
  31. - name: Verify if slurm exporter is already configured
  32. command: kubectl get service prometheus-slurmexporter-metrics-2
  33. register: service_status
  34. changed_when: False
  35. ignore_errors: yes
  36. - name: Apply slurm exporter configuration to prometheus
  37. command: kubectl apply -f "{{ installation_dir }}/{{ slurm_config_file }}" --validate=false
  38. changed_when: true
  39. when: "'Error from server (NotFound)' in service_status.stderr"