Skip to content

Instantly share code, notes, and snippets.

@bcarpio
bcarpio / mikoomi-mongodb-plugin.php
Created March 11, 2012 15:42
Working mikoomi-mongodb-plugin.php
<?php
/**********************************************************************
Mikoomi MIT License
**********************************************************************
Copyright (c) 2011 by Jayesh Thakrar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@bcarpio
bcarpio / gist:2032220
Created March 13, 2012 22:27
Puppet Class Relationship Using New Relationship Syntax
manifests/site.pp:
import "classes/*.pp"
import "nodes/*.pp"
manifests/classes/base.pp
class base {
$role = regsubst($ec2_userdata, '.*role=(.*).*', '\1')
notify {"the role is: ${role}": }
Class['baseapps']<-Class['admin_users']
$ulimit = $::hostname ? {
boxtypeA => "10000",
boxtypeB => "20000",
default => "1024",
}
-- mongod.py ---
@task
def rolling_upgrade():
""" Rolling upgrade of mongodb """
execute(puppet.puppetd_test)
--- puppet.py ---
@bcarpio
bcarpio / fabric_mongodb_rolling_upgrade_.py
Created March 27, 2012 21:41
Fabric MongoDB Rolling Upgrade Task
@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'])
@task
def test(stable_pkgs_url):
run('echo "export PACKAGESITE=\'%s\'" >> ~/.zshenv' %(stable_pkgs_url))
@bcarpio
bcarpio / mongodb.rolling_upgrade.py
Created March 30, 2012 15:35
mongodb.rolling_upgrade Fabric Task
@task
def rolling_upgrade(hostname):
""" Rolling upgrade of mongodb """
users.root()
## Make initial connection to determine which member is the primary node
conn = Connection('%s'%(hostname))
db = conn.local
isMaster = db.command("isMaster")
primary = (isMaster['primary'])
primary = primary.replace(":27017","")
@bcarpio
bcarpio / __init__.py
Created March 30, 2012 15:48
__init__.py
from fabric.api import *
from fabric.operations import local,put
import paramiko
import socket
import subprocess
import os
import mongod
import puppet
def _is_host_up(host, port):
@bcarpio
bcarpio / mongodb.py
Created March 30, 2012 15:51
mongodb.py
from fabric.api import *
from fabric.operations import local,put
from fabric.colors import *
from pymongo import *
import sys
import difflib
import paramiko
import socket
import subprocess
import os
@bcarpio
bcarpio / puppet.py
Created March 30, 2012 15:53
puppet.py
from fabric.api import *
from fabric.operations import local,put
import paramiko
import socket
import subprocess
import os
@task
# @parallel
def puppetd_test():