Debian Codegraph @

ansible_collections/community/vmware/tests/integration/targets/vmware_host_passthrough/tasks/pre.yml

raw
1 # Test code for the vmware_host_passthrough module.
2 # Copyright: (c) 2021, sky-joker <[email protected]>
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 - name: Gather PCI devices info from ESXi host
6 community.vmware.vmware_host_facts:
7 hostname: "{{ vcenter_hostname }}"
8 username: "{{ vcenter_username }}"
9 password: "{{ vcenter_password }}"
10 validate_certs: false
11 esxi_hostname: "{{ esxi1 }}"
12 schema: vsphere
13 properties:
14 - config.pciPassthruInfo
15 - hardware.pciDevice
16 register: pci_devices_result
17
18 - name: Set the device_ids variable that includes to be enabled passthrough devices only
19 ansible.builtin.set_fact:
20 device_ids: >-
21 {{ device_ids | default([])
22 + [item]
23 }}
24 loop: "{{ pci_devices_result.ansible_facts.config.pciPassthruInfo }}"
25 when:
26 - item.passthruCapable is sameas true
27
28 - name: The block task is collected PCI devices that can be enabled passthrough if the device_ids variable is defined
29 when:
30 - device_ids is defined
31 block:
32 - name: Set the list_of_pci_devices_that_can_be_enabled_passthrough variable
33 ansible.builtin.set_fact:
34 list_of_pci_devices_that_can_be_enabled_passthrough: >-
35 {{ list_of_pci_devices_that_can_be_enabled_passthrough | default([])
36 + [item.1]
37 }}
38 loop: "{{ device_ids | product(pci_devices_result.ansible_facts.hardware.pciDevice) | list }}"
39 when:
40 - item.0.id == item.1.id