From eeefd19ad360e44b5bd5965e33d97e0670a37083 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Mon, 1 Nov 2021 10:49:06 -0400 Subject: [PATCH 1/2] Fail with specific error message if protected image is not available locally --- awx/main/management/commands/inventory_import.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index a3c6acdab3..a4d2da7680 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -78,6 +78,16 @@ class AnsibleInventoryLoader(object): bargs.extend(['-e', '{0}={1}'.format(key, value)]) ee = get_default_execution_environment() + if ee.credential: + process = subprocess.run(['podman', 'image', 'exists', ee.image], capture_output=True) + if process.returncode != 0: + logger.warn( + f'The default execution environment (id={ee.id}, name={ee.name}, image={ee.image}) is not available on this node. ' + 'The image needs to be available locally before using this command, due to registry authentication. ' + 'To pull this image, either run a job on this node or manually pull the image.' + ) + sys.exit(1) + bargs.extend([ee.image]) bargs.extend(['ansible-inventory', '-i', self.source]) From f2aaa6778cf89a0d5c5b4efeff8550edb27f28a8 Mon Sep 17 00:00:00 2001 From: nixocio Date: Wed, 5 Jan 2022 11:32:59 -0500 Subject: [PATCH 2/2] Add warning message for K8S deployment Add warning message for K8S deployment --- awx/main/management/commands/inventory_import.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index a4d2da7680..0854784f10 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -78,6 +78,10 @@ class AnsibleInventoryLoader(object): bargs.extend(['-e', '{0}={1}'.format(key, value)]) ee = get_default_execution_environment() + if settings.IS_K8S: + logger.warn('This command is not able to run on kubernetes-based deployment. This action should be done using the API.') + sys.exit(1) + if ee.credential: process = subprocess.run(['podman', 'image', 'exists', ee.image], capture_output=True) if process.returncode != 0: