Last active
September 30, 2015 09:55
-
-
Save alexmuller/6ce97c6a1d4d2f8f0ce8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var expectedReplicaSetMembers = [ | |
{ | |
_id: 0, | |
host: 'api-mongo-1:27017' | |
}, | |
{ | |
_id: 1, | |
host: 'api-mongo-2:27017' | |
}, | |
{ | |
_id: 2, | |
host: 'api-mongo-3:27017' | |
} | |
] | |
var actualReplicaSetConfig = rs.conf() | |
var replicaSetChangesMade = false | |
for (var i = 0; i < expectedReplicaSetMembers.length; i++) { | |
printjson(expectedReplicaSetMembers[i]); | |
expectedMember = expectedReplicaSetMembers[i]; | |
thisMember = actualReplicaSetConfig.members.filter(function (value) { | |
return value.host === expectedMember.host | |
})[0]; | |
printjson(thisMember); | |
if expectedMember.priority { | |
if expectedMember.priority !== thisMember.priority | |
} | |
} | |
if replicaSetChangesMade { | |
rs.reconfig(actualReplicaSetConfig) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var expectedReplicaSetMembers = [ | |
<% for thing in things %> | |
{ | |
_id: 0, | |
host: '$HOSTNAME:27017' | |
<% if priority != 1 %> | |
priority: $PRIORITY | |
<% endif %> | |
}, | |
<% endfor %> | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment