We’re using vyos_command module to deploy the whole firewall configuration each time we make a change to the configuration.
Basically we send the following with the module:
delete firewall
set firewall ...
set firewall ...
(at least 120 lines of set firewall ...)
commit
save
This causes about 45 seconds of processing, which is quite a long time.
I tried the same process manually in an ssh session and it took roughly 30 seconds, which is also quite long.
I then tried doing the same with merge using the vyos json configuration format:
delete firewall
commit
save
merge the-same-firewall-configuration-in-json-format.json
commit
save
just from the merge to saving finished it also took 17seconds, which is quite long, but definitely better.
Any ideas why the set commands (especially when using the vyos_command) are taking so long to apply and maybe ideas how to improve it?
I also noticed that CPU of the vyos is quite heavily utilized during all of these actions.
I might be missing something here but that guys code is published at:
What his module seems to do is to aggregate all commands into a single script created locally on the VyOS box and then execute it.
However I doubt this would make like 1000 static routes to be able to get injected into VyOS due to the time static routes and firewall rules takes to get commited through vyos-configd (even when runned as a local script).
But he will avoid the overhead of sending one command at a time through ansible.
Could also be that once his script thats created locally runs it returns control to the client asynchronous which makes it from the client point of view look like you just sent 1000 routes/firewall entries and have them commited in 1 second while in fact it will take another 10 minutes before this locally created script will complete at the VyOS box.
Just an idea, which you might’ve already considered - if you’re not doing bulk logic changes, you might be able to get away with a smaller playbook/tag-set that just updates groups or other appropriate logic components when they’re all you’re updating.
Additionally, depending on use case, vyos_config could be a lot faster than vyos_command. It performs an initial comparison and filters conf-mode commands that are already in place. The actual configure stage inside vyos_config also looks like it doesn’t wait for results on each entry, but queues up the effective set and checks results after the commit, avoiding the vyos_command execute->get result loop for each individual step.