srl-labs / containerlab

container-based networking labs
https://containerlab.dev
BSD 3-Clause "New" or "Revised" License
1.53k stars 263 forks source link

Config template support 🚀 #384

Closed kellerza closed 3 years ago

kellerza commented 3 years ago

383 triggered some good discussions on config template support

Scope of #383

Other work:

Future evolution

New config vars

Node

nodes: xx: or defaults:
    config:
      vars:
        isis_id: 0
      transport: ssh
      templates:
        - ports
        - ifaces
links:
  - endpoints: [sr1:eth1, sr2:eth1]
     vars:
      port: 1/1/c1/1, 1/1/c2/1

Params

$ ./clab config --help
configure a lab based using templates and variables from the topology definition file
reference: https://containerlab.srlinux.dev/cmd/config/

Usage:
  containerlab config [flags]

Aliases:
  config, conf

Flags:
  -c, --check int               render dry-run & print n lines of config
  -h, --help                    help for config
  -l, --template-list strings   comma separated list of template names to render
  -p, --template-path strings   comma separated list of paths to search for templates
LimeHat commented 3 years ago

Have you considered decoupling of base topology definition ("old" clab.yml format) from new variable definitions?

hellt commented 3 years ago

Hi @LimeHat if you mean to keep variables used for config generation apart from the topology file, then we had a few rounds of discussions about it and the majority of responders were find it more comfortable to have the variables defined in the same file as the topology. This has some benefits such as:

The cost is that the file might be bigger than one would want.

I guess a compromise can be added to "Future evolution" is to have a something like this

config:
  transport: ...
  vars-from-file: <filepath>

to indicate that variables should come from the file

kellerza commented 3 years ago

Move discussion to #487