|
| 1 | +--- |
| 2 | + |
| 3 | +# TODO: running on master node for now (fix to run on multiple nodes) |
| 4 | + |
| 5 | +- name: check VF resources and bind them to vfio-pci |
| 6 | + block: |
| 7 | + - name: Get number of VF's available for the "{{ core.data_iface }}" |
| 8 | + shell: ip link show "{{ core.data_iface }}"|grep -c vf |
| 9 | + register: vf_status |
| 10 | + changed_when: false |
| 11 | + |
| 12 | + - debug: |
| 13 | + var=vf_status.stdout |
| 14 | + |
| 15 | + - name: verify the required VF resourses available in "{{ core.data_iface }}" |
| 16 | + ansible.builtin.assert: |
| 17 | + that: |
| 18 | + - vf_status.stdout | int >= 2 |
| 19 | + |
| 20 | + - name: check if "{{ core.upf.pci_devices[0] }}" attached to vfio-pci |
| 21 | + shell: driverctl -v list-overrides |grep 'vfio-pci'|grep {{ core.upf.pci_devices[0] }}|wc -l |
| 22 | + register: vf_status |
| 23 | + changed_when: false |
| 24 | + |
| 25 | + - name: Attach "{{ core.upf.pci_devices[0] }}" to vfio-pci |
| 26 | + shell: driverctl set-override {{ core.upf.pci_devices[0] }} vfio-pci |
| 27 | + changed_when: false |
| 28 | + become: true |
| 29 | + when: vf_status.stdout | int != 1 |
| 30 | + |
| 31 | + - pause: |
| 32 | + seconds: 5 |
| 33 | + |
| 34 | + - name: check if "{{ core.upf.pci_devices[1] }}" attached to vfio-pci |
| 35 | + shell: driverctl -v list-overrides |grep 'vfio-pci'|grep {{ core.upf.pci_devices[1] }}|wc -l |
| 36 | + register: vf_status |
| 37 | + changed_when: false |
| 38 | + |
| 39 | + - name: Attach "{{ core.upf.pci_devices[1] }}" to vfio-pci |
| 40 | + shell: driverctl set-override {{ core.upf.pci_devices[1] }} vfio-pci |
| 41 | + changed_when: false |
| 42 | + become: true |
| 43 | + when: vf_status.stdout | int != 1 |
| 44 | + |
| 45 | + - pause: |
| 46 | + seconds: 5 |
| 47 | + |
| 48 | + when: inventory_hostname in groups['master_nodes'] and core.upf.enable_resources |
| 49 | + |
| 50 | +- name: deploy sriov plugins |
| 51 | + block: |
| 52 | + - name: copy sriov-device-plugin.yaml to /tmp/sriov-device-plugin.yaml |
| 53 | + template: |
| 54 | + src: roles/sriov/templates/sriov-device-plugin.yaml |
| 55 | + dest: "/tmp/sriov-device-plugin.yaml" |
| 56 | + |
| 57 | + - name: copy sriov-device-plugin-config.yaml to /tmp/sriov-device-plugin-config.yaml |
| 58 | + template: |
| 59 | + src: roles/sriov/templates/sriov-device-plugin-config.yaml |
| 60 | + dest: "/tmp/sriov-device-plugin-config.yaml" |
| 61 | + |
| 62 | + - name: update proper data interface name in /tmp/sriov-device-plugin-config.yaml |
| 63 | + shell: sed -i -e "s/PFDEV/{{ core.data_iface }}/g" /tmp/sriov-device-plugin-config.yaml |
| 64 | + |
| 65 | + - name: apply /tmp/sriov-device-plugin.yaml |
| 66 | + shell: kubectl apply -f /tmp/sriov-device-plugin.yaml |
| 67 | + |
| 68 | + - name: apply /tmp/sriov-device-plugin-config.yaml |
| 69 | + shell: kubectl apply -f /tmp/sriov-device-plugin-config.yaml |
| 70 | + |
| 71 | + - name: Get Sriov Pods Status |
| 72 | + shell: kubectl get pods -A |grep sriov |
| 73 | + register: pod_status |
| 74 | + changed_when: false |
| 75 | + |
| 76 | + - name: restart sriov Pod |
| 77 | + shell: | |
| 78 | + while IFS= read -r line; do |
| 79 | + name=$(echo "$line" | awk '{print $2}') |
| 80 | + status=$(echo "$line" | awk '{print $4}') |
| 81 | +
|
| 82 | + kubectl delete pod "$name" |
| 83 | + done <<< "{{ pod_status.stdout }}" |
| 84 | + args: |
| 85 | + executable: /bin/bash |
| 86 | + - pause: |
| 87 | + seconds: 10 |
| 88 | + when: inventory_hostname in groups['master_nodes'] and core.upf.enable_resources |
0 commit comments