diff options
author | Samuel Munilla <smunilla@redhat.com> | 2015-12-08 14:56:37 -0500 |
---|---|---|
committer | Samuel Munilla <smunilla@redhat.com> | 2015-12-08 14:59:17 -0500 |
commit | b69a8724b38583a808f99c73cfed2d635353bf4c (patch) | |
tree | b3e3ad01b0e6568429b35a369fbc9cc1f00139b2 /utils | |
parent | a3e601b2abd4e64d983bf7bfd70637b7f06b10d2 (diff) | |
download | openshift-b69a8724b38583a808f99c73cfed2d635353bf4c.tar.gz openshift-b69a8724b38583a808f99c73cfed2d635353bf4c.tar.bz2 openshift-b69a8724b38583a808f99c73cfed2d635353bf4c.tar.xz openshift-b69a8724b38583a808f99c73cfed2d635353bf4c.zip |
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.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/src/ooinstall/openshift_ansible.py | 12 |
1 files changed, 9 insertions, 3 deletions
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 |