main.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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: Give slurm user permission to slurmctld spool
  16. file:
  17. path: "{{ spool_slurmctld_pth }}"
  18. owner: slurm
  19. group: slurm
  20. mode: "{{ tmp_mode }}"
  21. state: touch
  22. - name: Give slurm ownership to cluster state
  23. file:
  24. path: "{{ cluster_state_path }}"
  25. owner: slurm
  26. group: slurm
  27. mode: "{{ tmp_mode }}"
  28. state: touch
  29. - name: Create slurmctld log file on master
  30. file:
  31. path: "{{ slurm_logpth }}"
  32. owner: slurm
  33. mode: "{{ tmp_mode }}"
  34. state: touch
  35. with_items:
  36. - slurmctld.log
  37. - name: Create log files on master
  38. file:
  39. path: "{{ slurm_logpth }}"
  40. owner: slurm
  41. mode: "{{ tmp_mode }}"
  42. state: touch
  43. with_items:
  44. - "{{ log_files_master }}"
  45. - name: Install packages for slurm
  46. package:
  47. name: "{{ item }}"
  48. state: present
  49. with_items:
  50. - "{{ slurm_packages }}"
  51. tags: install
  52. - name: Install development tools
  53. package:
  54. name: "{{ item }}"
  55. state: present
  56. with_items:
  57. - "{{ dev_tools }}"
  58. tags: install
  59. - name: Create temporary download folder for slurm
  60. file:
  61. path: "{{ tmp_path }}"
  62. owner: slurm
  63. group: slurm
  64. mode: "{{ tmp_mode }}"
  65. state: directory
  66. - name: Download slurm source
  67. get_url:
  68. url: "{{ slurm_url }}"
  69. dest: "{{ tmp_path }}"
  70. checksum: "{{ slurm_md5 }}"
  71. validate_certs: no
  72. tags: install
  73. - name: Build slurm rpms
  74. command: rpmbuild -ta "{{ rpmbuild_path }}" --with mysql
  75. changed_when: false
  76. args:
  77. warn: no
  78. - name: Verify package md5
  79. command: rpm -qa
  80. ignore_errors: true
  81. register: verify_result
  82. changed_when: no
  83. failed_when: no
  84. args:
  85. warn: no
  86. - name: Install rpms
  87. command: rpm -Uvh ~"{{ rpm_loop }}"
  88. args:
  89. chdir: "{{ rpm_path }}"
  90. warn: no
  91. changed_when: true
  92. - name: Get the hostname
  93. command: hostname -s
  94. register: machine_name
  95. changed_when: true
  96. - name: Add control machine name
  97. lineinfile:
  98. path: "{{ slurm_confpth }}"
  99. regexp: "ControlMachine="
  100. line: "ControlMachine={{ machine_name.stdout }}"
  101. - name: Add slurm user name
  102. lineinfile:
  103. path: "{{ slurm_confpth }}"
  104. regexp: "SlurmUser="
  105. line: "SlurmUser={{ slurm_user }}"
  106. - name: Install firewalld
  107. package:
  108. name: firewalld
  109. state: present
  110. tags: firewalld
  111. - name: Start and enable firewalld
  112. service:
  113. name: firewalld
  114. state: started
  115. enabled: yes
  116. tags: firewalld
  117. - name: Firewall rule for slurm - tcp/udp ports
  118. firewalld:
  119. zone: public
  120. port: "{{ item }}"
  121. permanent: true
  122. state: enabled
  123. with_items:
  124. - "{{ tcp_port1 }}"
  125. - "{{ tcp_port2 }}"
  126. - "{{ tcp_port3 }}"
  127. - "{{ udp_port3 }}"
  128. - "{{ udp_port1 }}"
  129. - "{{ udp_port2 }}"
  130. when: "'manager' in group_names"
  131. tags: firewalld
  132. - name: Get network address/subnet mask through ipaddr
  133. set_fact:
  134. network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('network/prefix') }}"
  135. - name: Firewall rule slurm - allow all incoming traffic on internal network
  136. firewalld:
  137. zone: internal
  138. rich_rule: 'rule family="{{ family }}" source address="{{ network_address }}" accept'
  139. permanent: true
  140. state: enabled
  141. tags: firewalld
  142. - name: Reload firewalld
  143. command: firewall-cmd --reload
  144. changed_when: true
  145. tags: firewalld
  146. - name: Start mariadb
  147. systemd:
  148. name: mariadb
  149. state: restarted
  150. enabled: yes
  151. tags: install
  152. - name: Grant permissions for slurm db
  153. command: mysql -u root -e "GRANT ALL ON slurm_acct_db.* TO '{{ db_user }}'@'{{ db_host }}' identified by '{{ db_password[0] }}'with grant option;"
  154. tags: install
  155. changed_when: true
  156. - name: Create slurmdbd.conf file
  157. copy:
  158. src: slurmdbd.conf
  159. dest: "{{ slurmdbd_path }}"
  160. mode: "{{ slurmdbd_mode }}"
  161. owner: slurm
  162. tags: install
  163. - name: Add slurm user name
  164. lineinfile:
  165. path: "{{ slurmdbd_path }}"
  166. regexp: "SlurmUser="
  167. line: "SlurmUser={{ slurm_user }}"
  168. - name: Add db address
  169. lineinfile:
  170. path: "{{ slurmdbd_path }}"
  171. regexp: "DbdAddr="
  172. line: "DbdAddr={{ DbdAddr }}"
  173. - name: Add db host
  174. lineinfile:
  175. path: "{{ slurmdbd_path }}"
  176. regexp: "DbdHost="
  177. line: "DbdHost={{ DbdHost }}"
  178. - name: Add storage password
  179. lineinfile:
  180. path: "{{ slurmdbd_path }}"
  181. regexp: "StoragePass="
  182. line: "StoragePass={{ db_password[0] }}"
  183. - name: Add storage user
  184. lineinfile:
  185. path: "{{ slurmdbd_path }}"
  186. regexp: "StorageUser="
  187. line: "StorageUser={{ slurm_user }}"
  188. - name: Add log file path
  189. lineinfile:
  190. path: "{{ slurmdbd_path }}"
  191. regexp: "LogFile="
  192. line: "LogFile={{ logfile }}"
  193. - name: Add pid file path
  194. lineinfile:
  195. path: "{{ slurmdbd_path }}"
  196. regexp: "PidFile="
  197. line: "PidFile={{ pidfile }}"
  198. - name: Save slurm conf file in buffer
  199. fetch:
  200. src: "{{ slurm_confpth }}"
  201. dest: "{{ buffer_path }}"
  202. flat: true