From: Andrew Schoen Date: Tue, 18 Aug 2015 15:09:00 +0000 (-0500) Subject: task.ansible: archive the ansible log even if parsing fails X-Git-Tag: 1.1.0~845^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=df6677ecf35e43c6a020de61268ba05a2c941765;p=teuthology.git task.ansible: archive the ansible log even if parsing fails This fixes a bug where if we fail to parse the ansible log it is never archived. Signed-off-by: Andrew Schoen --- diff --git a/teuthology/task/ansible.py b/teuthology/task/ansible.py index b94efecd..7f6efaa9 100644 --- a/teuthology/task/ansible.py +++ b/teuthology/task/ansible.py @@ -272,23 +272,26 @@ class Ansible(Task): self.failure_log.name, ) ) + # archive the log anyway so we can see what tripped up + # the yaml parsing + self._archive_failures() if failures: - if self.ctx.archive: - self._archive_failures() + self._archive_failures() raise AnsibleFailedError(failures) raise CommandFailedError(command, status) def _archive_failures(self): - archive_path = "{0}/ansible_failures.yaml".format(self.ctx.archive) - log.info("Archiving ansible failure log at: {0}".format( - archive_path, - )) - shutil.move( - self.failure_log.name, - archive_path - ) - os.chmod(archive_path, 0664) + if self.ctx.archive: + archive_path = "{0}/ansible_failures.yaml".format(self.ctx.archive) + log.info("Archiving ansible failure log at: {0}".format( + archive_path, + )) + shutil.move( + self.failure_log.name, + archive_path + ) + os.chmod(archive_path, 0664) def _build_args(self): """