Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Netbox inventory plugin: add region grouping, optional interfaces&vlans gathering, slug and group name prefix length #60642

Open
wants to merge 29 commits into
base: devel
from

Conversation

@Yannis100
Copy link
Contributor

commented Aug 15, 2019

SUMMARY

Add region grouping, optional interfaces&vlans gathering, slug, and group name prefix length

Fixes #60124

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

Netbox inventory plugin

ADDITIONAL INFORMATION
plugin: netbox
api_endpoint: https://netbox:443
validate_certs: False
config_context: True
token: xxx
vlans: True
interfaces: True
use_slugs: True
substr_group: 8
group_by:
  - device_roles
  - device_types
  - sites
  - platforms
  - tags
  - regions
query_filters:
  - role: SWA
  - platform: ios-xe
ansible-inventory --graph
@all:
  |--@platform_ios-xe:
  |  |--3850-SWA01
  |--@device_r_SWA:
  |  |--3850-SWA01
  |--@device_t_WS-C3650-48PD-S:
  |  |--3650-SWA01
…
  |--@device_t_WS-C3850-12X48U-S:
  |  |--3850-SWA01
…
  |--@regions_AMR:
  |  |--@sites_US-PHX:
  |  |--@sites_USATL04:
  |  |  |--3850-SWA01
  |  |--@sites_USPHX03:
  |  |  |--3650-SWA01
  |--@regions_APAC:
  |  |--@sites_INBLR01:
  |  |  |--3850-SWA01-1
  |--@regions_EMEA:
  |  |--@sites_CHZRH04:
  |--@tags_uat:
  |  |--3850-SWA01-1
  |--@ungrouped:

Yannis100 added 24 commits Aug 6, 2019
Update netbox.py
Add slugify parameter
Add use_slugs
ToDo : add vlan getters per site+roles of vlan (tags ?)
Add interface getter
Modify region subgrouping to add sites as children
Update netbox.py
Region grouping almost ok
Update netbox.py
Sites as region children ok, but hosts are included in regions too for now
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Aug 15, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/plugins/inventory/netbox.py:312:161: E501 line too long (188 > 160 characters)

click here for bot help

@ansibot

This comment has been minimized.

@ansibot ansibot removed the ci_verified label Aug 19, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Aug 19, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/plugins/inventory/netbox.py:312:161: E501 line too long (188 > 160 characters)

click here for bot help

@ansibot ansibot added the ci_verified label Aug 19, 2019

Yannis100 added 3 commits Aug 19, 2019
Add ip to interfaces when relevant
Quite slow even for few devices
@Yannis100

This comment has been minimized.

Copy link
Contributor Author

commented Sep 5, 2019

I have to include #59028 and #59662 changes
Let me know if you have any interest in my changes to be implemented, there are still some logics to be enhanced in my code (slug where missing, etc.)
I was wondering why values in vars like config_context, sites, manufacturers and so on, were contained in [] brackets; they can have only 1 value and we have to add [0] every time we want to access them. I know that changing this means a lot of people will have to adapt their templates/playbooks but I don't get why it was done like this in the first place.

I added virtual-chassis check (to only gather single device or master of stacks) in my local version of the plugin, I'll commit it too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.