main.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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: Install packages for slurm
  27. package:
  28. name: "{{ item }}"
  29. state: present
  30. with_items:
  31. - "{{ common_packages }}"
  32. tags: install
  33. - name: Create munge key
  34. command: "{{ munge_cmd }}"
  35. changed_when: true
  36. - name: Copy munge key
  37. copy:
  38. src: munge.key
  39. dest: "{{ munge_dest }}"
  40. owner: munge
  41. group: munge
  42. mode: "{{ munge_mode }}"
  43. tags: install
  44. - name: Slurm configuration - slurm.conf
  45. copy:
  46. src: slurm.conf
  47. dest: "{{ slurm_dest }}"
  48. mode: "{{ slurm_mode }}"
  49. tags: install
  50. - name: Add cluster name
  51. lineinfile:
  52. path: "{{ slurm_confpth }}"
  53. regexp: "ClusterName="
  54. line: "ClusterName={{ cluster_name }}"
  55. - name: Add slurm user name
  56. lineinfile:
  57. path: "{{ slurm_confpth }}"
  58. regexp: "SlurmUser="
  59. line: "SlurmUser={{ slurm_user }}"
  60. - name: Add slurmctld port no
  61. lineinfile:
  62. path: "{{ slurm_confpth }}"
  63. regexp: "SlurmctldPort="
  64. line: "SlurmctldPort={{ slurmctld_port }}"
  65. - name: Add slurmd port no
  66. lineinfile:
  67. path: "{{ slurm_confpth }}"
  68. regexp: "SlurmdPort="
  69. line: "SlurmdPort={{ slurmd_port }}"
  70. - name: Add srun port range
  71. lineinfile:
  72. path: "{{ slurm_confpth }}"
  73. regexp: "SrunPortRange="
  74. line: "SrunPortRange={{ srun_port_range }}"
  75. - name: Add spool path
  76. lineinfile:
  77. path: "{{ slurm_confpth }}"
  78. regexp: "SlurmdSpoolDir="
  79. line: "SlurmdSpoolDir={{ spool_pth }}"
  80. - name: Add slurmctld pid file path
  81. lineinfile:
  82. path: "{{ slurm_confpth }}"
  83. regexp: "SlurmctldPidFile="
  84. line: "SlurmctldPidFile={{ slurmctld_pid }}"
  85. - name: Add slurmd pid file path
  86. lineinfile:
  87. path: "{{ slurm_confpth }}"
  88. regexp: "SlurmdPidFile="
  89. line: "SlurmdPidFile={{ slurmd_pid }}"
  90. - name: Add slurmctld log file path
  91. lineinfile:
  92. path: "{{ slurm_confpth }}"
  93. regexp: "SlurmctldLogFile="
  94. line: "SlurmctldLogFile={{ slurmctld_log }}"
  95. - name: Add slurmd log file path
  96. lineinfile:
  97. path: "{{ slurm_confpth }}"
  98. regexp: "SlurmdLogFile="
  99. line: "SlurmdLogFile={{ slurmd_log }}"
  100. - name: Add accounting storage port no
  101. lineinfile:
  102. path: "{{ slurm_confpth }}"
  103. regexp: "AccountingStoragePort="
  104. line: "AccountingStoragePort={{ acct_port }}"
  105. - name: Create slurm group
  106. group:
  107. name: slurm
  108. state: present
  109. tags: install
  110. - name: Add the user 'slurm' with uid 6001 and a primary group of 'slurm'
  111. user:
  112. name: slurm
  113. comment: Slurm User Account
  114. uid: "{{ slurm_uid }}"
  115. group: slurm
  116. tags: install
  117. - name: Create slurm log directory
  118. file:
  119. path: "{{ slurm_logpth }}"
  120. state: directory
  121. owner: slurm
  122. group: slurm
  123. mode: "{{ gen_mode }}"
  124. recurse: yes
  125. tags: install
  126. - name: Give slurm user permission to spool
  127. file:
  128. path: "{{ spool_pth }}"
  129. owner: slurm
  130. group: slurm
  131. state: directory
  132. mode: "{{ gen_mode }}"
  133. recurse: yes
  134. - name: Give slurm user permission to spool directory
  135. file:
  136. path: "{{ spool_dir }}"
  137. owner: slurm
  138. group: slurm
  139. state: directory
  140. mode: "{{ common_mode }}"
  141. recurse: yes
  142. - name: Create slurm pid directory
  143. file:
  144. path: "{{ slurm_pidpth }}"
  145. state: directory
  146. owner: slurm
  147. group: slurm
  148. mode: "{{ gen_mode }}"
  149. recurse: yes
  150. tags: install
  151. - name: Give slurm user permission to slurmctld
  152. file:
  153. path: "{{ slurmctld_pid }}"
  154. owner: slurm
  155. group: slurm
  156. mode: "{{ gen_mode }}"
  157. state: touch
  158. - name: Give slurm user permission to slurmd
  159. file:
  160. path: "{{ slurmd_pid }}"
  161. owner: slurm
  162. group: slurm
  163. mode: "{{ gen_mode }}"
  164. state: touch
  165. - name: Start munge service
  166. systemd:
  167. name: munge
  168. state: restarted
  169. enabled: yes
  170. tags: install
  171. ignore_errors: yes