|
4 | 4 | path: "{{ sriov_udev_rule_path }}"
|
5 | 5 | block: |
|
6 | 6 | {% for device in sriov_devices %}
|
7 |
| - {% if device.on_boot_configuration_enabled | default(true) | bool %} |
| 7 | + {% if device.on_boot_configuration_enabled | default(true) | bool and device.numvfs_driver | default(sriov_numvfs_driver) == 'udev' %} |
8 | 8 | SUBSYSTEM=="net", ACTION=="add", KERNEL=="{{ device.name }}", RUN+="/usr/bin/sh -c 'echo {{ device.numvfs | default(sriov_numvfs) }} > /sys/class/net/{{ device.name }}/device/sriov_numvfs'"
|
9 | 9 | {% endif %}
|
10 | 10 | {% endfor %}
|
|
16 | 16 | become: true
|
17 | 17 | notify: "{{ sriov_restart_handler }}"
|
18 | 18 |
|
| 19 | +- name: Persist sriov_numvfs with systemd unit |
| 20 | + ansible.builtin.template: |
| 21 | + dest: "/etc/systemd/system/virtual-functions-{{ device.name }}.service" |
| 22 | + src: "virtual-function.service.j2" |
| 23 | + mode: "0644" |
| 24 | + owner: root |
| 25 | + group: root |
| 26 | + loop: "{{ sriov_devices }}" |
| 27 | + loop_control: |
| 28 | + loop_var: device |
| 29 | + become: true |
| 30 | + when: |
| 31 | + - device.numvfs_driver | default(sriov_numvfs_driver) == 'systemd' |
| 32 | + - device.on_boot_configuration_enabled | default(true) |
| 33 | + |
| 34 | +- name: Ensure systemd unit is removed if on boot configuration is disabled |
| 35 | + ansible.builtin.file: |
| 36 | + path: "/etc/systemd/system/virtual-functions-{{ device.name }}.service" |
| 37 | + state: absent |
| 38 | + loop: "{{ sriov_devices }}" |
| 39 | + loop_control: |
| 40 | + loop_var: device |
| 41 | + become: true |
| 42 | + when: |
| 43 | + - not device.on_boot_configuration_enabled | default(true) |
| 44 | + |
| 45 | +- name: Enable sriov_numvfs systemd unit |
| 46 | + ansible.builtin.systemd: |
| 47 | + name: "virtual-functions-{{ device.name }}.service" |
| 48 | + enabled: true |
| 49 | + daemon_reload: true |
| 50 | + loop: "{{ sriov_devices }}" |
| 51 | + loop_control: |
| 52 | + loop_var: device |
| 53 | + become: true |
| 54 | + notify: |
| 55 | + - "{{ sriov_restart_handler }}" |
| 56 | + when: |
| 57 | + - device.numvfs_driver | default(sriov_numvfs_driver) == 'systemd' |
| 58 | + - device.on_boot_configuration_enabled | default(true) |
| 59 | + |
19 | 60 | - name: Add iommu to kernel command line (Intel)
|
20 | 61 | ansible.builtin.include_role:
|
21 | 62 | name: stackhpc.linux.grubcmdline
|
|
0 commit comments