main.yml 3.4 KB

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