hosts: all
connection: network_cli
gather_facts: no
vars:
ansible_network_os: ios
tasks:
- name: Get config for IOS devices
ios_facts:
gather_subset:
- '!all'
- '!min'
gather_network_resources:
- 'l2_interfaces'
- name: Configure L2 Trunks
ios_l2_interfaces:
mode: "{{ item.mode }}"
trunk_allowed_vlans: "{{ vlans | map(attribute='vlan_id') | join(',') }}"
state: present
loop: "{{ l2_interfaces[ansible_net_hostname] | selectattr('mode','equalto','trunk') | list}}"