diff --git a/tasks/main.yml b/tasks/main.yml index 3b911fd..e10fd79 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -15,16 +15,26 @@ wol_detected_interface: "{{ ansible_default_ipv4.interface }}" when: wol_interface | default('') | length == 0 -- name: Detect physical NIC enslaved to bridge +# - name: Detect physical NIC enslaved to bridge +# ansible.builtin.set_fact: +# wol_detected_phy: "{{ item }}" +# loop: "{{ ansible_interfaces }}" +# when: +# - wol_interface | default('') | length == 0 +# - item != 'lo' +# - hostvars[inventory_hostname]['ansible_' + item] is defined +# - hostvars[inventory_hostname]['ansible_' + item].master is defined +# - hostvars[inventory_hostname]['ansible_' + item].master == wol_detected_bridge + +- name: Detect physical NIC behind bridge ansible.builtin.set_fact: - wol_detected_phy: "{{ item }}" - loop: "{{ ansible_interfaces }}" + wol_detected_phy: "{{ ansible_facts[wol_detected_bridge].interfaces[0] }}" when: - wol_interface | default('') | length == 0 - - item != 'lo' - - hostvars[inventory_hostname]['ansible_' + item] is defined - - hostvars[inventory_hostname]['ansible_' + item].master is defined - - hostvars[inventory_hostname]['ansible_' + item].master == wol_detected_bridge + - ansible_facts[wol_detected_bridge] is defined + - ansible_facts[wol_detected_bridge].interfaces is defined + - ansible_facts[wol_detected_bridge].interfaces | length > 0 + - name: Debug WoL interface selection ansible.builtin.debug: