Config Templates: Accessing IPAM Information from Device context #13692
Replies: 2 comments 4 replies
-
As of NetBox 3.6, you can access models directly from a configuration template. In your example, the for loop should start off like so: For what it's worth, in my organization we define default gateways in a Config Context associated with a particular site and then reference that config context object in the template. I suppose that's slightly more manual, but it has served us well. |
Beta Was this translation helpful? Give feedback.
-
Here is a solution that I came up with. It requires the following.
The configuration template will determine the default gateway based on it's primary IP. jinja2 sample
|
Beta Was this translation helpful? Give feedback.
-
I'm trying to create a config template for some switches. Part of the core of the switch configuration is the default gateway:
ip default-gateway {{ default-gateway-for-subnet }}
From within the Config Template context, it looks like I only have access to the
device
object. Is there any way I can access any IPAM objects likeprefixes
? Typically I use the first address in the subnet for the default gateway, so I'm wanting to do something like this:The logic:
I'm not sure how to translate this into proper Jinja2 templating for the Config Template. If there's a much simpler way to do this, please, I'm all ears.
Beta Was this translation helpful? Give feedback.
All reactions