# ios\_l2\_interfaces vlan trunks

**URL:** <https://forum.ansible.com/t/ios-l2-interfaces-vlan-trunks/33933>\
**Category:** Ansible Project\
**Created:** [September 30, 2020, 6:58pm UTC](https://forum.ansible.com/t/ios-l2-interfaces-vlan-trunks/33933 "2020-09-30T18:58:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Lucht](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@Richard\_Lucht](https://forum.ansible.com/u/Richard_Lucht)\
**Post date:** [September 30, 2020, 6:58pm UTC](https://forum.ansible.com/t/ios-l2-interfaces-vlan-trunks/33933/1 "2020-09-30T18:58:04Z")

</div>

I am testing to loop a config to check all ports and add all vlans to the port. I am having an issue with the loop. I am wanting to loop through all interfaces that match the mode trunk

- name: Add all vlans to trunks  
connection: network\_cli  
gather\_facts: no  
hosts: all  
vars:  
ansible\_network\_os: ios

tasks:

- name: Configure L2 Trunks  
ios\_l2\_interfaces:  
mode: Trunk  
trunk\_allowed\_vlans: “{{ vlans | map(attribute=‘vlan\_id’) | join(‘,’) }}”  
state: present  
loop: “{{ interfaces[inventory\_hostname] | selectattr(‘mode’,‘equalto’,‘trunk’) | list }}”
