ansible_modules icon indicating copy to clipboard operation
ansible_modules copied to clipboard

[Feature]: Add ability to retrieve virtual cluster members from netbox inventory

Open kcbark opened this issue 5 years ago • 6 comments

ISSUE TYPE
  • Feature Idea
SOFTWARE VERSIONS
Ansible:

2.9.13

Netbox:

2.9.7

Collection:

v1.0.0

SUMMARY

We need a way to populate virtual chassis members properties via playbook. But since virtual chassi members are excluded by the inventory we are unable to.

STEPS TO REPRODUCE

ansible-inventory -i inventory/netbox.yml --list does not list virtual chassi members.

EXPECTED RESULTS

Add a toggle for including virtual chassis when asking for devices from netbox as inventory.

ACTUAL RESULTS

Virtual chassi members are not included when asking for devices from netbox as inventory.

kcbark avatar Oct 19 '20 07:10 kcbark

I gave this a try myself. @kcbark, could you try it out to see if this is what you were thinking? See here for the code: https://github.com/nahun/ansible_modules/blob/vc-members/plugins/inventory/nb_inventory.py.

Add the virtual_chassis_members: true option to your inventory file.

If its good, I'll fix the tests and create a PR.

nahun avatar Dec 09 '20 23:12 nahun

Nice!

I almost forgot about this. I had a local patch as well but forgot to publish it.

I will test and get back to you.

Thanks!

kcbark avatar Dec 10 '20 17:12 kcbark

Any update on this from either of y'all?

And Merry Christmas by the way! Obviously I'm sure y'all are busy with family stuff, but once the holidays are over with, let me know how this is going for y'all.

FragmentedPacket avatar Dec 23 '20 06:12 FragmentedPacket

Happy Holidays!

I need to rebase my branch and get the pieces for testing added. I'll create a PR when ready.

Just FYI, the way I'm implementing this is another data lookup for all devices that are VC members (virtual_chassis_member=true filter). Since the user might be filtering the devices list, we can't depend on that existing lookup to get all VC members.

nahun avatar Dec 23 '20 16:12 nahun

I'd make sure to only do that extra call if query_filters is specified to address your point of it being filtered and missing things.

Thanks for your incoming work on this!

FragmentedPacket avatar Dec 26 '20 04:12 FragmentedPacket

I stumbled upon this issue when I setup some existing firewalls in netbox to join a virtual cluster. IE firewall-a & firewall-b are now members of the firewall cluster.

I would normally handle these devices as 1 given normal cluster behavior, BUT in terms of backup or reboot workflows, its important that the netbox inventory handle these as 2 different devices. I mean the API returns them as 2 different devices. I believe that overall virtual_clusters should be handled better.

IE I think for completeness the following flags should be supported(some already are):

  • virtual_chassis_name - As already supported, returns just the master name and not the physical chassis names
  • virtual_chassis_members - As per this thread provide chassis members when combined with virtual_chassis_name is set
  • virtual_chassis_non_masters - Brand new feature, assuming the virtual_chassis_name & virtual_chassis_members are not set, returns the devices as you would see in a normal API query, IE none of this only returning the master device would continue.

ryanmerolle avatar Jul 01 '21 19:07 ryanmerolle