dvtirol / pynetinstall

Module to perform Mikrotik Routerboard Netinstall via Etherboot
GNU General Public License v3.0
66 stars 8 forks source link

No default config, branding, environment variables #5

Open etfz opened 5 months ago

etfz commented 5 months ago

Hi,

I don't know exactly what netinstall is capable of normally, but would it be possible to skip applying the default configuration after installation? And also install my custom branding package? Would the latter simply be a matter of uploading the package at the same time as the firmware?

Would it be possible to perhaps use environment variables instead of pynetinstall.ini?

About the boot images; do you know whether these ever change, or can I keep using the same ones "forever"?

uedvt359 commented 5 months ago

I don't know exactly what netinstall is capable of normally, but would it be possible to skip applying the default configuration after installation?

do you mean no config at all (i.e., "/export" is empty) or using the mikrotik default config instead of a custom one? the former can be done (although it seems ill-advised) by specifying an empty config.rsc. the latter can be done by not specifying a config at all.

And also install my custom branding package? Would the latter simply be a matter of uploading the package at the same time as the firmware?

looking at this screenshot, i think it should be possible to do this by extending Flasher.do_files() - i'd like to support this (if only i had the time).

in our setup, we upload a default-config.rsc that:

  1. uses /tool/fetch to download additional packages and the real (dynamcially generated) config.rsc
  2. installs a on-startup scheduler that imports the config and removes itself
  3. reboots the device (which installs the downloaded packages and triggers configuration)

Would it be possible to perhaps use environment variables instead of pynetinstall.ini?

i don't know what use case you have in mind, but assuming you are trying to dynamically change which files to upload, you're supposed to write your own plugin that selects a routeros package and (optionally) default config based on mac address or model number (see readme). you can of course also write a small plugin that reads filenames from the environment.

etfz commented 5 months ago

Configuration question answered as per the other issue.

I tried simply copying the code that uploads the firmware package, adjusting the paths, and it seemed to work.

If you don't mind, roughly how do you work with your dynamic configuration system?

Regarding environment variables, I'm not sure that I had anything specific in mind, other than it being easier to edit than the ini file when using RouterOS. I saw the other open ticket with an example of a multi architecture plugin, and I'm certainly going to have a look at that, but I am going to need to figure out the values for some other architectures. What's an easy way of debugging that?

uedvt359 commented 5 months ago

our workflow is like this (a little simplified):

  1. we upload the firmware and a static stage0-config.rsc.
  2. this stage0-config.rsc then on first boot calls /tool/fetch http://provisioning.internal/config?serial=abcdefgh dst-path=real-config.rsc to download the actual config from a small api we wrote.
  3. then, stage0-config.rsc downloads packages (also with /tool/fetch) if needed and installs a /system/scheduler start-time=startup on-event=/import real-config.rsc; /sys/scheduler/remove 0 and reboots.
  4. on reboot, the packages are installed and afterwards the config is imported and the scheduler removed.

the real-config.rsc is generated on the fly from jinja2 templates, with data provided by our dcim (data center infrastructure management) platform.

regarding values for other platforms: when you boot the netinstall image, pynetinstall will print out a line like this:

Device found! mac=48:a9:8a:xx:xx:xx, model=RB5009UG+S+, arch=arm64

this should give you all the information you need. sadly, the model number listed here is often different than what /system/routerboard/print or /system/resource/print says, so you can't rely on that. for example, note the space in netinstall and no space in /sys/routerboard/print:

[INFO ] -> Device found! mac=xx:xx:xx:xx:xx:xx, model=RB LtAP-2HnD, arch=mmips

[xxx] > /sys router pr
        board-name: LtAP
             model: RBLtAP-2HnD

[xxx] > /sys resource pr
        architecture-name: mmips
               board-name: LtAP
                 platform: MikroTik