How to fill netplan config file with routes via ansible

179 views
Skip to first unread message

Markus

unread,
Oct 27, 2021, 5:25:18 AM10/27/21
to Ansible Project

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

Reply all
Reply to author
Forward
0 new messages