diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 32a6557a89..a9123659dd 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1653,6 +1653,8 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions, JobNotificationMixin, organization_groups = [] if self.inventory_source.inventory is not None: inventory_groups = [x for x in self.inventory_source.inventory.instance_groups.all()] + else: + inventory_groups = [] selected_groups = inventory_groups + organization_groups if not selected_groups: return self.global_instance_groups diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 6f99acad08..35322553b8 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1998,6 +1998,9 @@ class RunInventoryUpdate(BaseTask): inventory_source = inventory_update.inventory_source inventory = inventory_source.inventory + if inventory is None: + raise RuntimeError('Inventory Source is not associated with an Inventory.') + # Piece together the initial command to run via. the shell. args = ['awx-manage', 'inventory_import'] args.extend(['--inventory-id', str(inventory.pk)])