diff --git a/Manual.org b/Manual.org index d1b71fc..01b74d6 100644 --- a/Manual.org +++ b/Manual.org @@ -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) diff --git a/library/hardware_facts.py b/library/hardware_facts.py index e1a7788..1fcfc49 100755 --- a/library/hardware_facts.py +++ b/library/hardware_facts.py @@ -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) diff --git a/roles/collect-facts/tasks/main.yml b/roles/collect-facts/tasks/main.yml index 085e2f4..99497bd 100644 --- a/roles/collect-facts/tasks/main.yml +++ b/roles/collect-facts/tasks/main.yml @@ -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