# Network Modules Parents: as a list

**URL:** <https://forum.ansible.com/t/network-modules-parents-as-a-list/22187>\
**Category:** Ansible Project\
**Created:** [August 2, 2016, 7:40am UTC](https://forum.ansible.com/t/network-modules-parents-as-a-list/22187 "2016-08-02T07:40:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![emhgully](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@emhgully](https://forum.ansible.com/u/emhgully)\
**Post date:** [August 2, 2016, 7:40am UTC](https://forum.ansible.com/t/network-modules-parents-as-a-list/22187/1 "2016-08-02T07:40:29Z")

</div>

Hello,

I am trying to setup a file as shown below. Where the command “switchport access vlan 10” is required on two separate parts of the configuration “GigabitEthernet1/0/2” and “GigabitEthernet1/0/30”. However it only ever applies the command to the last item in the Parents list. Is this a valid approach/ syntax for this. I have tried against ansible 2.1.0.0 and 2.1.1.0 but each time the same result.

thanks

---

<div class="post-metadata">

**Author:** ![psprygada](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@psprygada](https://forum.ansible.com/u/psprygada)\
**Post date:** [August 3, 2016, 3:05am UTC](https://forum.ansible.com/t/network-modules-parents-as-a-list/22187/2 "2016-08-03T03:05:48Z")

</div>

I think there is a little confusion here. Parents refers to hierarchy in the configuration file but what you have described here is separate blocks. Your example playbook would try to build the config as such:

interface GigabitEthernet1/0/2  
interface GigabitEthernet1/0/30  
switchport access vlan 10

Which of course explains why you only see the second interface configured. In order to achieve what you are attempting to do, you need to loop over the task as follows:

- name: vlan 10  
ios\_config:  
host: “A-NODE”  
username: admin  
password: password  
lines:
- switchport access vlan 10  
parents: “{{ item }}”  
authorize: yes  
with\_items:
- interface GigabitEthernet1/0/2
- interface GigabitEthernet1/0/30
