main.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. # Copyright 2022 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. when: os_supported_leap not in compute_os
  51. - name: Install packages for slurm
  52. package:
  53. name: "{{ leap_slurm_packages }}"
  54. state: present
  55. tags: install
  56. when: os_supported_leap in compute_os
  57. - name: Install development tools
  58. package:
  59. name: "{{ dev_tools }}"
  60. state: present
  61. tags: install
  62. when: os_supported_leap not in compute_os
  63. - name: Get the hostname
  64. command: hostname
  65. register: machine_name
  66. changed_when: true
  67. - name: Add control machine name
  68. lineinfile:
  69. path: "{{ slurm_confpth }}"
  70. regexp: "ControlMachine="
  71. line: "ControlMachine={{ machine_name.stdout }}"
  72. - name: Add slurm user name
  73. lineinfile:
  74. path: "{{ slurm_confpth }}"
  75. regexp: "SlurmUser="
  76. line: "SlurmUser={{ slurm_user }}"
  77. - name: Install firewalld
  78. package:
  79. name: firewalld
  80. state: present
  81. tags: firewalld
  82. - name: Start and enable firewalld
  83. service:
  84. name: firewalld
  85. state: started
  86. enabled: yes
  87. tags: firewalld
  88. - name: Firewall rule for slurm - tcp/udp ports
  89. firewalld:
  90. zone: public
  91. port: "{{ item }}"
  92. permanent: true
  93. state: enabled
  94. with_items:
  95. - "{{ tcp_port1 }}"
  96. - "{{ tcp_port2 }}"
  97. - "{{ tcp_port3 }}"
  98. - "{{ tcp_port4 }}"
  99. - "{{ tcp_port5 }}"
  100. - "{{ udp_port3 }}"
  101. - "{{ udp_port1 }}"
  102. - "{{ udp_port2 }}"
  103. - "{{ udp_port4 }}"
  104. when: "'manager' in group_names"
  105. tags: firewalld
  106. - name: Get network address/subnet mask
  107. set_fact:
  108. network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('network/prefix') }}"
  109. when: not hostvars['127.0.0.1']['ansible_collection_used']
  110. - name: Get network address/subnet mask
  111. set_fact:
  112. network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ansible.utils.ipaddr('network/prefix') }}"
  113. when: hostvars['127.0.0.1']['ansible_collection_used']
  114. - name: Firewall rule slurm - allow all incoming traffic on internal network
  115. firewalld:
  116. zone: public
  117. rich_rule: 'rule family="{{ family }}" source address="{{ network_address }}" accept'
  118. permanent: true
  119. state: enabled
  120. tags: firewalld
  121. - name: Reload firewalld
  122. command: firewall-cmd --reload
  123. changed_when: true
  124. tags: firewalld
  125. - name: Start mariadb
  126. systemd:
  127. name: mariadb
  128. state: restarted
  129. enabled: yes
  130. tags: install
  131. - name: Grant permissions for slurm db
  132. command: >-
  133. mysql -u root -e "GRANT ALL ON slurm_acct_db.* TO '{{ db_user }}'@'{{
  134. db_host }}' identified by '{{ hostvars['127.0.0.1']['db_password'] }}'with
  135. grant option;"
  136. tags: install
  137. changed_when: true
  138. - name: Create slurmdbd.conf file
  139. copy:
  140. src: slurmdbd.conf
  141. dest: "{{ slurmdbd_path }}"
  142. mode: "{{ slurmdbd_mode }}"
  143. owner: slurm
  144. tags: install
  145. - name: Add slurm user name
  146. lineinfile:
  147. path: "{{ slurmdbd_path }}"
  148. regexp: "SlurmUser="
  149. line: "SlurmUser={{ slurm_user }}"
  150. - name: Add db address
  151. lineinfile:
  152. path: "{{ slurmdbd_path }}"
  153. regexp: "DbdAddr="
  154. line: "DbdAddr={{ dbd_addr }}"
  155. - name: Add db host
  156. lineinfile:
  157. path: "{{ slurmdbd_path }}"
  158. regexp: "DbdHost="
  159. line: "DbdHost={{ dbd_host }}"
  160. - name: Add storage password
  161. lineinfile:
  162. path: "{{ slurmdbd_path }}"
  163. regexp: "StoragePass="
  164. line: "StoragePass={{ hostvars['127.0.0.1']['db_password'] }}"
  165. - name: Add storage user
  166. lineinfile:
  167. path: "{{ slurmdbd_path }}"
  168. regexp: "StorageUser="
  169. line: "StorageUser={{ slurm_user }}"
  170. - name: Add log file path
  171. lineinfile:
  172. path: "{{ slurmdbd_path }}"
  173. regexp: "LogFile="
  174. line: "LogFile={{ logfile }}"
  175. - name: Add pid file path
  176. lineinfile:
  177. path: "{{ slurmdbd_path }}"
  178. regexp: "PidFile="
  179. line: "PidFile={{ pidfile }}"
  180. - name: Save slurm conf file in buffer
  181. fetch:
  182. src: "{{ slurm_confpth }}"
  183. dest: "{{ buffer_path }}"
  184. flat: true