main.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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: 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. - "{{ udp_port3 }}"
  92. - "{{ udp_port1 }}"
  93. - "{{ udp_port2 }}"
  94. when: "'manager' in group_names"
  95. tags: firewalld
  96. - name: Get network address/subnet mask
  97. set_fact:
  98. network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('network/prefix') }}"
  99. - name: Firewall rule slurm - allow all incoming traffic on internal network
  100. firewalld:
  101. zone: public
  102. rich_rule: 'rule family="{{ family }}" source address="{{ network_address }}" accept'
  103. permanent: true
  104. state: enabled
  105. tags: firewalld
  106. - name: Reload firewalld
  107. command: firewall-cmd --reload
  108. changed_when: true
  109. tags: firewalld
  110. - name: Start mariadb
  111. systemd:
  112. name: mariadb
  113. state: restarted
  114. enabled: yes
  115. tags: install
  116. - name: Grant permissions for slurm db
  117. command: >-
  118. mysql -u root -e "GRANT ALL ON slurm_acct_db.* TO '{{ db_user }}'@'{{
  119. db_host }}' identified by '{{ hostvars['127.0.0.1']['db_password'] }}'with
  120. grant option;"
  121. tags: install
  122. changed_when: true
  123. - name: Create slurmdbd.conf file
  124. copy:
  125. src: slurmdbd.conf
  126. dest: "{{ slurmdbd_path }}"
  127. mode: "{{ slurmdbd_mode }}"
  128. owner: slurm
  129. tags: install
  130. - name: Add slurm user name
  131. lineinfile:
  132. path: "{{ slurmdbd_path }}"
  133. regexp: "SlurmUser="
  134. line: "SlurmUser={{ slurm_user }}"
  135. - name: Add db address
  136. lineinfile:
  137. path: "{{ slurmdbd_path }}"
  138. regexp: "DbdAddr="
  139. line: "DbdAddr={{ dbd_addr }}"
  140. - name: Add db host
  141. lineinfile:
  142. path: "{{ slurmdbd_path }}"
  143. regexp: "DbdHost="
  144. line: "DbdHost={{ dbd_host }}"
  145. - name: Add storage password
  146. lineinfile:
  147. path: "{{ slurmdbd_path }}"
  148. regexp: "StoragePass="
  149. line: "StoragePass={{ hostvars['127.0.0.1']['db_password'] }}"
  150. - name: Add storage user
  151. lineinfile:
  152. path: "{{ slurmdbd_path }}"
  153. regexp: "StorageUser="
  154. line: "StorageUser={{ slurm_user }}"
  155. - name: Add log file path
  156. lineinfile:
  157. path: "{{ slurmdbd_path }}"
  158. regexp: "LogFile="
  159. line: "LogFile={{ logfile }}"
  160. - name: Add pid file path
  161. lineinfile:
  162. path: "{{ slurmdbd_path }}"
  163. regexp: "PidFile="
  164. line: "PidFile={{ pidfile }}"
  165. - name: Save slurm conf file in buffer
  166. fetch:
  167. src: "{{ slurm_confpth }}"
  168. dest: "{{ buffer_path }}"
  169. flat: true