main.yml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. - "{{ udp_port3 }}"
  132. - "{{ udp_port1 }}"
  133. - "{{ udp_port2 }}"
  134. when: "'manager' in group_names"
  135. tags: firewalld
  136. - name: Get network address/subnet mask
  137. set_fact:
  138. network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('network/prefix') }}"
  139. - name: Firewall rule slurm - allow all incoming traffic on internal network
  140. firewalld:
  141. zone: public
  142. rich_rule: 'rule family="{{ family }}" source address="{{ network_address }}" accept'
  143. permanent: true
  144. state: enabled
  145. tags: firewalld
  146. - name: Reload firewalld
  147. command: firewall-cmd --reload
  148. changed_when: true
  149. tags: firewalld
  150. - name: Start mariadb
  151. systemd:
  152. name: mariadb
  153. state: restarted
  154. enabled: yes
  155. tags: install
  156. - name: Grant permissions for slurm db
  157. command: >-
  158. mysql -u root -e "GRANT ALL ON slurm_acct_db.* TO '{{ db_user }}'@'{{
  159. db_host }}' identified by '{{ hostvars['127.0.0.1']['db_password'] }}'with
  160. grant option;"
  161. tags: install
  162. changed_when: true
  163. - name: Create slurmdbd.conf file
  164. copy:
  165. src: slurmdbd.conf
  166. dest: "{{ slurmdbd_path }}"
  167. mode: "{{ slurmdbd_mode }}"
  168. owner: slurm
  169. tags: install
  170. - name: Add slurm user name
  171. lineinfile:
  172. path: "{{ slurmdbd_path }}"
  173. regexp: "SlurmUser="
  174. line: "SlurmUser={{ slurm_user }}"
  175. - name: Add db address
  176. lineinfile:
  177. path: "{{ slurmdbd_path }}"
  178. regexp: "DbdAddr="
  179. line: "DbdAddr={{ DbdAddr }}"
  180. - name: Add db host
  181. lineinfile:
  182. path: "{{ slurmdbd_path }}"
  183. regexp: "DbdHost="
  184. line: "DbdHost={{ DbdHost }}"
  185. - name: Add storage password
  186. lineinfile:
  187. path: "{{ slurmdbd_path }}"
  188. regexp: "StoragePass="
  189. line: "StoragePass={{ hostvars['127.0.0.1']['db_password'] }}"
  190. - name: Add storage user
  191. lineinfile:
  192. path: "{{ slurmdbd_path }}"
  193. regexp: "StorageUser="
  194. line: "StorageUser={{ slurm_user }}"
  195. - name: Add log file path
  196. lineinfile:
  197. path: "{{ slurmdbd_path }}"
  198. regexp: "LogFile="
  199. line: "LogFile={{ logfile }}"
  200. - name: Add pid file path
  201. lineinfile:
  202. path: "{{ slurmdbd_path }}"
  203. regexp: "PidFile="
  204. line: "PidFile={{ pidfile }}"
  205. - name: Save slurm conf file in buffer
  206. fetch:
  207. src: "{{ slurm_confpth }}"
  208. dest: "{{ buffer_path }}"
  209. flat: true