Fix KeysView object does not support indexing
The KeysView we get from the hostvars is not indexable and throws an
error [1] when trying to access via an index. This can be fixed by
using an iterator and getting one item.
[1] Log:
[WARNING]: Failure using method (v2_playbook_on_play_start) in callback plugin
(<ansible.plugins.callback.zuul_stream.CallbackModule object at
0x7f5d41b73b70>): 'KeysView' object does not support indexing
Change-Id: I0c95b55a3b26856e9d101db95682efa0e0694523
diff --git a/zuul/ansible/callback/zuul_stream.py b/zuul/ansible/callback/zuul_stream.py
index c4473da..de83248 100644
--- a/zuul/ansible/callback/zuul_stream.py
+++ b/zuul/ansible/callback/zuul_stream.py
@@ -161,7 +161,7 @@
# Get the hostvars from just one host - the vars we're looking for will
# be identical on all of them
hostvars = self._play._variable_manager._hostvars
- a_host = hostvars.keys()[0]
+ a_host = next(iter(hostvars.keys()))
self.phase = hostvars[a_host]['zuul_execution_phase']
if self.phase != 'run':
self.phase = '{phase}-{index}'.format(