diff --git a/defaults/main.yml b/defaults/main.yml index 2b007353..5e52f986 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -506,6 +506,20 @@ nova_vendor_data_overrides: {} nova_api_metadata_uwsgi_ini_overrides: {} nova_api_os_compute_uwsgi_ini_overrides: {} +# Enabled vGPU Types - dict defining 'type' and 'address' (optional) of vGPU +# an address is only required when supporting more than one physical GPU on the host +# Example 1: +# nova_enabled_vgpu_types: +# - type: nvidia-35 +# +# Example 2: +# nova_enabled_vgpu_types: +# - type: nvidia-35 +# address: +# - type: nvidia-36 +# address: +nova_enabled_vgpu_types: {} + # PCI devices passthrough to nova # For SR-IOV please use: # nova_pci_passthrough_whitelist: '{ "physical_network": "", "devname": "" }' diff --git a/tasks/nova_vgpu_detect.yml b/tasks/nova_vgpu_detect.yml index c64166cf..5b547b69 100644 --- a/tasks/nova_vgpu_detect.yml +++ b/tasks/nova_vgpu_detect.yml @@ -24,7 +24,7 @@ - name: Register a fact for nova enabled_vgpu_types set_fact: - enabled_vgpu_types: "{{ mdev.stdout_lines | unique }}" + discovered_vgpu_types: "{{ mdev.stdout_lines | unique }}" when: - mdev.stdout_lines is defined - mdev.stdout_lines | length > 0 diff --git a/templates/nova.conf.j2 b/templates/nova.conf.j2 index 17e43997..e9e17678 100644 --- a/templates/nova.conf.j2 +++ b/templates/nova.conf.j2 @@ -293,9 +293,14 @@ tracks_instance_changes = {{ nova_scheduler_tracks_instance_changes }} [upgrade_levels] compute=auto -{% if enabled_vgpu_types is defined %} +{% if nova_enabled_vgpu_types | length > 0 or discovered_vgpu_types is defined %} [devices] -enabled_vgpu_types = {{ enabled_vgpu_types | join(',') }} +enabled_vgpu_types = {{ nova_enabled_vgpu_types | map(attribute='type') | list | default(discovered_vgpu_types, true) | unique | join(',') }} + +{% for record in nova_enabled_vgpu_types | selectattr('address', 'defined') | list %} +[vgpu_{{ record.type }}] +device_addresses = {{ record.address }} +{% endfor %} {% endif %} {% if nova_pci_passthrough_whitelist or nova_pci_alias %}