main.yml 4.5 KB

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