Junos Automation (Scripting)
Junos Automation (Scripting)

Jinja2 cannot process l3-interface command with variables

‎10-03-2018 08:58 AM

We have a jinja2 file to create l3 interface in the vlans stanza as follows:


set vlans description VLAN{{ vlannumber }} vlan-id {{ vlannumber }} l3-interface {{ vlanorirb }}.{{ vlannumber }}


We are taking the vlannumber variable from a spreadsheet entry, the vlanorid is also a variable (vlan or irb as needed for model of EX device) and the vlannumber variable.  The "." may be the culprit, or the two variables separated by the "." may be the culprit.  Either way, we are getting an error:


jnpr.junos.exception.ConfigLoadError: ConfigLoadError(severity: error, bad_element: l3-interface, message: error: Invalid numeric vlalue: 'l3-interface' (next line of error response) error: syntax errir. expecting <identifier>


There is no workaround for the l3-interface vlan.number or l3-interface irb.number in Junos configuration from the cli.  So, what is the workaround to make this line in jinja2 work?



Junos Automation (Scripting)

Re: Jinja2 cannot process l3-interface command with variables

‎10-03-2018 02:54 PM



Can you print your rendered jinja2 before you attempt to load it into the configuration to see that it has rendered correctly? The error message appears to indicate that the configuration is not correct.


I have used jinja2 with both vlan and irb interfaces to build the entire configuration based on the model.