diff --git a/lib/ansible/plugins/inventory/netbox.py b/lib/ansible/plugins/inventory/netbox.py index b6aae06dba..fb2feee702 100644 --- a/lib/ansible/plugins/inventory/netbox.py +++ b/lib/ansible/plugins/inventory/netbox.py @@ -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