nautobot/nornir-nautobot

Add groups to Inventory

jvanderaa opened this issue · 5 comments

Add ability to add options for groups, in a similar fashion to what the Ansible inventory module will support.

Configuration

options: {
  "group_by": ["tags", "sites"]
}

Underneath considerations

  • Should have a finite list of options to group by that are known to work
  • Unit tests
  • Verify that the group_by option that comes in will work
jifox commented

@jvanderaa

Do you think the group names should get the "group_by" as a prefix?

options: {
  "group_by": ["tags", "sites"]
}

Group names for inventory:

tags_tag1, tags_tag2, sites_site1, sites_site2

Yeah, that is exactly what I'm thinking of. My goal is to try to get the inventories between Ansible and Nornir to be as close as possible to each other within the projects @jifox. I think that the Ansible inventory has a bunch of terrific features that Nornir could benefit from.

@jvanderaa I've done a similar implementation in nornir_netbox
https://github.com/wvandeun/nornir_netbox/blob/76d3d9b2da1190a11f302f28f19b6d1e49528932/nornir_netbox/plugins/inventory/netbox.py#L257-L280

Is this how you envisioned providing group support?

The biggest vision was to try to line things up with the Ansible inventory that had a few extra options. But that is not a requirement by any means. I'll welcome what makes sense. What I was thinking of having a key in the inventory options of

{
    "group_by": [
        "site",
        "region",
        # ... and so on
        ]

With the various items.

@wvandeun I'm good with the options that make sense to get some groups populating.