main.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. tags: install
  37. - name: Add elrepo (nvidia kmod drivers)
  38. package:
  39. name: "{{ elrepo_rpm_url }}"
  40. state: present
  41. tags: install
  42. - name: Add docker community edition repository
  43. get_url:
  44. url: "{{ docker_repo_url }}"
  45. dest: "{{ docker_repo_dest }}"
  46. tags: install
  47. - name: Permanently Disable swap
  48. mount:
  49. name: "swap"
  50. fstype: swap
  51. state: absent
  52. - name: Disable selinux
  53. selinux:
  54. state: disabled
  55. tags: install
  56. - name: Install common packages
  57. package:
  58. name: "{{ common_packages }}"
  59. state: present
  60. tags: install
  61. - name: Versionlock docker
  62. command: "yum versionlock '{{ item }}'"
  63. args:
  64. warn: false
  65. with_items:
  66. - "{{ docker_packages }}"
  67. changed_when: true
  68. tags: install
  69. - name: Collect host facts (including acclerator information)
  70. setup: ~
  71. - name: Install infiniBand support
  72. package:
  73. name: "@Infiniband Support"
  74. state: present
  75. tags: install
  76. - name: Deploy time ntp/chrony
  77. include_tasks: ntp.yml
  78. tags: install
  79. - name: Install Nvidia drivers and software components
  80. include_tasks: nvidia.yml
  81. when: ansible_local.inventory.nvidia_gpu > 0
  82. tags: install
  83. - name: Install AMD GPU drivers and software components
  84. include_tasks: amd.yml
  85. when: ansible_local.inventory.amd_gpu > 0
  86. tags: install
  87. - name: Get the hostname
  88. command: hostname
  89. register: machine_hostname
  90. changed_when: true
  91. - name: Set facts for node hostname and ip
  92. set_fact:
  93. node_ip: "{{ inventory_hostname }}"
  94. node_hostname: "{{ machine_hostname.stdout }}"
  95. - name: Add host name in hosts file
  96. lineinfile:
  97. dest: "{{ hosts_file_dest }}"
  98. line: "{{ inventory_hostname }} {{ machine_hostname.stdout }}"
  99. state: present
  100. create: yes
  101. mode: "{{ hosts_file_mode }}"
  102. - name: Add compute hosts info in manager node hosts file
  103. lineinfile:
  104. dest: "{{ hosts_file_dest }}"
  105. line: "{{ hostvars[item].node_ip }} {{ hostvars[item].node_hostname }}"
  106. state: present
  107. create: yes
  108. mode: "{{ hosts_file_mode }}"
  109. with_items:
  110. - "{{ groups['compute'] }}"
  111. when: "'manager' in group_names"
  112. - name: Add manager hosts info in compute node hosts file
  113. lineinfile:
  114. dest: "{{ hosts_file_dest }}"
  115. line: "{{ hostvars[item].node_ip }} {{ hostvars[item].node_hostname }}"
  116. state: present
  117. create: yes
  118. mode: "{{ hosts_file_mode }}"
  119. with_items:
  120. - "{{ groups['manager'] }}"
  121. when: "'compute' in group_names"