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
This commit is contained in:
parent
29965cc9e6
commit
c6a6769dc3
|
@ -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…
Reference in New Issue