Skip to content

Instantly share code, notes, and snippets.

@alexmuller
Last active September 30, 2015 09:55
Show Gist options
  • Save alexmuller/6ce97c6a1d4d2f8f0ce8 to your computer and use it in GitHub Desktop.
Save alexmuller/6ce97c6a1d4d2f8f0ce8 to your computer and use it in GitHub Desktop.
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)
}
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