I want to create a local firmware mirror that can be scripted.
Easy in principle:
- Create a user on each MT box that has a full-capability user with an authorized SSH key
- "scp new-firmware.npk mtbox:"
- "ssh mtbox reboot"
That will reboot that one router, which will see an *.npk file on boot at the root of its file system, and so will automatically upgrade to that version.
Putting this into a loop to iterate over all available routers is not difficult. The tricky bit is sending the right version of the firmware to each subset of boxes that has a different CPU, or needs a different version than the others, and so on. Perhaps your existing Ansible setup will suffice for this.
Alternately, there are MNDP (MikroTik Neighbor Discovery Protocol) programs which give output you can use to drive the upgrade loop. The MNDP reply message doesn't appear to include the CPU type string in the form that MikroTik uses in naming firmware upgrade packages, but it does have a "Board" string you can map to the CPU type, which then tells you which file to send. The reply also includes a version string you can use to decide which routers need an upgrade and which to skip.
I hear the devops crowd likes Go, so
this particular implemnentation may be of special interest since it gives you a golang library you can use to write your own program with. The associated "discover" program isn't really written to produce output suitable for parsing in a script, but it's a pretty trivial shell around the actual "mndp" library.