# Conditions with vlan id

**URL:** <https://forum.ansible.com/t/conditions-with-vlan-id/31472>\
**Category:** Ansible Project\
**Created:** [October 16, 2019, 6:42am UTC](https://forum.ansible.com/t/conditions-with-vlan-id/31472 "2019-10-16T06:42:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [October 16, 2019, 6:42am UTC](https://forum.ansible.com/t/conditions-with-vlan-id/31472/1 "2019-10-16T06:42:35Z")

</div>

Hi Team,

I need to push the line in cisco switch if vlan id =25 or vlan id = 100-119. what module should I use?

I parsed **show interfaces status** and got below structured output. please help.

“Gi1/0/12”: {  
“data”: {  
“duplex”: “auto”,  
“interface”: “Gi1/0/12”,  
“name”: “test interface”,  
“speed”: “auto”,  
“status”: “notconnect”,  
“type”: " 10/100/1000BaseTX",  
“vlan”: “25”

thanks

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [October 24, 2019, 2:18pm UTC](https://forum.ansible.com/t/conditions-with-vlan-id/31472/2 "2019-10-24T14:18:53Z")

</div>

This got resolved. thanks team.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 25, 2019, 12:47pm UTC](https://forum.ansible.com/t/conditions-with-vlan-id/31472/3 "2019-10-25T12:47:56Z")

</div>

Thanks, but I don't see the answer in this thread?  
How was it solved?

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [November 20, 2019, 6:57am UTC](https://forum.ansible.com/t/conditions-with-vlan-id/31472/4 "2019-11-20T06:57:57Z")

</div>

The below is the solution

vlan\_id\_l2 : [‘30’, ‘100’]

- name: configure the line based on desired condition (Layer 2)  
ios\_config:  
lines:
- 
* * *
- 
* * *
- 
* * *

parents: “interface {{ item.key }}”  
when: item.value.data.vlan in vlan\_id\_l2  
with\_dict: “{{ interfaces\_status\_facts }}”
