containerlab icon indicating copy to clipboard operation
containerlab copied to clipboard

Make `groups` work as they were designed to

Open hellt opened this issue 1 year ago • 1 comments

Containerlab topology definition file had a notion of a group forever. But we never implemented them in the way they were envisioned to be used.

A group should allow a user to define a common set of node-level parameters that a certain node can then inherit via the group reference.

For example, the below topology defines a group leafs and adds some node-specific parameters to it. Then a node in the topology references this group to adopt the specified parameters:

name: group-demo
topology:
  groups:
    leafs:
      labels:
        someLabel: someValue
      type: ixrd3l

  nodes:
    node1:
      group: leafs

    node2:

node1 will inherit labels and type as defined in a group, whereas node2 will not.

hellt avatar Mar 05 '25 14:03 hellt

I'm just starting with container lab. I think rather than having groups defined in one place and then tag the nodes as part of the groups, why not have groups be subsets of nodes. This could also allow for multiple layers of inheritance and maybe even groups in groups. Kind of like how Ansible handles yaml inventories

name: groups-demo
topology:
# General nodes
  nodes:
    node1:
      kind: linux

# Grouped nodes
  groups:
    lab1:
      kind: ceos
      labels:
        cloud: az
      nodes:
        lab1a:

    lab2:
      kind: nokia_srlinux
      groups:
        clients:
          nodes:
            lab2a:
            lab2b:
        spine:
           nodes:
             spine1:
               type: ixrd31

evilhamsterman avatar Mar 21 '25 22:03 evilhamsterman