Number of network interfaces varies in our environment and we have atleast 5 variants, hardcoding is not an option.
This playbook need to check {{ ansible_interfaces }} and then get the status of all available interfaces active status.
from the example snippet below
“ansible_eth1”: {
“active”: true,
“device”: “eth1”,
I am trying to set_fact which should return the dict like
“eth1status_active” = “yes”
eth0status_active" = “no”
…
ethxstatus_active = ‘xxx’
I have lost just before the last task
tasks:
-
name: get filesystem
setup: gather_subset=network -
name: set fact network_interfaces
set_fact: network_interfaces={{ ansible_interfaces }} -
name: set fact
set_fact: iface_item=“ansible_{{ item }}”
with_items: “{{ ansible_interfaces }}”
register: iface_result -
name: make a list
set_fact: iface_list=“{{ iface_result.results | map(attribute=‘ansible_facts.iface_item’) | list }}”
Please help me continue playing …