This repository was archived by the owner on Feb 14, 2022. It is now read-only.
File tree 2 files changed +26
-7
lines changed
2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "cluster0" : {
3
+ "uri" : " http://localhost:8080" ,
4
+ "name" : " cluster0" ,
5
+ "ambari_user" : " admin" ,
6
+ "ambari_pass" : " admin0"
7
+ },
8
+ "cluster1" : {
9
+ "uri" : " https://localhost.localdomain:8444" ,
10
+ "name" : " cluster1" ,
11
+ "ambari_user" : " admin" ,
12
+ "ambari_pass" : " admin1"
13
+ }
14
+ }
Original file line number Diff line number Diff line change 14
14
class AmbariInventory (object ):
15
15
16
16
def __init__ (self ):
17
- # TODO: load settings from a config file
18
- self .cluster_name = 'sandbox'
19
- self .uri = 'http://localhost:8080'
20
- self .ambari_user = 'admin'
21
- self .ambari_pass = 'admin'
17
+ # Get the cluster name from the OS environment variable AMBARI_CLUSTER_NAME
18
+ self .cluster_name = os .environ ['AMBARI_CLUSTER_NAME' ]
19
+
20
+ # Load configuration file
21
+ with open ('ansible-inventory-config.json' ) as json_data_file :
22
+ config = json .load (json_data_file )
23
+
24
+ self .uri = config [self .cluster_name ]['uri' ]
25
+ self .ambari_user = config [self .cluster_name ]['ambari_user' ]
26
+ self .ambari_pass = config [self .cluster_name ]['ambari_pass' ]
22
27
23
28
args = self .process_args ()
24
- service_list = self .get_service_list ()
25
- # service_list = json.load(open('ansible-inventory-sample.json'))
29
+ # service_list = self.get_service_list()
30
+ service_list = json .load (open ('ansible-inventory-sample.json' ))
26
31
27
32
ambari_inv = self .generate_ambari_inventory (service_list )
28
33
You can’t perform that action at this time.
0 commit comments