main.yml 4.6 KB

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