main.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 manager
  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 manager
  38. file:
  39. path: "{{ slurm_logpth }}"
  40. owner: slurm
  41. mode: "{{ tmp_mode }}"
  42. state: touch
  43. with_items:
  44. - "{{ log_files_manager }}"
  45. - name: Install packages for slurm
  46. package:
  47. name: "{{ slurm_packages }}"
  48. state: present
  49. tags: install
  50. - name: Install development tools
  51. package:
  52. name: "{{ dev_tools }}"
  53. state: present
  54. tags: install
  55. - name: Verify if slurm is installed
  56. shell: rpm -qa | grep slurm
  57. ignore_errors: true
  58. register: verify_result
  59. changed_when: no
  60. failed_when: no
  61. args:
  62. warn: no
  63. - name: Create temporary download folder for slurm
  64. file:
  65. path: "{{ tmp_path }}"
  66. owner: slurm
  67. group: slurm
  68. mode: "{{ tmp_mode }}"
  69. state: directory
  70. when: verify_result.rc != 0
  71. - name: Download slurm source
  72. get_url:
  73. url: "{{ slurm_url }}"
  74. dest: "{{ tmp_path }}"
  75. checksum: "{{ slurm_md5 }}"
  76. validate_certs: no
  77. tags: install
  78. when: verify_result.rc != 0
  79. - name: Build slurm rpms
  80. command: rpmbuild -ta "{{ rpmbuild_path }}" --with mysql
  81. changed_when: false
  82. when: verify_result.rc != 0
  83. args:
  84. warn: no
  85. - name: Install rpms
  86. command: rpm -Uvh ~"{{ rpm_loop }}"
  87. args:
  88. chdir: "{{ rpm_path }}"
  89. warn: no
  90. changed_when: true
  91. when: verify_result.rc != 0
  92. - name: Get the hostname
  93. command: hostname
  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. - "{{ tcp_port4 }}"
  128. - "{{ udp_port3 }}"
  129. - "{{ udp_port1 }}"
  130. - "{{ udp_port2 }}"
  131. when: "'manager' in group_names"
  132. tags: firewalld
  133. - name: Get network address/subnet mask
  134. set_fact:
  135. network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('network/prefix') }}"
  136. - name: Firewall rule slurm - allow all incoming traffic on internal network
  137. firewalld:
  138. zone: public
  139. rich_rule: 'rule family="{{ family }}" source address="{{ network_address }}" accept'
  140. permanent: true
  141. state: enabled
  142. tags: firewalld
  143. - name: Reload firewalld
  144. command: firewall-cmd --reload
  145. changed_when: true
  146. tags: firewalld
  147. - name: Start mariadb
  148. systemd:
  149. name: mariadb
  150. state: restarted
  151. enabled: yes
  152. tags: install
  153. - name: Grant permissions for slurm db
  154. command: >-
  155. mysql -u root -e "GRANT ALL ON slurm_acct_db.* TO '{{ db_user }}'@'{{
  156. db_host }}' identified by '{{ hostvars['127.0.0.1']['db_password'] }}'with
  157. grant option;"
  158. tags: install
  159. changed_when: true
  160. - name: Create slurmdbd.conf file
  161. copy:
  162. src: slurmdbd.conf
  163. dest: "{{ slurmdbd_path }}"
  164. mode: "{{ slurmdbd_mode }}"
  165. owner: slurm
  166. tags: install
  167. - name: Add slurm user name
  168. lineinfile:
  169. path: "{{ slurmdbd_path }}"
  170. regexp: "SlurmUser="
  171. line: "SlurmUser={{ slurm_user }}"
  172. - name: Add db address
  173. lineinfile:
  174. path: "{{ slurmdbd_path }}"
  175. regexp: "DbdAddr="
  176. line: "DbdAddr={{ DbdAddr }}"
  177. - name: Add db host
  178. lineinfile:
  179. path: "{{ slurmdbd_path }}"
  180. regexp: "DbdHost="
  181. line: "DbdHost={{ DbdHost }}"
  182. - name: Add storage password
  183. lineinfile:
  184. path: "{{ slurmdbd_path }}"
  185. regexp: "StoragePass="
  186. line: "StoragePass={{ hostvars['127.0.0.1']['db_password'] }}"
  187. - name: Add storage user
  188. lineinfile:
  189. path: "{{ slurmdbd_path }}"
  190. regexp: "StorageUser="
  191. line: "StorageUser={{ slurm_user }}"
  192. - name: Add log file path
  193. lineinfile:
  194. path: "{{ slurmdbd_path }}"
  195. regexp: "LogFile="
  196. line: "LogFile={{ logfile }}"
  197. - name: Add pid file path
  198. lineinfile:
  199. path: "{{ slurmdbd_path }}"
  200. regexp: "PidFile="
  201. line: "PidFile={{ pidfile }}"
  202. - name: Save slurm conf file in buffer
  203. fetch:
  204. src: "{{ slurm_confpth }}"
  205. dest: "{{ buffer_path }}"
  206. flat: true