Created
October 3, 2011 11:33
-
-
Save doryokujin/1258927 to your computer and use it in GitHub Desktop.
manage rvm and gem using fabric
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
# -*- coding: utf-8 -*- | |
# | |
# install: http://morgangoose.com/blog/2011/01/06/using-the-parallel-branch-of-fabric/ | |
# document: http://docs.fabfile.org/en/1.2.0/index.html | |
# | |
import os | |
from fabric.api import * | |
from fabric.decorators import * | |
# | |
# env | |
# | |
env.hosts = [ | |
'delta1','delta2','delta3','delta4','delta5','delta6', | |
'delta11','delta12','delta13','delta14','delta15','delta16' | |
] | |
env.user = 'doryokujin' | |
env.password = '*****' | |
HOME_DIR="/home/doryokujin" | |
SHELL_RC=".zshrc" | |
RVM_DIR=os.path.join(HOME_DIR,".rvm") | |
RVM=os.path.join(RVM_DIR,"scripts/rvm") | |
GIT_RVM = "git://github.com/wayneeseguin/rvm.git" | |
@runs_parallel | |
def setup(rvm=True,ruby=True,rails=True): | |
prepare_install() | |
if rvm: | |
install_rvm() | |
if ruby: | |
install_ruby("head-ruby") | |
install_ruby("1.9.2") | |
default_ruby("1.9.2") | |
if rails: | |
install_rails("1.9.2","3.1.0") | |
def prepare_install(): | |
sudo("apt-get -y install git-core curl autoconf bison") | |
def install_rvm(): | |
with cd(HOME_DIR): | |
run("mkdir -p ~/.rvm/src && cd ~/.rvm/src && rm -rf ./rvm/ && git clone git://github.com/wayneeseguin/rvm.git && cd rvm && ./install") | |
run("echo 'if [[ -s %s ]] ; then source %s ; fi' >> %s"%(RVM_DIR,RVM, os.path.join(HOME_DIR,SHELL_RC))) | |
def install_ruby(version="head-ruby"): | |
with cd(HOME_DIR): | |
run("source %s && rvm install %s"%(RVM,version)) | |
def default_ruby(version="head-ruby"): | |
with cd(HOME_DIR): | |
run("source %s && rvm use %s --default"%(RVM,version)) | |
def install_rails(ruby_version="1.9.2",rails_version="3.1.0"): | |
with cd(HOME_DIR): | |
run("source %s && rvm use %s && gem install rails -v '%s'"%(RVM,ruby_version,rails_version)) | |
@runs_parallel | |
def gem(package,ruby_version="1.9.2"): | |
with cd(HOME_DIR): | |
run("source %s && rvm use %s && gem install %s"%(RVM,ruby_version,package)) | |
@runs_parallel | |
def put_fluent_conf(): | |
FLUENT_CONF_PATH="/etc/fluent/fluent.conf" | |
with settings(warn_only=True): | |
sudo("mkdir -p %s"%(os.path.dirname(FLUENT_CONF_PATH))) | |
put("./fluent.conf", FLUENT_CONF_PATH, use_sudo=True, mirror_local_mode=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment