extend hardware_facts.py with bool variables for detected graphic card manufacturers

This commit is contained in:
Alexander Grothe 2017-11-22 09:24:33 +01:00
parent 6ae45c65ce
commit 0cd621b6a6
3 changed files with 24 additions and 26 deletions

View File

@ -558,18 +558,6 @@ APT::Install-Suggests "0";
gpus: True
acpi_power_modes: True
- name: set variable nvidia_detected
set_fact:
nvidia_detected: '{{ gpus | selectattr("VendorName", "equalto", "nvidia") | list | bool }}'
- name: set variable intel_detected
set_fact:
intel_detected: '{{ gpus | selectattr("VendorName", "equalto", "intel") | list | bool }}'
- name: set variable amd_detected
set_fact:
amd_detected: '{{ gpus | selectattr("VendorName", "equalto", "amd") | list | bool }}'
- debug:
var: '{{ item }}'
verbosity: 1
@ -582,6 +570,7 @@ APT::Install-Suggests "0";
- nvidia_detected
- intel_detected
- amd_detected
- virtualbox_detected
#+END_SRC
** vdr
*** tasks
@ -3840,6 +3829,10 @@ def main():
pci_devices = []
modules = []
gpus = []
nvidia_detected = False
intel_detected = False
amd_detected = False
virtualbox_detected = False
acpi_power_modes = []
if collect_usb:
@ -3854,12 +3847,18 @@ def main():
if collect_gpus:
gpus = format_gpu_device_list(get_pci_devices())
nvidia_detected = any((True for gpu in gpus.items() if gpu['VendorName'] == 'nvidia'))
intel_detected = any((True for gpu in gpus.items() if gpu['VendorName'] == 'intel'))
amd_detected = any((True for gpu in gpus.items() if gpu['VendorName'] == 'amd'))
virtualbox_detected = any((True for gpu in gpus.items() if gpu['VendorName'] == 'virtualbox'))
if collect_acpi_power_modes:
acpi_power_modes = list_acpi_power_modes()
data = {'usb': usb_devices, 'pci': pci_devices, 'modules': modules, 'gpus': gpus,
'acpi_power_modes': acpi_power_modes}
'acpi_power_modes': acpi_power_modes, 'nvidia_detected': nvidia_detected,
'intel_detected': intel_detected, 'amd_detected': amd_detected,
'virtualbox_detected': virtualbox_detected}
module.exit_json(changed=False, ansible_facts=data, msg=data)

View File

@ -134,6 +134,10 @@ def main():
pci_devices = []
modules = []
gpus = []
nvidia_detected = False
intel_detected = False
amd_detected = False
virtualbox_detected = False
acpi_power_modes = []
if collect_usb:
@ -148,12 +152,18 @@ def main():
if collect_gpus:
gpus = format_gpu_device_list(get_pci_devices())
nvidia_detected = any((True for gpu in gpus.items() if gpu['VendorName'] == 'nvidia'))
intel_detected = any((True for gpu in gpus.items() if gpu['VendorName'] == 'intel'))
amd_detected = any((True for gpu in gpus.items() if gpu['VendorName'] == 'amd'))
virtualbox_detected = any((True for gpu in gpus.items() if gpu['VendorName'] == 'virtualbox'))
if collect_acpi_power_modes:
acpi_power_modes = list_acpi_power_modes()
data = {'usb': usb_devices, 'pci': pci_devices, 'modules': modules, 'gpus': gpus,
'acpi_power_modes': acpi_power_modes}
'acpi_power_modes': acpi_power_modes, 'nvidia_detected': nvidia_detected,
'intel_detected': intel_detected, 'amd_detected': amd_detected,
'virtualbox_detected': virtualbox_detected}
module.exit_json(changed=False, ansible_facts=data, msg=data)

View File

@ -6,18 +6,6 @@
gpus: True
acpi_power_modes: True
- name: set variable nvidia_detected
set_fact:
nvidia_detected: '{{ gpus | selectattr("VendorName", "equalto", "nvidia") | list | bool }}'
- name: set variable intel_detected
set_fact:
intel_detected: '{{ gpus | selectattr("VendorName", "equalto", "intel") | list | bool }}'
- name: set variable amd_detected
set_fact:
amd_detected: '{{ gpus | selectattr("VendorName", "equalto", "amd") | list | bool }}'
- debug:
var: '{{ item }}'
verbosity: 1
@ -30,3 +18,4 @@
- nvidia_detected
- intel_detected
- amd_detected
- virtualbox_detected