main.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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: Collect host facts (including acclerator information)
  57. setup: ~
  58. - name: Install infiniBand support
  59. package:
  60. name: "@Infiniband Support"
  61. state: present
  62. tags: install
  63. - name: Deploy time ntp/chrony
  64. include_tasks: ntp.yml
  65. tags: install
  66. - name: Install Nvidia drivers and software components
  67. include_tasks: nvidia.yml
  68. when: ansible_local.inventory.nvidia_gpu > 0
  69. tags: install
  70. - name: Install AMD GPU drivers and software components
  71. include_tasks: amd.yml
  72. when: ansible_local.inventory.amd_gpu > 0
  73. tags: install
  74. - name: Get the hostname
  75. command: hostname
  76. register: machine_hostname
  77. changed_when: true
  78. - name: Set facts for node hostname and ip
  79. set_fact:
  80. node_ip: "{{ inventory_hostname }}"
  81. node_hostname: "{{ machine_hostname.stdout }}"
  82. - name: Add host name in hosts file
  83. lineinfile:
  84. dest: "{{ hosts_file_dest }}"
  85. line: "{{ inventory_hostname }} {{ machine_hostname.stdout }}"
  86. state: present
  87. create: yes
  88. mode: "{{ hosts_file_mode }}"
  89. - name: Add compute hosts info in manager node hosts file
  90. lineinfile:
  91. dest: "{{ hosts_file_dest }}"
  92. line: "{{ hostvars[item].node_ip }} {{ hostvars[item].node_hostname }}"
  93. state: present
  94. create: yes
  95. mode: "{{ hosts_file_mode }}"
  96. with_items:
  97. - "{{ groups['compute'] }}"
  98. when: "'manager' in group_names"
  99. - name: Add manager hosts info in compute node hosts file
  100. lineinfile:
  101. dest: "{{ hosts_file_dest }}"
  102. line: "{{ hostvars[item].node_ip }} {{ hostvars[item].node_hostname }}"
  103. state: present
  104. create: yes
  105. mode: "{{ hosts_file_mode }}"
  106. with_items:
  107. - "{{ groups['manager'] }}"
  108. when: "'compute' in group_names"