04-25-2022 03:23 PM
Hello- I'm trying to use DayN template to configure switch port. All the vlans are created using Onboarding templates.
So in the config i have following vlans already provisioned on the switch
vlan 30
name VOICE-VLAN
!
vlan 40
name DATA-VLAN
!
so in my DayN template i'm able to use something like
interface range GigabitEthernet1/0/1-12
switchport mode access
switchport voice vlan name VOICE-VLAN
and it deploys the following
interface range GigabitEthernet1/0/1
switchport mode access
switchport voice vlan 30
but for other port config like the one below vlan name is not supported. It has to be vlan id
interface range GigabitEthernet1/0/13-23
authentication event server dead action authorize vlan x
i could use something like ${Data_Vlan} and have this info as input from the user but the vlan id is different in all locations so i didn't want to make this a variable that you have to input and remember the data vlan iD.
Since this vlan already exist on the switch , is there a way to use the name and have it convert to vlan ID? any system variable to do something like this or another way?
Hope this makes sense
TIA
04-25-2022 04:01 PM
But if vlan id is different for each location, then, you are going to need different templates for each location, right?
Why you can´t just add on the template "authentication event server dead action authorize vlan 30" and apply on the switch?
04-25-2022 07:20 PM
i do have different Onboarding templates which configures different vlan IDs. i was hoping to use single DayN template to configure the ports with different vlans
04-27-2022 08:18 AM
You could use Jinja Templates for this and define the variables inside the template
{% set VoiceVlanID = '30' %}
interface range GigabitEthernet1/0/13-23
authentication event server dead action authorize vlan {{ VoiceVlanID }}
Cheers
Markus
04-27-2022 09:06 AM - edited 04-27-2022 09:11 AM
Thanks Markus- What i need is to look up vlan ID somehow as the ID could be different every time. I need something like
i.e {% set VoiceVlanID = 'sh vlan name VOICE-VLAN ifindex ' %}
obviously this doesn't work but you get what i'm trying to do here
04-27-2022 09:46 AM
Click the link in the upper right of the template editor for Template System Variables. I don't think you'll find anything vlan related, so it's unlikely you'll be able to do what you're hoping. Perhaps this is an opportunity to pick a new vlan to use everywhere for this purpose, to simplify the operation of your network going forward.
If you use a variable instead, keep in mind that you can build a CSV file to import to the provision process to populate all the variables automatically. So you don't actually have to "manually" enter the vlan number for each site each time you provision.
04-27-2022 10:27 AM
Look at the screenshot. There is something related from the inventories
I haven't tried yet, but at least there is something to test with
04-27-2022 01:14 PM
The easiest way to access those interface variables in your template, is something like this (so that you can avoid having to find the index)
#foreach( $int in $__interface )
$int.portName
#if ($int.description.contains("Cisco"))
#end
04-27-2022 10:37 AM
unfortunately this is a legacy environment and not easy to clean up . I only found interface.vlanid in the variable ..thats not what i need. will just have to input the vlan id for now until we figure out another way.. thank you
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide