Automate source port for logging config

Share your Config Push presets or discuss automation in general
Post Reply
User avatar
tauceti3
Posts: 3
Joined: Fri Jul 14, 2023 3:22 pm
Location: UK

Mon Jul 17, 2023 10:21 am

Hello,

In the environment I'm manging the management IP could be an SVI or Phy port, I'd rather not have to specify the interface manually as it differs for many devices.

Is it possible to use Unimus to create dynamic config based on the source port that the management IP sits on.
Similar to how Ansible gather facts can be used to collect L3 information, then pull interface name from that.

I''ve had a look at use of var as described on the wiki but there are few working examples and seemingly the only logic that can be applied is a regex search. But I do not see how I can combine all this in one bulkpush.
Perhaps something like...

Code: Select all

show ip int brief | include {device_ip}

//Output
Vlan29                 a.b.c.d   YES NVRAM  up                    up

!! But then how to say first block of chars = {src_int} 

no logging event link-status boot
logging event link-status default
logging trap debugging
logging source-interface {src_int}
logging host w.x.y.z
will.t
Posts: 7
Joined: Tue Jul 18, 2023 12:51 pm

Tue Jul 18, 2023 2:24 pm

Hello tauceti3,

We have built-in variables, that would make your task really simple, currently on our roadmap #omgcantwait.
However as a quick workaround one can utilize tcl shell to extract the interface name of the management interface.
Please go ahead and try this cmdlet via Mass config push:

Code: Select all

# enter tclsh
tclsh

# set your logging host IP here
set logging_host "1.2.3.4"

# find management interface
regexp { +\d+ +vty +\d+ +\S+ +\S+ +\S+ +(\S+)} [exec show users] fullMatch user_ip
regexp {\S+ +(\S+)\.\d+ +\S+ +\S+} [exec show tcp brief | i $user_ip] fullMatch mgmt_ip
regexp {(\S+) +\S+ +\S+ +\S+ +\S+ +\S+} [exec show ip int br | i $mgmt_ip] fullMatch src_int

# config device
ios_config "no logging event link-status boot"
ios_config "logging event link-status default"
ios_config "logging trap debugging"
ios_config "logging source-interface $src_int"
ios_config "logging host $logging_host"
User avatar
tauceti3
Posts: 3
Joined: Fri Jul 14, 2023 3:22 pm
Location: UK

Tue Jul 18, 2023 4:41 pm

Thanks will.t,

Appreciate the quick and detailed response, this should helps loads.
Very much looking forward to the roadmap release features #omgcantwait

The wiki doesn't point me at tcl setup (been a Cisco centric thing).
But I see Unimus has a decent guide here https://blog.unimus.net/automating-cisc ... us-part-1/

The inevitable/dreaded follow up question is... how would I expand this to other Vendors such as Juniper or Extreme?
will.t
Posts: 7
Joined: Tue Jul 18, 2023 12:51 pm

Wed Jul 19, 2023 3:43 pm

Hi tauceti3,

Glad to be of help.

Unimus is many great things but it is not an IaC platform. As such it does not have a single scripting language that is cross-vendor (you cannot write a single config push that would work on any vendor device)
The solution would be to prepare a custom script for specific vendor CLI, be it Juniper or Extreme networks, and push it to devices using Mass config push feature.

Hope that makes sense.

Let me know if there is anything else.
User avatar
tauceti3
Posts: 3
Joined: Fri Jul 14, 2023 3:22 pm
Location: UK

Thu Jul 20, 2023 12:48 pm

Thanks Will.

I'll see what I can come up with.
Post Reply