|
| 1 | +--- |
| 2 | +# Copyright 2024 Red Hat, Inc. |
| 3 | +# All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. You may obtain |
| 7 | +# a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | +# License for the specific language governing permissions and limitations |
| 15 | +# under the License. |
| 16 | + |
| 17 | + |
| 18 | +- name: Gather the list of EDPM computes |
| 19 | + hosts: "{{ cifmw_target_hook_host | default('localhost') }}" |
| 20 | + gather_facts: false |
| 21 | + tasks: |
| 22 | + - name: Fetch OSP BMO nodesets |
| 23 | + environment: |
| 24 | + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" |
| 25 | + PATH: "{{ cifmw_path }}" |
| 26 | + ansible.builtin.command: |
| 27 | + cmd: >- |
| 28 | + oc get OpenStackBaremetalSet -n "{{ namespace|default('openstack') }}" -o yaml |
| 29 | + register: _osp_bmo_nodsets_oc_out |
| 30 | + |
| 31 | + - name: Craft the BM hosts list |
| 32 | + ansible.builtin.set_fact: |
| 33 | + _bmo_provisioned_hosts: >- |
| 34 | + {% set hosts = [] -%} |
| 35 | + {% set nodesets = (_osp_bmo_nodsets_oc_out.stdout | from_yaml)['items'] | default([]) -%} |
| 36 | + {% for spec in nodesets | map(attribute='spec') -%} |
| 37 | + {% for host_key, host_val in spec.baremetalHosts.items() -%} |
| 38 | + {% set _ = hosts.append( |
| 39 | + { |
| 40 | + 'name': host_key, |
| 41 | + 'ip': host_val['ctlPlaneIP'] | ansible.utils.ipaddr('address'), |
| 42 | + 'user': spec.cloudUserName, |
| 43 | + 'group': host_key | split('-') | first + 's' |
| 44 | + }) -%} |
| 45 | + {% endfor -%} |
| 46 | + {% endfor -%} |
| 47 | + {{ hosts }} |
| 48 | +
|
| 49 | + - name: Add OSP BMO nodesets to Ansible |
| 50 | + ansible.builtin.add_host: |
| 51 | + name: "{{ item.name }}" |
| 52 | + groups: "{{ item.group }}" |
| 53 | + ansible_ssh_user: "{{ item.user }}" |
| 54 | + ansible_host: "{{ item.ip }}" |
| 55 | + ansible_ssh_private_key_file: "{{ ansible_user_dir }}/.ssh/id_cifw" |
| 56 | + ansible_ssh_extra_args: '-o StrictHostKeyChecking=no' |
| 57 | + loop: "{{ _bmo_provisioned_hosts }}" |
| 58 | + |
| 59 | + - name: Wait for the instance to boot |
| 60 | + delegate_to: "{{ item.name }}" |
| 61 | + ansible.builtin.wait_for_connection: |
| 62 | + sleep: 2 |
| 63 | + timeout: 600 |
| 64 | + loop: "{{ _bmo_provisioned_hosts }}" |
| 65 | + |
| 66 | +- name: Run the Nvidia phase 1 role |
| 67 | + hosts: edpms |
| 68 | + tasks: |
| 69 | + - name: Run phase1 |
| 70 | + ansible.builtin.import_role: |
| 71 | + name: edpm_nvidia_mdev_prepare |
| 72 | + # As a reminder, at the end of phase1, the compute will reboot |
| 73 | + tasks_from: phase1 |
0 commit comments