Community discussions

MikroTik App
 
flohoff
just joined
Topic Author
Posts: 1
Joined: Tue May 18, 2021 4:18 pm

Ansible/Indempotence / Removing port from vlans etc

Tue May 18, 2021 5:19 pm

Hi,
i am trying to get my way around the RouterOS command line and the goal is to put all infrastructure into ansible code. So i am trying to find solutions for common tasks first by command line to then put it into ansible playbooks. Target is currently CRS326 with current RouterOS and i must say i am a bit puzzled or lost (Doing networking for 20+ Years on ALU, Cisco, Juniper, Redback etc)

So is there a command to remove a port from a vlan? From what i found there isnt. One has to get output from the command line, parse it and put it in again right?

So the vlan creation and port association is one single statement like:

Example:
/interface bridge vlan add bridge=bridge untagged=sfp-sfpplus10,sfp-sfpplus11 vlan-ids=1001
Now i want to algorithmically put port 10 into vlan 1002 i need to find all statements mentioning port 10, parse them and issue a couple of set statements - Example:
/interface/bridge/vlan/export
grep for vlans mentioning the sfpplus10

and issue a corresponding set for all vlans with the untagged/tagged port list in the set - For example:
/interface/bridge/vlan/set untagged=sfp-sfpplus11 [ find vlan-ids=1001 ]
Then issue a get on the vlan 1002, add the port 10 to the list of untagged interfaces and set the list again (Or in case 1002 is not existant issue an add instead of set command)
/interface bridge vlan add bridge=bridge untagged=sfp-sfpplus10 vlan-ids=1002


Is that a correct understanding? Read:

- I can not incrementally remove or add ports for vlans
- I can not remove a port from all vlans in a single statement (or 2 in case for tagged and untagged)

Flo

Who is online

Users browsing this forum: marcelofares and 26 guests