main.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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: Create a custom fact directory on each host
  16. file:
  17. path: "{{ custom_fact_dir }}"
  18. state: directory
  19. mode: "{{ custom_fact_dir_mode }}"
  20. - name: Install accelerator discovery script
  21. copy:
  22. src: inventory.fact
  23. dest: "{{ accelerator_discovery_script_dest }}"
  24. owner: root
  25. group: root
  26. mode: "{{ accelerator_discovery_script_mode }}"
  27. - name: Add epel-release repo
  28. package:
  29. name: epel-release
  30. state: present
  31. tags: install
  32. - name: Add elrepo GPG key
  33. rpm_key:
  34. state: present
  35. key: "{{ elrepo_gpg_key_url }}"
  36. register: elrepo_gpg_key
  37. until: elrepo_gpg_key is not failed
  38. retries: 20
  39. delay: 10
  40. tags: install
  41. - name: Add elrepo (nvidia kmod drivers)
  42. package:
  43. name: "{{ elrepo_rpm_url }}"
  44. state: present
  45. register: elrepo
  46. until: elrepo is not failed
  47. retries: 20
  48. delay: 10
  49. tags: install
  50. - name: Add docker community edition repository
  51. get_url:
  52. url: "{{ docker_repo_url }}"
  53. dest: "{{ docker_repo_dest }}"
  54. register: docker_repo
  55. until: docker_repo is not failed
  56. retries: 20
  57. delay: 10
  58. tags: install
  59. - name: Permanently Disable swap
  60. mount:
  61. name: "swap"
  62. fstype: swap
  63. state: absent
  64. - name: Disable selinux
  65. selinux:
  66. state: disabled
  67. tags: install
  68. - name: Install common packages
  69. package:
  70. name: "{{ common_packages }}"
  71. state: present
  72. tags: install
  73. - name: Versionlock docker
  74. command: "yum versionlock '{{ item }}'"
  75. args:
  76. warn: false
  77. with_items:
  78. - "{{ docker_packages }}"
  79. changed_when: true
  80. tags: install
  81. - name: Collect host facts (including acclerator information)
  82. setup: ~
  83. - name: Install infiniBand support
  84. package:
  85. name: "@Infiniband Support"
  86. state: present
  87. tags: install
  88. - name: Deploy time ntp/chrony
  89. include_tasks: ntp.yml
  90. tags: install
  91. - name: Install Nvidia drivers and software components
  92. include_tasks: nvidia.yml
  93. when: ansible_local.inventory.nvidia_gpu > 0
  94. tags: install
  95. - name: Install AMD GPU drivers and software components
  96. include_tasks: amd.yml
  97. when: ansible_local.inventory.amd_gpu > 0
  98. tags: install
  99. - name: Get the hostname
  100. command: hostname
  101. register: machine_hostname
  102. changed_when: true
  103. - name: Set facts for node hostname and ip
  104. set_fact:
  105. node_ip: "{{ inventory_hostname }}"
  106. node_hostname: "{{ machine_hostname.stdout }}"
  107. - name: Add host name in hosts file
  108. lineinfile:
  109. dest: "{{ hosts_file_dest }}"
  110. line: "{{ inventory_hostname }} {{ machine_hostname.stdout }}"
  111. state: present
  112. create: yes
  113. mode: "{{ hosts_file_mode }}"
  114. - name: Add compute hosts info in manager node hosts file
  115. lineinfile:
  116. dest: "{{ hosts_file_dest }}"
  117. line: "{{ hostvars[item].node_ip }} {{ hostvars[item].node_hostname }}"
  118. state: present
  119. create: yes
  120. mode: "{{ hosts_file_mode }}"
  121. with_items:
  122. - "{{ groups['compute'] }}"
  123. when: "'manager' in group_names"
  124. - name: Add manager hosts info in compute node hosts file
  125. lineinfile:
  126. dest: "{{ hosts_file_dest }}"
  127. line: "{{ hostvars[item].node_ip }} {{ hostvars[item].node_hostname }}"
  128. state: present
  129. create: yes
  130. mode: "{{ hosts_file_mode }}"
  131. with_items:
  132. - "{{ groups['manager'] }}"
  133. when: "'compute' in group_names"
  134. - name: Add login node info in /etc/hosts of manager node
  135. lineinfile:
  136. dest: "{{ hosts_file_dest }}"
  137. line: "{{ hostvars[item].node_ip }} {{ hostvars[item].node_hostname }}"
  138. state: present
  139. create: yes
  140. mode: "{{ hosts_file_mode }}"
  141. with_items:
  142. - "{{ groups['login_node'] }}"
  143. when:
  144. - '"manager" in group_names'
  145. - hostvars["127.0.0.1"]["login_node_required"]
  146. - name: Add manager info in /etc/hosts of login node
  147. lineinfile:
  148. dest: "{{ hosts_file_dest }}"
  149. line: "{{ hostvars[item].node_ip }} {{ hostvars[item].node_hostname }}"
  150. state: present
  151. create: yes
  152. mode: "{{ hosts_file_mode }}"
  153. with_items:
  154. - "{{ groups['manager'] }}"
  155. when:
  156. - '"login_node" in group_names'
  157. - hostvars["127.0.0.1"]["login_node_required"]
  158. - name: Add compute info in /etc/hosts of login node
  159. lineinfile:
  160. dest: "{{ hosts_file_dest }}"
  161. line: "{{ hostvars[item].node_ip }} {{ hostvars[item].node_hostname }}"
  162. state: present
  163. create: yes
  164. mode: "{{ hosts_file_mode }}"
  165. with_items:
  166. - "{{ groups['compute'] }}"
  167. when:
  168. - hostvars["127.0.0.1"]["login_node_required"]
  169. - '"login_node" in group_names'