Search and replace element in configuration


It would be great if Juniper’s “replace pattern” feature could be incorporated into VyOS. I don’t think this feature is copyrighted :slight_smile:

replace pattern <pattern> with <new_value>

The pattern should support regular expressions.

The use cases are many but let’s say that you want to change naming convention on all firewall objects - either change object name from hyphen to underscore, or add a prefix to all objects.

You can run awk or whatever on the /config/config.boot file and then reboot or load that modified config to replace your current running one.

I would call that a workaround, but it works of course :slight_smile:

I just love the “replace pattern” feature in Junos along with “commit confirm” without having to reboot when the configuration gets rolled back.

By the way, did you test rollback-soft feature? Allows to rollback configs without rebooting

rollback-soft works great :+1: but the use-case is a bit different than commit-confirm which is a great feature if you lock yourself out with a faulty commit.

It will be the next step

1 Like

You may already know this since it seems you’re more referring to more complex renaming, but just in case:

There is a rename feature that works similar to Juniper, but it can’t do regex:

vyos@vyos# show route-map | commands
set route-map TEST rule 10 action 'permit'
set route-map TEST rule 10 match ip address prefix-list 'TEST'
[edit policy]
vyos@vyos# rename route-map TEST to route-map NEW_NAME
[edit policy]
vyos@vyos# show | compare
[policy route-map]
- TEST {
-     rule 10 {
-         action "permit"
-         match {
-             ip {
-                 address {
-                     prefix-list "TEST"
-                 }
-             }
-         }
-     }
- }
+     rule 10 {
+         action "permit"
+         match {
+             ip {
+                 address {
+                     prefix-list "TEST"
+                 }
+             }
+         }
+     }
+ }

I’ve tried this method to rename and it works.
However if an element is referred several places in the config I cannot rename in one command like Junos «replace pattern» does.

Not a big issue but would be a nice feature to add to an already great system :grinning: