main.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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: Install packages for slurm
  16. package:
  17. name: "{{ item }}"
  18. state: present
  19. with_items:
  20. - "{{ slurm_packages }}"
  21. tags: install
  22. - name: Install development tools
  23. package:
  24. name: "{{ item }}"
  25. enablerepo: PowerTools
  26. state: present
  27. with_items:
  28. - "{{ dev_tools }}"
  29. tags: install
  30. - name: Create temporary download folder for slurm
  31. file:
  32. path: "{{ tmp_path }}"
  33. owner: slurm
  34. group: slurm
  35. mode: "{{ tmp_mode }}"
  36. state: directory
  37. - name: Download slurm source
  38. get_url:
  39. url: "{{ slurm_url }}"
  40. dest: "{{ tmp_path }}"
  41. checksum: "{{ slurm_md5 }}"
  42. validate_certs: no
  43. tags: install
  44. - name: Build slurm rpms
  45. command: rpmbuild -ta "{{ rpmbuild_path }}"
  46. changed_when: false
  47. args:
  48. warn: no
  49. - name: Verify package md5
  50. command: rpm -qa
  51. ignore_errors: true
  52. register: verify_result
  53. changed_when: no
  54. failed_when: no
  55. args:
  56. warn: no
  57. - name: Install rpms
  58. command: rpm -Uvh ~"{{ rpm_loop }}"
  59. args:
  60. chdir: "{{ rpm_path }}"
  61. warn: no
  62. when: verify_result.rc != 0
  63. - name: Add control machine name
  64. lineinfile:
  65. path: "{{ slurm_confpth }}"
  66. regexp: "ControlMachine="
  67. line: "ControlMachine={{ group_names[0] }}"
  68. - name: Add slurm user name
  69. lineinfile:
  70. path: "{{ slurmdbd_path }}"
  71. regexp: "SlurmUser="
  72. line: "SlurmUser={{ slurm_user }}"
  73. - name: Firewall rule for slurm - tcp/ip,udp
  74. firewalld:
  75. zone: internal
  76. port: "{{ item }}"
  77. permanent: true
  78. state: enabled
  79. with_items:
  80. - "{{ tcp_port1 }}"
  81. - "{{ tcp_port2 }}"
  82. - "{{ tcp_port3 }}"
  83. - "{{ tcp_port4 }}"
  84. - "{{ udp_port1 }}"
  85. - "{{ udp_port2 }}"
  86. tags: install
  87. - name: Get network address/subnet mask through ipaddr
  88. set_fact:
  89. network_address: "{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) | ipaddr('network/prefix') }}"
  90. - name: Firewall rule slurm - allow all incoming traffic on internal network
  91. firewalld:
  92. zone: internal
  93. rich_rule: 'rule family="{{ family }}" source address="{{ network_address }}" accept'
  94. permanent: true
  95. state: enabled
  96. tags: install
  97. - name: Firewall reload
  98. systemd:
  99. name: firewalld
  100. state: reloaded
  101. tags: install
  102. - name: Start mariadb
  103. service:
  104. name: mariadb
  105. state: restarted
  106. enabled: yes
  107. tags: install
  108. - name: Grant permissions for slurm db
  109. command: mysql -u root -e "GRANT ALL ON slurm_acct_db.* TO 'slurm'@'localhost' identified by 'password' with grant option;"
  110. tags: install
  111. changed_when: true
  112. - name: Create slurmdbd.conf file
  113. copy:
  114. src: slurmdbd.conf
  115. dest: "{{ slurmdbd_path }}"
  116. mode: "{{ slurmdbd_mode }}"
  117. tags: install
  118. - name: Add slurm user name
  119. lineinfile:
  120. path: "{{ slurmdbd_path }}"
  121. regexp: "SlurmUser="
  122. line: "SlurmUser={{ slurm_user }}"
  123. - name: Add db address
  124. lineinfile:
  125. path: "{{ slurmdbd_path }}"
  126. regexp: "DbdAddr="
  127. line: "DbdAddr={{ DbdAddr }}"
  128. - name: Add db host
  129. lineinfile:
  130. path: "{{ slurmdbd_path }}"
  131. regexp: "DbdHost="
  132. line: "DbdHost={{ DbdHost }}"
  133. - name: Add log file path
  134. lineinfile:
  135. path: "{{ slurmdbd_path }}"
  136. regexp: "LogFile="
  137. line: "LogFile={{ logfile }}"
  138. - name: Add pid file path
  139. lineinfile:
  140. path: "{{ slurmdbd_path }}"
  141. regexp: "PidFile="
  142. line: "PidFile={{ pidfile }}"
  143. - name: Populate accounting database
  144. command: slurmdbd
  145. tags: install
  146. changed_when: true
  147. - name: Save slurm conf file in buffer
  148. fetch:
  149. src: "{{ slurm_confpth }}"
  150. dest: "{{ buffer_path }}"
  151. flat: true