main.yml 4.5 KB

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