main.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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: Get hostname
  16. command: hostname
  17. register: host_name
  18. changed_when: true
  19. - name: Add host name in file
  20. replace:
  21. dest: "{{ hostname_dest }}"
  22. regexp: localhost.localdomain
  23. replace: "{{ host_name.stdout }}"
  24. backup: yes
  25. mode: "{{ common_mode }}"
  26. - name: Enable powertools repo in Rocky 8
  27. command: dnf config-manager --set-enabled powertools -y
  28. when:
  29. - ( ansible_distribution | lower == os_centos ) or
  30. ( ansible_distribution | lower == os_rocky )
  31. - ( ansible_distribution_version >= os_version )
  32. - name: Add python dependent packages for CentOS 7.9
  33. package:
  34. name: "{{ common_python2_packages }}"
  35. state: present
  36. tags: install
  37. when:
  38. - ( ansible_distribution | lower == os_centos )
  39. - ( ansible_distribution_version < os_version )
  40. - name: Add python dependent packages for CentOS version > 8 and Rocky 8
  41. package:
  42. name: "{{ common_python3_packages }}"
  43. state: present
  44. tags: install
  45. when:
  46. - ( ansible_distribution | lower == os_centos ) or
  47. ( ansible_distribution | lower == os_rocky )
  48. - ( ansible_distribution_version >= os_version )
  49. - name: Install packages for slurm
  50. package:
  51. name: "{{ common_packages }}"
  52. state: present
  53. tags: install
  54. when: os_supported_leap not in compute_os
  55. - name: Install packages for slurm
  56. package:
  57. name: "{{ leap_common_packages }}"
  58. state: present
  59. when: os_supported_leap in compute_os
  60. - name: Create munge key
  61. command: "{{ munge_cmd }}"
  62. changed_when: true
  63. when: os_supported_leap not in compute_os
  64. - name: Create munge key
  65. shell: dd if=/dev/random bs=1 count=1024 >/etc/munge/munge.key
  66. changed_when: true
  67. when: os_supported_leap in compute_os
  68. - name: Copy munge key
  69. copy:
  70. src: munge.key
  71. dest: "{{ munge_dest }}"
  72. owner: munge
  73. group: munge
  74. mode: "{{ munge_mode }}"
  75. tags: install
  76. - name: Slurm configuration - slurm.conf
  77. copy:
  78. src: slurm.conf
  79. dest: "{{ slurm_dest }}"
  80. mode: "{{ slurm_mode }}"
  81. tags: install
  82. - name: Add cluster name
  83. lineinfile:
  84. path: "{{ slurm_confpth }}"
  85. regexp: "ClusterName="
  86. line: "ClusterName={{ cluster_name }}"
  87. - name: Add slurm user name
  88. lineinfile:
  89. path: "{{ slurm_confpth }}"
  90. regexp: "SlurmUser="
  91. line: "SlurmUser={{ slurm_user }}"
  92. - name: Add slurmctld port no
  93. lineinfile:
  94. path: "{{ slurm_confpth }}"
  95. regexp: "SlurmctldPort="
  96. line: "SlurmctldPort={{ slurmctld_port }}"
  97. - name: Add slurmd port no
  98. lineinfile:
  99. path: "{{ slurm_confpth }}"
  100. regexp: "SlurmdPort="
  101. line: "SlurmdPort={{ slurmd_port }}"
  102. - name: Add srun port range
  103. lineinfile:
  104. path: "{{ slurm_confpth }}"
  105. regexp: "SrunPortRange="
  106. line: "SrunPortRange={{ srun_port_range }}"
  107. - name: Add spool path
  108. lineinfile:
  109. path: "{{ slurm_confpth }}"
  110. regexp: "SlurmdSpoolDir="
  111. line: "SlurmdSpoolDir={{ spool_pth }}"
  112. - name: Add slurmctld pid file path
  113. lineinfile:
  114. path: "{{ slurm_confpth }}"
  115. regexp: "SlurmctldPidFile="
  116. line: "SlurmctldPidFile={{ slurmctld_pid }}"
  117. - name: Add slurmd pid file path
  118. lineinfile:
  119. path: "{{ slurm_confpth }}"
  120. regexp: "SlurmdPidFile="
  121. line: "SlurmdPidFile={{ slurmd_pid }}"
  122. - name: Add slurmctld log file path
  123. lineinfile:
  124. path: "{{ slurm_confpth }}"
  125. regexp: "SlurmctldLogFile="
  126. line: "SlurmctldLogFile={{ slurmctld_log }}"
  127. - name: Add slurmd log file path
  128. lineinfile:
  129. path: "{{ slurm_confpth }}"
  130. regexp: "SlurmdLogFile="
  131. line: "SlurmdLogFile={{ slurmd_log }}"
  132. - name: Add accounting storage port no
  133. lineinfile:
  134. path: "{{ slurm_confpth }}"
  135. regexp: "AccountingStoragePort="
  136. line: "AccountingStoragePort={{ acct_port }}"
  137. - name: Create slurm group
  138. group:
  139. name: slurm
  140. state: present
  141. tags: install
  142. - name: Add the user 'slurm' with uid 6001 and a primary group of 'slurm'
  143. user:
  144. name: slurm
  145. comment: Slurm User Account
  146. uid: "{{ slurm_uid }}"
  147. group: slurm
  148. tags: install
  149. - name: Create slurm log directory
  150. file:
  151. path: "{{ slurm_logpth }}"
  152. state: directory
  153. owner: slurm
  154. group: slurm
  155. mode: "{{ gen_mode }}"
  156. recurse: yes
  157. tags: install
  158. - name: Give slurm user permission to spool
  159. file:
  160. path: "{{ spool_pth }}"
  161. owner: slurm
  162. group: slurm
  163. state: directory
  164. mode: "{{ gen_mode }}"
  165. recurse: yes
  166. - name: Give slurm user permission to spool directory
  167. file:
  168. path: "{{ spool_dir }}"
  169. owner: slurm
  170. group: slurm
  171. state: directory
  172. mode: "{{ common_mode }}"
  173. recurse: yes
  174. - name: Create slurm pid directory
  175. file:
  176. path: "{{ slurm_pidpth }}"
  177. state: directory
  178. owner: slurm
  179. group: slurm
  180. mode: "{{ gen_mode }}"
  181. recurse: yes
  182. tags: install
  183. - name: Give slurm user permission to slurmctld
  184. file:
  185. path: "{{ slurmctld_pid }}"
  186. owner: slurm
  187. group: slurm
  188. mode: "{{ gen_mode }}"
  189. state: touch
  190. - name: Give slurm user permission to slurmd
  191. file:
  192. path: "{{ slurmd_pid }}"
  193. owner: slurm
  194. group: slurm
  195. mode: "{{ gen_mode }}"
  196. state: touch
  197. - name: Start munge service
  198. systemd:
  199. name: munge
  200. state: restarted
  201. enabled: yes
  202. tags: install
  203. failed_when: false