@@ -300,8 +300,8 @@ def main():
300
300
host_port = dict (default = '27017' ),
301
301
host_type = dict (default = 'replica' , choices = ['replica' ,'arbiter' ]),
302
302
ssl = dict (default = False ),
303
- build_indexes = dict (type = 'bool' , choices = BOOLEANS , default = 'yes' ),
304
- hidden = dict (type = 'bool' , choices = BOOLEANS , default = 'no' ),
303
+ build_indexes = dict (type = 'bool' , default = 'yes' ),
304
+ hidden = dict (type = 'bool' , default = 'no' ),
305
305
priority = dict (default = '1.0' ),
306
306
slave_delay = dict (type = 'int' , default = '0' ),
307
307
votes = dict (type = 'int' , default = '1' ),
@@ -322,6 +322,7 @@ def main():
322
322
host_type = module .params ['host_type' ]
323
323
ssl = module .params ['ssl' ]
324
324
state = module .params ['state' ]
325
+ priority = float (module .params ['priority' ])
325
326
326
327
replica_set_created = False
327
328
@@ -340,7 +341,9 @@ def main():
340
341
client = MongoClient (login_host , int (login_port ), ssl = ssl )
341
342
authenticate (client , login_user , login_password )
342
343
if state == 'present' :
343
- config = { '_id' : "{0}" .format (replica_set ), 'members' : [{ '_id' : 0 , 'host' : "{0}:{1}" .format (host_name , host_port )}] }
344
+ new_host = { '_id' : 0 , 'host' : "{0}:{1}" .format (host_name , host_port ) }
345
+ if priority != 1.0 : new_host ['priority' ] = priority
346
+ config = { '_id' : "{0}" .format (replica_set ), 'members' : [new_host ] }
344
347
client ['admin' ].command ('replSetInitiate' , config )
345
348
wait_for_ok_and_master (module , client )
346
349
replica_set_created = True
0 commit comments