# How create vlans if he don't exist in the file gathred by ios\_facts

**URL:** <https://forum.ansible.com/t/how-create-vlans-if-he-dont-exist-in-the-file-gathred-by-ios-facts/31993>\
**Category:** Ansible Project\
**Created:** [January 16, 2020, 2:18pm UTC](https://forum.ansible.com/t/how-create-vlans-if-he-dont-exist-in-the-file-gathred-by-ios-facts/31993 "2020-01-16T14:18:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaouane\_Alaaeddine](https://avatars.discourse-cdn.com/v4/letter/k/a87d85/32.png) [@Kaouane\_Alaaeddine](https://forum.ansible.com/u/Kaouane_Alaaeddine)\
**Post date:** [January 16, 2020, 2:18pm UTC](https://forum.ansible.com/t/how-create-vlans-if-he-dont-exist-in-the-file-gathred-by-ios-facts/31993/1 "2020-01-16T14:18:45Z")

</div>

Hello,

I want to create (configurate) “vlan” in my device (switch) when it is not available on my equipment

for configurate or ( add) vlan in the switch I use the module “ios\_vlans”

for gather facts of my device I use “ios\_facts”

you will find below how are stored all the vlans currently available on my equipment

> `
> 
> “ansible\_network\_resources”: {  
> “vlans”: [  
> {  
> “mtu”: 1500,  
> “name”: “default”,  
> “shutdown”: “disabled”,  
> “state”: “active”,  
> “vlan\_id”: 1  
> },  
> {  
> “mtu”: 1500,  
> “name”: “V2-SPA-LAN-A-Admin”,  
> “shutdown”: “disabled”,  
> “state”: “active”,  
> “vlan\_id”: 2  
> },  
> {  
> “mtu”: 1500,  
> “name”: “VLAN0010”,  
> “shutdown”: “disabled”,  
> “state”: “active”,  
> “vlan\_id”: 10  
> },  
> {  
> “mtu”: 1500,  
> “name”: “Total”,  
> “shutdown”: “disabled”,  
> “state”: “active”,  
> “vlan\_id”: 20  
> },  
> {  
> “mtu”: 1500,  
> “name”: “youpi”,  
> “shutdown”: “disabled”,  
> “state”: “active”,  
> “vlan\_id”: 222  
> }
> 
> `

I’m trying to find of way of how doing it thanks to when conditionnal in ansible but can’t find it.  
Thanks for you help
