Fix command tasks with free play strategy

When using the free play strategy the command and shell tasks fail
logging due to an undefined variable. Fix that and add tests for it.

Change-Id: Ib869b12c54201b59f3de852b502ff62183db7266
This commit is contained in:
Tobias Henkel 2018-06-12 10:29:37 +02:00 committed by James E. Blair
parent bfcdff9118
commit 1310aa592b
3 changed files with 13 additions and 0 deletions

View File

@ -38,3 +38,11 @@
handlers:
- name: test handler
command: echo "This is a handler"
- hosts: all
strategy: free
tasks:
- name: Command task 1 within free strategy
command: echo "First free task"
- name: Command task 2 within free strategy
command: echo "Second free task"

View File

@ -96,6 +96,8 @@ class TestZuulStream(AnsibleZuulTestCase):
self.assertLogLine('TASK \[Show contents of second file\]', text)
self.assertLogLine('controller \| command test two', text)
self.assertLogLine('controller \| This is a handler', text)
self.assertLogLine('controller \| First free task', text)
self.assertLogLine('controller \| Second free task', text)
self.assertLogLine(
'controller \| ok: Runtime: \d:\d\d:\d\d\.\d\d\d\d\d\d', text)
self.assertLogLine('PLAY RECAP', text)

View File

@ -210,6 +210,9 @@ class CallbackModule(default.CallbackModule):
if self._play.strategy != 'free':
task_name = self._print_task_banner(task)
else:
task_name = task.get_name().strip()
if task.action in ('command', 'shell'):
log_id = uuid.uuid4().hex
task.args['zuul_log_id'] = log_id