From b69a8724b38583a808f99c73cfed2d635353bf4c Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Tue, 8 Dec 2015 14:56:37 -0500 Subject: atomic-openshift-installer: Error handling on yaml loading This addresses the stack trace that has been plaguing recent demos. In the case of an error with callback_facts.yaml the program output is much clearer and a course of action is suggested. --- utils/src/ooinstall/openshift_ansible.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'utils/src/ooinstall/openshift_ansible.py') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 17196a813..fd2cd7fbd 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -157,9 +157,15 @@ def load_system_facts(inventory_file, os_facts_path, env_vars, verbose=False): status = subprocess.call(args, env=env_vars, stdout=FNULL) if not status == 0: return [], 1 - callback_facts_file = open(CFG.settings['ansible_callback_facts_yaml'], 'r') - callback_facts = yaml.load(callback_facts_file) - callback_facts_file.close() + + with open(CFG.settings['ansible_callback_facts_yaml'], 'r') as callback_facts_file: + try: + callback_facts = yaml.safe_load(callback_facts_file) + except yaml.YAMLError, exc: + print "Error in {}".format(CFG.settings['ansible_callback_facts_yaml']), exc + print "Try deleting and rerunning the atomic-openshift-installer" + sys.exit(1) + return callback_facts, 0 -- cgit v1.2.3