Created
March 27, 2012 21:41
-
-
Save bcarpio/2220611 to your computer and use it in GitHub Desktop.
Fabric MongoDB Rolling Upgrade Task
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
@task | |
def rolling_upgrade(hostname): | |
""" Rolling upgrade of mongodb """ | |
users.root() | |
conn = Connection('%s'%(hostname)) | |
db = conn.admin | |
replSet = db.command("replSetGetStatus") | |
for secondary in replSet['members']: | |
stateStr = str(secondary['stateStr']) | |
host = str(secondary['name']) | |
health = str(secondary['health']) | |
if stateStr == 'SECONDARY': | |
execute(puppet.puppetd_test, host='%s' %(host)) | |
execute(mongod.restart, host='%s' %(host)) | |
while health != '1.0': | |
time.sleep(10) | |
print health | |
for primary in replSet['members']: | |
stateStr = str(primary['stateStr']) | |
host = str(primary['name']) | |
health = str(primary['health']) | |
if stateStr == 'PRIMARY': | |
execute(mongod.stop, host='%s' %(host)) | |
execute(puppet.puppetd_test, host='%s' %(host)) | |
execute(mongod.start, host='%s' %(host)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment