main.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: Get hostname
  16. command: hostname -s
  17. register: host_name
  18. changed_when: true
  19. - name: Add host name in file
  20. replace:
  21. dest: "{{ hostname_dest }}"
  22. regexp: localhost.localdomain
  23. replace: "{{ host_name.stdout }}"
  24. backup: yes
  25. mode: "{{ common_mode ]}"
  26. - name: Add host name in hosts file
  27. lineinfile:
  28. dest: "{{ hosts_dest }}"
  29. line: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }} {{ host_name.stdout }}"
  30. state: present
  31. create: yes
  32. mode: "{{ common_mode }}"
  33. - name: Install epel repository
  34. package:
  35. name: epel-release
  36. state: present
  37. tags: install
  38. - name: Install packages for slurm
  39. package:
  40. name: "{{ item }}"
  41. state: present
  42. with_items:
  43. - "{{ common_packages }}"
  44. tags: install
  45. - name: Create munge key
  46. command: "{{ munge_cmd }}"
  47. changed_when: true
  48. - name: Copy munge key
  49. copy:
  50. src: munge.key
  51. dest: "{{ munge_dest }}"
  52. owner: munge
  53. group: munge
  54. mode: "{{ munge_mode }}"
  55. tags: install
  56. - name: Slurm configuration - slurm.conf
  57. copy:
  58. src: slurm.conf
  59. dest: "{{ slurm_dest }}"
  60. mode: "{{ slurm_mode }}"
  61. tags: install
  62. - name: Add cluster name
  63. lineinfile:
  64. path: "{{ slurm_confpth }}"
  65. regexp: "ClusterName="
  66. line: "ClusterName={{ cluster_name }}"
  67. - name: Add slurm user name
  68. lineinfile:
  69. path: "{{ slurm_confpth }}"
  70. regexp: "SlurmUser="
  71. line: "SlurmUser={{ slurm_user }}"
  72. - name: Add slurmctld port no
  73. lineinfile:
  74. path: "{{ slurm_confpth }}"
  75. regexp: "SlurmctldPort="
  76. line: "SlurmctldPort={{ slurmctld_port }}"
  77. - name: Add slurmd port no
  78. lineinfile:
  79. path: "{{ slurm_confpth }}"
  80. regexp: "SlurmdPort="
  81. line: "SlurmdPort={{ slurmd_port }}"
  82. - name: Add spool path
  83. lineinfile:
  84. path: "{{ slurm_confpth }}"
  85. regexp: "SlurmdSpoolDir="
  86. line: "SlurmdSpoolDir={{ spool_pth }}"
  87. - name: Add slurmctld pid file path
  88. lineinfile:
  89. path: "{{ slurm_confpth }}"
  90. regexp: "SlurmctldPidFile="
  91. line: "SlurmctldPidFile={{ slurmctld_pid }}"
  92. - name: Add slurmd pid file path
  93. lineinfile:
  94. path: "{{ slurm_confpth }}"
  95. regexp: "SlurmdPidFile="
  96. line: "SlurmdPidFile={{ slurmd_pid }}"
  97. - name: Add slurmctld log file path
  98. lineinfile:
  99. path: "{{ slurm_confpth }}"
  100. regexp: "SlurmctldLogFile="
  101. line: "SlurmctldLogFile={{ slurmctld_log }}"
  102. - name: Add slurmd log file path
  103. lineinfile:
  104. path: "{{ slurm_confpth }}"
  105. regexp: "SlurmdLogFile="
  106. line: "SlurmdLogFile={{ slurmd_log }}"
  107. - name: Add accounting storage port no
  108. lineinfile:
  109. path: "{{ slurm_confpth }}"
  110. regexp: "AccountingStoragePort="
  111. line: "AccountingStoragePort={{ acct_port }}"
  112. - name: Create slurm group
  113. group:
  114. name: slurm
  115. state: present
  116. tags: install
  117. - name: Add the user 'slurm' with uid 6001 and a primary group of 'slurm'
  118. user:
  119. name: slurm
  120. comment: Slurm User Account
  121. uid: "{{ slurm_uid }}"
  122. group: slurm
  123. tags: install
  124. - name: Create slurm log directory
  125. file:
  126. path: "{{ slurm_logpth }}"
  127. state: directory
  128. owner: slurm
  129. group: slurm
  130. mode: "{{ gen_mode }}"
  131. recurse: yes
  132. tags: install
  133. - name: Give slurm user permission to spool
  134. file:
  135. path: "{{ spool_pth }}"
  136. owner: slurm
  137. group: slurm
  138. state: directory
  139. mode: "{{ gen_mode }}"
  140. recurse: yes
  141. - name: Create slurm pid directory
  142. file:
  143. path: "{{ slurm_pidpth }}"
  144. state: directory
  145. owner: slurm
  146. group: slurm
  147. mode: "{{ gen_mode }}"
  148. recurse: yes
  149. tags: install
  150. - name: Give slurm user permission to slurmctld
  151. file:
  152. path: "{{ slurmctld_pid }}"
  153. owner: slurm
  154. group: slurm
  155. mode: "{{ gen_mode }}"
  156. state: touch
  157. - name: Give slurm user permission to slurmd
  158. file:
  159. path: "{{ slurmd_pid }}"
  160. owner: slurm
  161. group: slurm
  162. mode: "{{ gen_mode }}"
  163. state: touch
  164. - name: Start munge service
  165. systemd:
  166. name: munge
  167. state: restarted
  168. enabled: yes
  169. tags: install
  170. ignore_errors: yes
  171. - name: Disable selinux
  172. selinux:
  173. state: disabled
  174. tags: install
  175. - name: Deploy time ntp/chrony
  176. include_tasks: ntp.yml