Browse Source

Handle non-syntax errors from Ansible

If a playbook refers to a role that does not exist, Ansible will output
"ERROR!" followed by an error. Such as:

  ERROR! the role 'add-launchpadlib-credentials' was not found in ...

  The error appears to have been in '...':
  line 5, column 7, but may be elsewhere in the file depending on the exact syntax problem.

  The offending line appears to be:

    - add-sshkey
    - add-launchpadlib-credentials
      ^
  here

Simply adding the error to the build log will help people track down the
issue.

Change-Id: If49c50c16844243cbbade4b7fef7a43df4107d43
changes/19/510219/1
Monty Taylor 5 years ago
parent
commit
c6a6769dc3
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
  1. 7
      zuul/executor/server.py

7
zuul/executor/server.py

@ -1697,6 +1697,13 @@ class AnsibleJob(object):
elif ret == -9:
# Received abort request.
return (self.RESULT_ABORTED, None)
elif ret == 1:
if syntax_buffer[0].startswith('ERROR!'):
with open(self.jobdir.job_output_file, 'a') as job_output:
for line in syntax_buffer:
job_output.write("{now} | {line}\n".format(
now=datetime.datetime.now(),
line=line.decode('utf-8').rstrip()))
elif ret == 4:
# Ansible could not parse the yaml.
self.log.debug("Ansible parse error")

Loading…
Cancel
Save