main.yml 3.7 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 epel repository
  16. package:
  17. name: epel-release
  18. state: present
  19. tags: install
  20. - name: Munge installation
  21. package:
  22. name: munge-devel
  23. enablerepo: PowerTools
  24. state: present
  25. - name: Install packages for slurm
  26. package:
  27. name: "{{ item }}"
  28. state: present
  29. with_items:
  30. - "{{ common_packages }}"
  31. tags: install
  32. - name: Create munge key
  33. command: "{{ munge_cmd }}"
  34. changed_when: true
  35. - name: Copy munge key
  36. copy:
  37. src: munge.key
  38. dest: "{{ munge_dest }}"
  39. owner: munge
  40. group: munge
  41. mode: "{{ munge_mode }}"
  42. tags: install
  43. - name: Slurm configuration - slurm.conf
  44. copy:
  45. src: slurm.conf
  46. dest: "{{ slurm_dest }}"
  47. mode: "{{ slurm_mode }}"
  48. tags: install
  49. - name: Add cluster name
  50. lineinfile:
  51. path: "{{ slurm_confpth }}"
  52. regexp: "ClusterName="
  53. line: "ClusterName={{ cluster_name }}"
  54. - name: Add slurm user name
  55. lineinfile:
  56. path: "{{ slurm_confpth }}"
  57. regexp: "SlurmUser="
  58. line: "SlurmUser={{ slurm_user }}"
  59. - name: Add slurmctld port no
  60. lineinfile:
  61. path: "{{ slurm_confpth }}"
  62. regexp: "SlurmctldPort="
  63. line: "SlurmctldPort={{ slurmctld_port }}"
  64. - name: Add slurmd port no
  65. lineinfile:
  66. path: "{{ slurm_confpth }}"
  67. regexp: "SlurmdPort="
  68. line: "SlurmdPort={{ slurmd_port }}"
  69. - name: Add spool path
  70. lineinfile:
  71. path: "{{ slurm_confpth }}"
  72. regexp: "SlurmdSpoolDir="
  73. line: "SlurmdSpoolDir={{ spool_pth }}"
  74. - name: Add slurmctld pid file path
  75. lineinfile:
  76. path: "{{ slurm_confpth }}"
  77. regexp: "SlurmctldPidFile="
  78. line: "SlurmctldPidFile={{ slurmctld_pid }}"
  79. - name: Add slurmd pid file path
  80. lineinfile:
  81. path: "{{ slurm_confpth }}"
  82. regexp: "SlurmdPidFile="
  83. line: "SlurmdPidFile={{ slurmd_pid }}"
  84. - name: Add slurmctld log file path
  85. lineinfile:
  86. path: "{{ slurm_confpth }}"
  87. regexp: "SlurmctldLogFile="
  88. line: "SlurmctldLogFile={{ slurmctld_log }}"
  89. - name: Add slurmd log file path
  90. lineinfile:
  91. path: "{{ slurm_confpth }}"
  92. regexp: "SlurmdLogFile="
  93. line: "SlurmdLogFile={{ slurmd_log }}"
  94. - name: Create slurm group
  95. group:
  96. name: slurm
  97. state: present
  98. tags: install
  99. - name: Add the user 'slurm' with uid 6001 and a primary group of 'slurm'
  100. user:
  101. name: slurm
  102. comment: Slurm User Account
  103. uid: "{{ slurm_uid }}"
  104. group: slurm
  105. tags: install
  106. - name: Create slurm log directory
  107. file:
  108. path: "{{ slurm_logpth }}"
  109. state: directory
  110. owner: slurm
  111. group: slurm
  112. mode: "{{ gen_mode }}"
  113. recurse: yes
  114. tags: install
  115. - name: Give slurm user permission to spool
  116. file:
  117. path: "{{ spool_pth }}"
  118. owner: slurm
  119. group: slurm
  120. state: directory
  121. mode: "{{ gen_mode }}"
  122. recurse: yes
  123. - name: Give slurm user permission to slurmctld
  124. file:
  125. path: "{{ slurmctld_pid }}"
  126. owner: slurm
  127. group: slurm
  128. mode: "{{ gen_mode }}"
  129. state: touch
  130. - name: Give slurm user permission to slurmd
  131. file:
  132. path: "{{ slurmd_pid }}"
  133. owner: slurm
  134. group: slurm
  135. mode: "{{ gen_mode }}"
  136. state: touch
  137. - name: Start munge service
  138. service:
  139. name: munge
  140. state: restarted
  141. enabled: yes
  142. tags: install