main.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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: Include common variables
  16. include_vars: ../../slurm_manager/vars/main.yml
  17. - name: Give slurm user permission to slurmd spool
  18. file:
  19. path: "{{ spool_slurmd_pth }}"
  20. owner: slurm
  21. group: slurm
  22. mode: "{{ tmp_mode }}"
  23. state: touch
  24. - name: Create log files on compute nodes
  25. file:
  26. path: "{{ slurm_logpth }}"
  27. owner: slurm
  28. group: slurm
  29. mode: "{{ tmp_mode }}"
  30. state: touch
  31. with_items:
  32. - slurmd.log
  33. - name: Install firewalld
  34. package:
  35. name: firewalld
  36. state: present
  37. tags: firewalld
  38. - name: Stop and disable firewalld
  39. service:
  40. name: firewalld
  41. state: stopped
  42. enabled: no
  43. tags: firewalld
  44. - name: Copy slurm conf from buffer
  45. copy:
  46. src: "{{ buffer_path }}"
  47. dest: "{{ slurm_confpth }}"
  48. mode: "{{ slurm_mode }}"
  49. - name: Install packages for slurm
  50. package:
  51. name: "{{ slurm_packages }}"
  52. state: present
  53. with_items:
  54. - "{{ slurm_packages }}"
  55. tags: install
  56. - name: Install development tools
  57. package:
  58. name: "{{ item }}"
  59. state: present
  60. with_items:
  61. - "{{ dev_tools }}"
  62. tags: install
  63. - name: Verify if slurm is installed
  64. shell: rpm -qa | grep slurm
  65. ignore_errors: true
  66. register: verify_result
  67. changed_when: no
  68. failed_when: no
  69. args:
  70. warn: no
  71. - name: Create temporary download folder for slurm
  72. file:
  73. path: "{{ tmp_path }}"
  74. owner: slurm
  75. group: slurm
  76. mode: "{{ tmp_mode }}"
  77. state: directory
  78. when: verify_result.rc != 0
  79. - name: Download slurm source
  80. get_url:
  81. url: "{{ slurm_url }}"
  82. dest: "{{ tmp_path }}"
  83. checksum: "{{ slurm_md5 }}"
  84. validate_certs: no
  85. tags: install
  86. when: verify_result.rc != 0
  87. - name: Build slurm rpms
  88. command: rpmbuild -ta "{{ rpmbuild_path }}" --with mysql
  89. changed_when: false
  90. when: verify_result.rc != 0
  91. args:
  92. warn: no
  93. - name: Install rpms
  94. command: rpm -Uvh ~"{{ rpm_loop }}"
  95. args:
  96. chdir: "{{ rpm_path }}"
  97. warn: no
  98. changed_when: true
  99. when: verify_result.rc != 0
  100. - name: Get the hostname
  101. command: hostname
  102. register: machine_name
  103. changed_when: true
  104. - name: Set compute node hostname/host ip to add in manager hosts file
  105. set_fact:
  106. compute_host: "{{ inventory_hostname }}"
  107. compute_ip: "{{ machine_name.stdout }}"
  108. - name: Get socket and core info from compute nodes
  109. set_fact:
  110. node_name: "{{ machine_name.stdout }}"
  111. sockets: "{{ hostvars[inventory_hostname]['ansible_facts']['processor_count'] }}"
  112. cores: "{{ hostvars[inventory_hostname]['ansible_facts']['processor_cores'] }}"
  113. - name: Add compute nodes core & socket info in slurm config file
  114. lineinfile:
  115. dest: "{{ slurm_confpth }}"
  116. line: "NodeName={{ hostvars[item].node_name }} Sockets={{ hostvars[item].sockets }} CoresPerSocket={{ hostvars[item].cores }}"
  117. state: present
  118. create: yes
  119. mode: "{{ slurm_mode }}"
  120. with_items:
  121. - "{{ groups['compute'] }}"
  122. - name: Save slurm conf in buffer
  123. fetch:
  124. src: "{{ slurm_confpth }}"
  125. dest: "{{ buffer_path }}"
  126. flat: true
  127. - name: Start slurmd on compute nodes
  128. systemd:
  129. name: slurmd.service
  130. state: started
  131. enabled: yes
  132. tags: install