summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorSamuel Munilla <smunilla@redhat.com>2015-12-08 14:56:37 -0500
committerSamuel Munilla <smunilla@redhat.com>2015-12-08 14:59:17 -0500
commitb69a8724b38583a808f99c73cfed2d635353bf4c (patch)
treeb3e3ad01b0e6568429b35a369fbc9cc1f00139b2 /utils
parenta3e601b2abd4e64d983bf7bfd70637b7f06b10d2 (diff)
downloadopenshift-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.py12
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