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: I830d64d6089f869dc5a0e3d4fe346e6480884793
This commit is contained in:
Tobias Henkel 2018-06-12 10:29:37 +02:00
parent d94a0d6f06
commit 3512a5608c
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
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