nautobot / nornir-nautobot

Nornir inventory and plugins for Nautobot.
https://docs.nautobot.com/projects/nornir-nautobot/en/latest/
31 stars 25 forks source link

Add groups to Inventory #3

Open jvanderaa opened 3 years ago

jvanderaa commented 3 years ago

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

jifox commented 3 years ago

@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
jvanderaa commented 3 years ago

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.

wvandeun commented 2 years ago

@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?

jvanderaa commented 2 years ago

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.

jvanderaa commented 2 years ago

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