From 6ef06fbb206a75787616b45d28307ca9396f6ec2 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Wed, 11 Jul 2018 11:21:31 +0300 Subject: [PATCH] Report ansible errors in json file for standalone Change-Id: Ia40e2144d23bfa239931180e424e142c0008e6d9 Signed-off-by: Bogdan Dobrelya --- lower-constraints.txt | 2 +- requirements.txt | 2 +- tripleoclient/v1/tripleo_deploy.py | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index ec1457b05..f2604576b 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -146,7 +146,7 @@ testscenarios===0.4 testtools==2.2.0 tooz==1.58.0 traceback2==1.4.0 -tripleo-common==9.0.1 +tripleo-common==9.1.0 ujson==1.35 unittest2==1.1.0 vine==1.1.4 diff --git a/requirements.txt b/requirements.txt index 3013cd0d2..395cdf0e7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,5 +16,5 @@ simplejson>=3.5.1 # MIT six>=1.10.0 # MIT osc-lib>=1.8.0 # Apache-2.0 websocket-client>=0.44.0 # LGPLv2+ -tripleo-common>=9.0.1 # Apache-2.0 +tripleo-common>=9.1.0 # Apache-2.0 cryptography>=2.1 # BSD/Apache-2.0 diff --git a/tripleoclient/v1/tripleo_deploy.py b/tripleoclient/v1/tripleo_deploy.py index 86e36f194..cf040898a 100644 --- a/tripleoclient/v1/tripleo_deploy.py +++ b/tripleoclient/v1/tripleo_deploy.py @@ -15,6 +15,7 @@ from __future__ import print_function import argparse +import json import logging import netaddr import os @@ -40,6 +41,7 @@ from tripleoclient import exceptions from tripleoclient import heat_launcher from tripleoclient import utils +from tripleo_common import constants as tc_constants from tripleo_common.image import kolla_builder from tripleo_common.utils import passwords as password_utils @@ -937,6 +939,25 @@ class Deploy(command.Command): target = hiera_override_file return target + def _dump_ansible_errors(self, f, name): + if not os.path.isfile(f): + return + + failures = None + with open(f, 'r') as ff: + try: + failures = json.load(ff) + except Exception: + self.log.error( + _('Could not read ansible errors from file %s') % f) + + if not failures or not failures.get(name, {}): + return + + self.log.error(_('** Found ansible errors for %s deployment! **') % + name) + self.log.error(json.dumps(failures.get(name, {}), indent=1)) + def _standalone_deploy(self, parsed_args): if not parsed_args.local_ip: msg = _('Please set --local-ip to the correct ' @@ -1051,6 +1072,10 @@ class Deploy(command.Command): self._kill_heat(parsed_args) tar_filename = \ self._create_install_artifact(parsed_args.deployment_user) + self._dump_ansible_errors( + os.path.join(ansible_dir, + tc_constants.ANSIBLE_ERRORS_FILE), + parsed_args.stack) self._cleanup_working_dirs( cleanup=parsed_args.cleanup, user=parsed_args.deployment_user