install_slurm_exporter.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: Download and untar go package
  16. unarchive:
  17. src: "{{ go_pack_url }}"
  18. dest: "{{ installation_dir }}"
  19. remote_src: yes
  20. - name: Add to the linux path
  21. shell: echo $PATH
  22. environment:
  23. PATH: "{{ extended_path }}:{{ ansible_env.PATH }}"
  24. changed_when: False
  25. - name: Clone the source code
  26. git:
  27. repo: "{{ slurm_exporter_git_repo }}"
  28. dest: "{{ slurm_exporter_inst_dir }}"
  29. version: "{{ stable_commit_id }}"
  30. - name: export GOPATH
  31. shell: echo $GOPATH
  32. environment:
  33. PATH: "{{ ansible_env.PATH }}:/var/lib/go/bin/"
  34. GOPATH: "{{ go_modules_path }}"
  35. changed_when: False
  36. - name: Download dependencies
  37. command: "{{ go_exec_path }} mod download"
  38. args:
  39. chdir: "{{ slurm_exporter_inst_dir }}"
  40. changed_when: False
  41. - name: Build the exporter
  42. shell: "{{ go_exec_path }} build -o bin/prometheus-slurm-exporter {main,accounts,cpus,nodes,partitions,queue,scheduler,users}.go"
  43. args:
  44. chdir: "{{ slurm_exporter_inst_dir }}"
  45. changed_when: False
  46. - name: Run all tests included in _test.go files
  47. shell: "{{ go_exec_path }} test -v *.go"
  48. args:
  49. chdir: "{{ slurm_exporter_inst_dir }}"
  50. changed_when: False
  51. ignore_errors: yes
  52. - name: Copy executable to /usr/bin
  53. copy:
  54. src: "{{ slurm_exporter_exec }}"
  55. dest: "{{ system_path }}"
  56. remote_src: yes
  57. mode: "{{ file_permission }}"