From 5e84782b9c9b0695a0cda788a12a35953a7f313f Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Tue, 5 Feb 2019 17:07:33 -0500 Subject: [PATCH] provide a better ansible-inventory fallback error message old ansibles see: https://github.com/ansible/awx/issues/3139 --- awx/main/management/commands/inventory_import.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/awx/main/management/commands/inventory_import.py b/awx/main/management/commands/inventory_import.py index bd9c8001ee..e8c9494831 100644 --- a/awx/main/management/commands/inventory_import.py +++ b/awx/main/management/commands/inventory_import.py @@ -109,6 +109,17 @@ class AnsibleInventoryLoader(object): venv_exe = os.path.join(self.venv_path, 'bin', 'ansible-inventory') if os.path.exists(venv_exe): return venv_exe + elif os.path.exists( + os.path.join(self.venv_path, 'bin', 'ansible') + ): + # if bin/ansible exists but bin/ansible-inventory doesn't, it's + # probably a really old version of ansible that doesn't support + # ansible-inventory + raise RuntimeError( + "{} does not exist (please upgrade to ansible >= 2.4)".format( + venv_exe + ) + ) return shutil.which('ansible-inventory') def get_base_args(self):