# How to fill netplan config file with routes via ansible

**URL:** <https://forum.ansible.com/t/how-to-fill-netplan-config-file-with-routes-via-ansible/35929>\
**Category:** Ansible Project\
**Created:** [October 27, 2021, 9:25am UTC](https://forum.ansible.com/t/how-to-fill-netplan-config-file-with-routes-via-ansible/35929 "2021-10-27T09:25:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Markus1](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@Markus1](https://forum.ansible.com/u/Markus1)\
**Post date:** [October 27, 2021, 9:25am UTC](https://forum.ansible.com/t/how-to-fill-netplan-config-file-with-routes-via-ansible/35929/1 "2021-10-27T09:25:18Z")

</div>

I’m trying to manage netplan by using ansible. That worked well in the past, where I used the a static template. Now I have to add several lines to the route section:

… bridges:… br0:  
… routes:  
… - to: 0.0.0.0/0  
… via: {{ ansible\_default\_ipv4.gateway }}  
… on-link: true  
… - to: {{ IP1 }}/32  
… scope: link  
… - to: {{ IP2 }}/32  
… scope: link  
… …

Now here comes the part, where I struggle.

Due to the fact, that my local routes differs from host to host, I can’t use a static template. So I tried to create a list in the host vars file, that contains a list of ips.

ROUTES:

- ip: “aaa.AAA.aaa.AAA”
- ip: “bbb.BBB.bbb.BBB”
- ip: “ccc.CCC.ccc.CCC”
- ip: n

I wanted to insert this list into my netplan file while looping over this list.

But I dont get it working. Do you have any hint or advice?

Thx in advance

Markus
