From 946d643795b0df2989e0dbacfb04e82ded755523 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Wed, 26 Feb 2020 08:45:08 -0500 Subject: [PATCH] cli: make launch with --monitor return code respect the final job status see: https://github.com/ansible/awx/issues/5920 see: https://github.com/ansible/awx/issues/6079 --- awxkit/awxkit/cli/client.py | 2 ++ awxkit/awxkit/cli/custom.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/awxkit/awxkit/cli/client.py b/awxkit/awxkit/cli/client.py index 6ccef0f12f..6a7c4c3f51 100755 --- a/awxkit/awxkit/cli/client.py +++ b/awxkit/awxkit/cli/client.py @@ -200,6 +200,8 @@ class CLI(object): ) if formatted: print(utils.to_str(formatted), file=self.stdout) + if hasattr(response, 'rc'): + raise SystemExit(response.rc) else: if six.PY3: self.parser.print_help() diff --git a/awxkit/awxkit/cli/custom.py b/awxkit/awxkit/cli/custom.py index 81a189169a..0f876579bc 100644 --- a/awxkit/awxkit/cli/custom.py +++ b/awxkit/awxkit/cli/custom.py @@ -90,6 +90,8 @@ class Launchable(object): ) if status: response.json['status'] = status + if status in ('failed', 'error'): + setattr(response, 'rc', 1) return response def perform(self, **kwargs):