summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cluster37
1 files changed, 34 insertions, 3 deletions
diff --git a/bin/cluster b/bin/cluster
index 2a6cb4b58..2ea389523 100755
--- a/bin/cluster
+++ b/bin/cluster
@@ -143,6 +143,8 @@ class Cluster(object):
inventory = '-i inventory/aws/hosts'
elif 'libvirt' == provider:
inventory = '-i inventory/libvirt/hosts'
+ elif 'openstack' == provider:
+ inventory = '-i inventory/openstack/hosts'
else:
# this code should never be reached
raise ValueError("invalid PROVIDER {}".format(provider))
@@ -163,6 +165,11 @@ class Cluster(object):
if args.verbose > 0:
verbose = '-{}'.format('v' * args.verbose)
+ if args.option:
+ for opt in args.option:
+ k, v = opt.split('=', 1)
+ env['opt_'+k] = v
+
ansible_env = '-e \'{}\''.format(
' '.join(['%s=%s' % (key, value) for (key, value) in env.items()])
)
@@ -184,24 +191,48 @@ class Cluster(object):
if __name__ == '__main__':
"""
User command to invoke ansible playbooks in a "known" environment
+
+ Reads ~/.openshift-ansible for default configuration items
+ [DEFAULT]
+ validate_cluster_ids = False
+ cluster_ids = marketing,sales
+ providers = gce,aws,libvirt,openstack
"""
+ environment = ConfigParser.SafeConfigParser({
+ 'cluster_ids': 'marketing,sales',
+ 'validate_cluster_ids': 'False',
+ 'providers': 'gce,aws,libvirt,openstack',
+ })
+
+ path = os.path.expanduser("~/.openshift-ansible")
+ if os.path.isfile(path):
+ environment.read(path)
+
cluster = Cluster()
- providers = ['gce', 'aws', 'libvirt']
parser = argparse.ArgumentParser(
description='Python wrapper to ensure proper environment for OpenShift ansible playbooks',
)
parser.add_argument('-v', '--verbose', action='count',
help='Multiple -v options increase the verbosity')
- parser.add_argument('--version', action='version', version='%(prog)s 0.2')
+ parser.add_argument('--version', action='version', version='%(prog)s 0.3')
meta_parser = argparse.ArgumentParser(add_help=False)
+ providers = environment.get('DEFAULT', 'providers').split(',')
meta_parser.add_argument('provider', choices=providers, help='provider')
- meta_parser.add_argument('cluster_id', help='prefix for cluster VM names')
+
+ if environment.get('DEFAULT', 'validate_cluster_ids').lower() in ("yes", "true", "1"):
+ meta_parser.add_argument('cluster_id', choices=environment.get('DEFAULT', 'cluster_ids').split(','),
+ help='prefix for cluster VM names')
+ else:
+ meta_parser.add_argument('cluster_id', help='prefix for cluster VM names')
+
meta_parser.add_argument('-t', '--deployment-type',
choices=['origin', 'online', 'enterprise'],
help='Deployment type. (default: origin)')
+ meta_parser.add_argument('-o', '--option', action='append',
+ help='options')
action_parser = parser.add_subparsers(dest='action', title='actions',
description='Choose from valid actions')