Add std_error output to error log in tripleo-ansible-inventory.

The standard output was missing in one of the error logs
inside tripleo-ansible-inventory. This made it pretty
hard to debug when ansible-playbook failed due that
inventory script error.
This patch also formats a little the error message to give
some more info about the issue.

Related-Bug: #1768011
Change-Id: Ib240a4626bedb4d2a2d0b51caf696b3728fb7fb0
This commit is contained in:
Jose Luis Franco Arza 2018-05-18 12:04:26 +02:00
parent ce2702005d
commit 9bace992f3
1 changed files with 6 additions and 5 deletions

View File

@ -139,10 +139,11 @@ def main():
plan_name=configs.stack or configs.plan)
if inventory.get_overcloud_environment() == {}:
print("Error, the environment data can not "
"be empty '{}', please check that the --stack "
"or the --plan options are configured correctly "
"and if they correspond to the stack name.")
print("ERROR: The environment data can not "
"be empty '{{}}', please check that the --stack "
"or --plan options are configured correctly "
"and the stack {} exists".format(configs.stack or configs.plan)
,file=sys.stderr)
sys.exit(1)
if configs.list:
@ -150,7 +151,7 @@ def main():
inventory_list = inventory.list()
print(json.dumps(inventory_list))
except Exception as e:
print("Error creating inventory: {}".format(e),
print("ERROR: Error creating inventory: {}".format(e),
file=sys.stderr)
if configs.debug:
traceback.print_exc()