Tuesday, November 14, 2017

Iterate subnets in Jinja template?

So I'm trying to generate switch configs using Ansible and Jinja.

I'm trying to extrapolate subnets from a starting subnet (class C) based on a variable provided in a site specific YAML. I define the starting subnet (ex. 10.1.1.0/24) and the number of subnets needed (ex. 16.) I'm using ipaddr() to get specific host addresses within the subnet, but have no idea how to easily get the next class C subnet.

Is there a way to do this without having to rip the string apart and parse the third octet by itself?



No comments:

Post a Comment