diff --git a/tasks/main.yml b/tasks/main.yml index e10fd79..59e5c11 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -15,25 +15,30 @@ wol_detected_interface: "{{ ansible_default_ipv4.interface }}" when: wol_interface | default('') | length == 0 -# - 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: Debug facts + ansible.builtin.debug: + msg: + - "{{ hostvars[inventory_hostname] }}" -- name: Detect physical NIC behind bridge +- name: Detect physical NIC enslaved to bridge ansible.builtin.set_fact: - wol_detected_phy: "{{ ansible_facts[wol_detected_bridge].interfaces[0] }}" + wol_detected_phy: "{{ item }}" + loop: "{{ ansible_interfaces }}" when: - wol_interface | default('') | length == 0 - - ansible_facts[wol_detected_bridge] is defined - - ansible_facts[wol_detected_bridge].interfaces is defined - - ansible_facts[wol_detected_bridge].interfaces | 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: "{{ ansible_facts[wol_detected_bridge].interfaces[0] }}" +# when: +# - wol_interface | default('') | length == 0 +# - 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