From 6d4dd9f43d4b5dc747bfff5700d2e7b6a562ba9c Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Wed, 3 Jun 2015 15:11:01 -0700 Subject: Issue 119 - Add support for ~/.openshift-ansible * Allow user to override: validate_cluster_ids, cluster_ids, providers --- bin/cluster | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'bin/cluster') diff --git a/bin/cluster b/bin/cluster index 2a6cb4b58..0a6ee7ec4 100755 --- a/bin/cluster +++ b/bin/cluster @@ -184,21 +184,43 @@ 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 = production,stage,integration + providers = gce,aws,libvirt """ + environment = ConfigParser.SafeConfigParser({ + 'cluster_ids': 'prod,stg,int', + 'validate_cluster_ids': 'False', + 'providers': 'gce,aws,libvirt', + }) + + 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)') -- cgit v1.2.3 From 73a3673b55e84c255fc13a350a7a6989e6df4bf3 Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Thu, 4 Jun 2015 09:15:44 -0700 Subject: * Update defaults and examples to track core concepts guide --- bin/cluster | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin/cluster') diff --git a/bin/cluster b/bin/cluster index 0a6ee7ec4..bf8198de9 100755 --- a/bin/cluster +++ b/bin/cluster @@ -188,12 +188,12 @@ if __name__ == '__main__': Reads ~/.openshift-ansible for default configuration items [DEFAULT] validate_cluster_ids = False - cluster_ids = production,stage,integration + cluster_ids = marketing,sales providers = gce,aws,libvirt """ environment = ConfigParser.SafeConfigParser({ - 'cluster_ids': 'prod,stg,int', + 'cluster_ids': 'marketing,sales', 'validate_cluster_ids': 'False', 'providers': 'gce,aws,libvirt', }) -- cgit v1.2.3