1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

netbox: inventory: Fix VMs do not have device_roles, but instead use roles (#50761)

This makes sure that roles show up as device_role when using VMs
This commit is contained in:
Karsten Jakobsen 2019-02-11 06:40:24 +01:00 committed by René Moser
parent 7b84c0ee80
commit e6ae688e47

View file

@ -252,7 +252,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
def extract_device_role(self, host):
try:
return [self.device_roles_lookup[host["device_role"]["id"]]]
if 'device_role' in host:
return [self.device_roles_lookup[host["device_role"]["id"]]]
elif 'role' in host:
return [self.device_roles_lookup[host["role"]["id"]]]
except Exception:
return