From 26d11b2fb74ff38805b159e640b97413a2510e8f Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Thu, 25 Feb 2016 11:23:00 -0500 Subject: [PATCH 1/2] Default play names to the hosts the play was run against Fixes #1030 --- awx/plugins/callback/job_event_callback.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/awx/plugins/callback/job_event_callback.py b/awx/plugins/callback/job_event_callback.py index eb2f3e9d6e..b43fa4c998 100644 --- a/awx/plugins/callback/job_event_callback.py +++ b/awx/plugins/callback/job_event_callback.py @@ -463,6 +463,10 @@ class JobCallbackModule(BaseCallbackModule): def v2_playbook_on_play_start(self, play): setattr(self, 'play', play) + # Ansible 2.0.0.2 doesn't default .name to hosts like it did in 1.9.4, + # though that default will likely return in a future version of Ansible. + if not hasattr(play, 'name') or play.name == '': + play.name = ', '.join(play.hosts) self._log_event('playbook_on_play_start', name=play.name, pattern=play.hosts) From 5dc164bb762879689daaa06fc4ac76cb77eb1948 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Thu, 25 Feb 2016 11:38:09 -0500 Subject: [PATCH 2/2] Handle both string and list hosts in our hosts->name conversion Base our play.name fix off of what Ansible will be doing in the next release: https://github.com/ansible/ansible/commit/e2d2798a4238d95590777e8d41b9b28f324bd91d --- awx/plugins/callback/job_event_callback.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/awx/plugins/callback/job_event_callback.py b/awx/plugins/callback/job_event_callback.py index b43fa4c998..5108f97c31 100644 --- a/awx/plugins/callback/job_event_callback.py +++ b/awx/plugins/callback/job_event_callback.py @@ -465,8 +465,11 @@ class JobCallbackModule(BaseCallbackModule): setattr(self, 'play', play) # Ansible 2.0.0.2 doesn't default .name to hosts like it did in 1.9.4, # though that default will likely return in a future version of Ansible. - if not hasattr(play, 'name') or play.name == '': - play.name = ', '.join(play.hosts) + if (not hasattr(play, 'name') or not play.name) and hasattr(play, 'hosts'): + if isinstance(play.hosts, list): + play.name = ','.join(play.hosts) + else: + play.name = play.hosts self._log_event('playbook_on_play_start', name=play.name, pattern=play.hosts)