main.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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: 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.4
  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.4
  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. - name: Create munge key
  55. command: "{{ munge_cmd }}"
  56. changed_when: true
  57. - name: Copy munge key
  58. copy:
  59. src: munge.key
  60. dest: "{{ munge_dest }}"
  61. owner: munge
  62. group: munge
  63. mode: "{{ munge_mode }}"
  64. tags: install
  65. - name: Slurm configuration - slurm.conf
  66. copy:
  67. src: slurm.conf
  68. dest: "{{ slurm_dest }}"
  69. mode: "{{ slurm_mode }}"
  70. tags: install
  71. - name: Add cluster name
  72. lineinfile:
  73. path: "{{ slurm_confpth }}"
  74. regexp: "ClusterName="
  75. line: "ClusterName={{ cluster_name }}"
  76. - name: Add slurm user name
  77. lineinfile:
  78. path: "{{ slurm_confpth }}"
  79. regexp: "SlurmUser="
  80. line: "SlurmUser={{ slurm_user }}"
  81. - name: Add slurmctld port no
  82. lineinfile:
  83. path: "{{ slurm_confpth }}"
  84. regexp: "SlurmctldPort="
  85. line: "SlurmctldPort={{ slurmctld_port }}"
  86. - name: Add slurmd port no
  87. lineinfile:
  88. path: "{{ slurm_confpth }}"
  89. regexp: "SlurmdPort="
  90. line: "SlurmdPort={{ slurmd_port }}"
  91. - name: Add srun port range
  92. lineinfile:
  93. path: "{{ slurm_confpth }}"
  94. regexp: "SrunPortRange="
  95. line: "SrunPortRange={{ srun_port_range }}"
  96. - name: Add spool path
  97. lineinfile:
  98. path: "{{ slurm_confpth }}"
  99. regexp: "SlurmdSpoolDir="
  100. line: "SlurmdSpoolDir={{ spool_pth }}"
  101. - name: Add slurmctld pid file path
  102. lineinfile:
  103. path: "{{ slurm_confpth }}"
  104. regexp: "SlurmctldPidFile="
  105. line: "SlurmctldPidFile={{ slurmctld_pid }}"
  106. - name: Add slurmd pid file path
  107. lineinfile:
  108. path: "{{ slurm_confpth }}"
  109. regexp: "SlurmdPidFile="
  110. line: "SlurmdPidFile={{ slurmd_pid }}"
  111. - name: Add slurmctld log file path
  112. lineinfile:
  113. path: "{{ slurm_confpth }}"
  114. regexp: "SlurmctldLogFile="
  115. line: "SlurmctldLogFile={{ slurmctld_log }}"
  116. - name: Add slurmd log file path
  117. lineinfile:
  118. path: "{{ slurm_confpth }}"
  119. regexp: "SlurmdLogFile="
  120. line: "SlurmdLogFile={{ slurmd_log }}"
  121. - name: Add accounting storage port no
  122. lineinfile:
  123. path: "{{ slurm_confpth }}"
  124. regexp: "AccountingStoragePort="
  125. line: "AccountingStoragePort={{ acct_port }}"
  126. - name: Create slurm group
  127. group:
  128. name: slurm
  129. state: present
  130. tags: install
  131. - name: Add the user 'slurm' with uid 6001 and a primary group of 'slurm'
  132. user:
  133. name: slurm
  134. comment: Slurm User Account
  135. uid: "{{ slurm_uid }}"
  136. group: slurm
  137. tags: install
  138. - name: Create slurm log directory
  139. file:
  140. path: "{{ slurm_logpth }}"
  141. state: directory
  142. owner: slurm
  143. group: slurm
  144. mode: "{{ gen_mode }}"
  145. recurse: yes
  146. tags: install
  147. - name: Give slurm user permission to spool
  148. file:
  149. path: "{{ spool_pth }}"
  150. owner: slurm
  151. group: slurm
  152. state: directory
  153. mode: "{{ gen_mode }}"
  154. recurse: yes
  155. - name: Give slurm user permission to spool directory
  156. file:
  157. path: "{{ spool_dir }}"
  158. owner: slurm
  159. group: slurm
  160. state: directory
  161. mode: "{{ common_mode }}"
  162. recurse: yes
  163. - name: Create slurm pid directory
  164. file:
  165. path: "{{ slurm_pidpth }}"
  166. state: directory
  167. owner: slurm
  168. group: slurm
  169. mode: "{{ gen_mode }}"
  170. recurse: yes
  171. tags: install
  172. - name: Give slurm user permission to slurmctld
  173. file:
  174. path: "{{ slurmctld_pid }}"
  175. owner: slurm
  176. group: slurm
  177. mode: "{{ gen_mode }}"
  178. state: touch
  179. - name: Give slurm user permission to slurmd
  180. file:
  181. path: "{{ slurmd_pid }}"
  182. owner: slurm
  183. group: slurm
  184. mode: "{{ gen_mode }}"
  185. state: touch
  186. - name: Start munge service
  187. systemd:
  188. name: munge
  189. state: restarted
  190. enabled: yes
  191. tags: install
  192. failed_when: false