start_services.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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: Install firewalld
  16. package:
  17. name: firewalld
  18. state: present
  19. tags: firewalld
  20. - name: Start and enable firewalld
  21. service:
  22. name: firewalld
  23. state: started
  24. enabled: yes
  25. tags: firewalld
  26. - name: Firewall port addition for slurm exporter
  27. firewalld:
  28. zone: public
  29. port: "{{ item }}"
  30. permanent: true
  31. state: enabled
  32. with_items:
  33. - "{{ slurm_exporter_port }}/tcp"
  34. - "{{ slurm_exporter_port }}/udp"
  35. tags: firewalld
  36. - name: Reload firewalld
  37. command: firewall-cmd --reload
  38. changed_when: true
  39. tags: firewalld
  40. - name: Stop and disable firewalld
  41. service:
  42. name: firewalld
  43. state: stopped
  44. enabled: no
  45. tags: firewalld
  46. - name: Create systemd unit file
  47. copy:
  48. src: "{{ role_path }}/files/prometheus-slurm-exporter.service"
  49. dest: "{{ systemd_path_dest }}"
  50. remote_src: no
  51. mode: "{{ file_permission }}"
  52. - name: Update the port in service file
  53. replace:
  54. path: "{{ systemd_path_dest }}/prometheus-slurm-exporter.service"
  55. regexp: "0.0.0.0:8080"
  56. replace: "0.0.0.0:{{ slurm_exporter_port }}"
  57. tags: init
  58. - name: Start services
  59. systemd:
  60. name: prometheus-slurm-exporter
  61. state: restarted
  62. enabled: yes