main.yml 3.9 KB

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