summaryrefslogtreecommitdiffstats
path: root/bin/cluster
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2015-07-01 15:39:12 -0700
committerJhon Honce <jhonce@redhat.com>2015-07-01 15:39:12 -0700
commit6ae88062163562c8b67090c0522596a2c0c9fd51 (patch)
tree5e5dd9888780115a9879a9fa3b9ec5d77702dd13 /bin/cluster
parent6558d4b37ad7595fa2fc991650dca6285693bc67 (diff)
parent232ce80fc1088146a8bb28bd5cff8f53cf4991c8 (diff)
downloadopenshift-6ae88062163562c8b67090c0522596a2c0c9fd51.tar.gz
openshift-6ae88062163562c8b67090c0522596a2c0c9fd51.tar.bz2
openshift-6ae88062163562c8b67090c0522596a2c0c9fd51.tar.xz
openshift-6ae88062163562c8b67090c0522596a2c0c9fd51.zip
Merge pull request #317 from jwhonce/wip/improve_reporting
Infrastructure - Validate AWS environment before calling playbooks
Diffstat (limited to 'bin/cluster')
-rwxr-xr-xbin/cluster23
1 files changed, 18 insertions, 5 deletions
diff --git a/bin/cluster b/bin/cluster
index 2ea389523..cb8ff0439 100755
--- a/bin/cluster
+++ b/bin/cluster
@@ -3,8 +3,9 @@
import argparse
import ConfigParser
-import sys
import os
+import sys
+import traceback
class Cluster(object):
@@ -141,6 +142,11 @@ class Cluster(object):
os.environ[key] = config.get('ec2', key)
inventory = '-i inventory/aws/hosts'
+
+ missing = [key for key in ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'] if key not in os.environ]
+ if len(missing) > 0:
+ raise ValueError("PROVIDER aws requires {} environment variable(s). See README_AWS.md".format(missing))
+
elif 'libvirt' == provider:
inventory = '-i inventory/libvirt/hosts'
elif 'openstack' == provider:
@@ -168,7 +174,7 @@ class Cluster(object):
if args.option:
for opt in args.option:
k, v = opt.split('=', 1)
- env['opt_'+k] = v
+ env['opt_' + k] = v
ansible_env = '-e \'{}\''.format(
' '.join(['%s=%s' % (key, value) for (key, value) in env.items()])
@@ -290,7 +296,14 @@ if __name__ == '__main__':
sys.stderr.write('\nACTION [update] aborted by user!\n')
exit(1)
- status = args.func(args)
- if status != 0:
- sys.stderr.write("ACTION [{}] failed with exit status {}\n".format(args.action, status))
+ status = 1
+ try:
+ status = args.func(args)
+ if status != 0:
+ sys.stderr.write("ACTION [{}] failed with exit status {}\n".format(args.action, status))
+ except Exception, e:
+ if args.verbose:
+ traceback.print_exc(file=sys.stderr)
+ else:
+ sys.stderr.write("{}\n".format(e))
exit(status)