main.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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: "{{ 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: Verify if slurm is installed
  60. shell: rpm -qa | grep slurm
  61. ignore_errors: true
  62. register: verify_result
  63. changed_when: no
  64. failed_when: no
  65. args:
  66. warn: no
  67. - name: Create temporary download folder for slurm
  68. file:
  69. path: "{{ tmp_path }}"
  70. owner: slurm
  71. group: slurm
  72. mode: "{{ tmp_mode }}"
  73. state: directory
  74. when: verify_result.rc != 0
  75. - name: Download slurm source
  76. get_url:
  77. url: "{{ slurm_url }}"
  78. dest: "{{ tmp_path }}"
  79. checksum: "{{ slurm_md5 }}"
  80. validate_certs: no
  81. tags: install
  82. when: verify_result.rc != 0
  83. - name: Build slurm rpms
  84. command: rpmbuild -ta "{{ rpmbuild_path }}" --with mysql
  85. changed_when: false
  86. when: verify_result.rc != 0
  87. args:
  88. warn: no
  89. - name: Install rpms
  90. command: rpm -Uvh ~"{{ rpm_loop }}"
  91. args:
  92. chdir: "{{ rpm_path }}"
  93. warn: no
  94. changed_when: true
  95. when: verify_result.rc != 0
  96. - name: Get the hostname
  97. command: hostname
  98. register: machine_name
  99. changed_when: true
  100. - name: Add control machine name
  101. lineinfile:
  102. path: "{{ slurm_confpth }}"
  103. regexp: "ControlMachine="
  104. line: "ControlMachine={{ machine_name.stdout }}"
  105. - name: Add slurm user name
  106. lineinfile:
  107. path: "{{ slurm_confpth }}"
  108. regexp: "SlurmUser="
  109. line: "SlurmUser={{ slurm_user }}"
  110. - name: Install firewalld
  111. package:
  112. name: firewalld
  113. state: present
  114. tags: firewalld
  115. - name: Start and enable firewalld
  116. service:
  117. name: firewalld
  118. state: started
  119. enabled: yes
  120. tags: firewalld
  121. - name: Firewall rule for slurm - tcp/udp ports
  122. firewalld:
  123. zone: public
  124. port: "{{ item }}"
  125. permanent: true
  126. state: enabled
  127. with_items:
  128. - "{{ tcp_port1 }}"
  129. - "{{ tcp_port2 }}"
  130. - "{{ tcp_port3 }}"
  131. - "{{ tcp_port4 }}"
  132. - "{{ udp_port3 }}"
  133. - "{{ udp_port1 }}"
  134. - "{{ udp_port2 }}"
  135. when: "'manager' in group_names"
  136. tags: firewalld
  137. - name: Get network address/subnet mask
  138. set_fact:
  139. network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('network/prefix') }}"
  140. - name: Firewall rule slurm - allow all incoming traffic on internal network
  141. firewalld:
  142. zone: public
  143. rich_rule: 'rule family="{{ family }}" source address="{{ network_address }}" accept'
  144. permanent: true
  145. state: enabled
  146. tags: firewalld
  147. - name: Reload firewalld
  148. command: firewall-cmd --reload
  149. changed_when: true
  150. tags: firewalld
  151. - name: Start mariadb
  152. systemd:
  153. name: mariadb
  154. state: restarted
  155. enabled: yes
  156. tags: install
  157. - name: Grant permissions for slurm db
  158. command: >-
  159. mysql -u root -e "GRANT ALL ON slurm_acct_db.* TO '{{ db_user }}'@'{{
  160. db_host }}' identified by '{{ hostvars['127.0.0.1']['db_password'] }}'with
  161. grant option;"
  162. tags: install
  163. changed_when: true
  164. - name: Create slurmdbd.conf file
  165. copy:
  166. src: slurmdbd.conf
  167. dest: "{{ slurmdbd_path }}"
  168. mode: "{{ slurmdbd_mode }}"
  169. owner: slurm
  170. tags: install
  171. - name: Add slurm user name
  172. lineinfile:
  173. path: "{{ slurmdbd_path }}"
  174. regexp: "SlurmUser="
  175. line: "SlurmUser={{ slurm_user }}"
  176. - name: Add db address
  177. lineinfile:
  178. path: "{{ slurmdbd_path }}"
  179. regexp: "DbdAddr="
  180. line: "DbdAddr={{ DbdAddr }}"
  181. - name: Add db host
  182. lineinfile:
  183. path: "{{ slurmdbd_path }}"
  184. regexp: "DbdHost="
  185. line: "DbdHost={{ DbdHost }}"
  186. - name: Add storage password
  187. lineinfile:
  188. path: "{{ slurmdbd_path }}"
  189. regexp: "StoragePass="
  190. line: "StoragePass={{ hostvars['127.0.0.1']['db_password'] }}"
  191. - name: Add storage user
  192. lineinfile:
  193. path: "{{ slurmdbd_path }}"
  194. regexp: "StorageUser="
  195. line: "StorageUser={{ slurm_user }}"
  196. - name: Add log file path
  197. lineinfile:
  198. path: "{{ slurmdbd_path }}"
  199. regexp: "LogFile="
  200. line: "LogFile={{ logfile }}"
  201. - name: Add pid file path
  202. lineinfile:
  203. path: "{{ slurmdbd_path }}"
  204. regexp: "PidFile="
  205. line: "PidFile={{ pidfile }}"
  206. - name: Save slurm conf file in buffer
  207. fetch:
  208. src: "{{ slurm_confpth }}"
  209. dest: "{{ buffer_path }}"
  210. flat: true