def _handle_failure(self, command, status): failures = None with open(self.failure_log.name, 'r') as fail_log: try: failures = yaml.safe_load(fail_log) except yaml.parser.ParserError: log.error("Failed to parse ansible failure log: {0}".format( self.failure_log.name, )) failures = fail_log if failures: self._archive_failures() raise AnsibleFailedError(failures) raise CommandFailedError(command, status)
def _handle_failure(self, command, status): self._set_status('dead') failures = None with open(self.failure_log.name, 'r') as fail_log: try: failures = yaml.safe_load(fail_log) except yaml.YAMLError as e: log.error( "Failed to parse ansible failure log: {0} ({1})".format( self.failure_log.name, e)) failures = fail_log.read().replace('\n', '') if failures: self._archive_failures() raise AnsibleFailedError(failures) raise CommandFailedError(command, status)