-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ian Eyberg
committed
Mar 29, 2009
0 parents
commit aff8aca
Showing
8 changed files
with
524 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Colorify | ||
def colorBlack(text) | ||
return "\033[1m\033[30m\033[40m #{text} \033[0m" | ||
end | ||
|
||
def colorWhite(text) | ||
return "\033[1m\033[37m\033[40m #{text} \033[0m" | ||
end | ||
|
||
def colorGreen(text) | ||
return "\033[1m\033[32m\033[40m #{text} \033[0m" | ||
end | ||
|
||
def colorRed(text) | ||
return "\033[1m\033[31m\033[40m #{text} \033[0m" | ||
end | ||
|
||
def colorBlue(text) | ||
return "\033[1m\033[34m\033[40m #{text} \033[0m" | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'Colorify' | ||
|
||
class Host | ||
include Colorify | ||
|
||
def save | ||
puts colorBlack("creating a new host") | ||
puts colorBlack("-------------------") | ||
print colorBlack("Host: ") | ||
host = STDIN.gets.chomp | ||
|
||
hash = File.open('pac.yml') do |f| YAML.load f end | ||
|
||
if hash.nil? or hash.eql? false then | ||
hash = {} | ||
end | ||
|
||
if hash["hosts"].nil? then | ||
hosts = {} | ||
hash["hosts"] = hosts | ||
end | ||
|
||
ncount = hash["hosts"].count | ||
|
||
hash["hosts"]["host#{ncount+1}"] = host | ||
|
||
File.open("pac.yml", 'w') do |f| | ||
f.puts hash.to_yaml | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'Colorify' | ||
|
||
# projects can be any sort of software project | ||
# that is deployed often: in our case it consists | ||
# of bluffparse and our merb web service | ||
class Project | ||
include Colorify | ||
|
||
def load | ||
project = {} | ||
|
||
puts colorBlack("creating a new project") | ||
puts colorBlack("-------------------") | ||
print colorBlack("Name: ") | ||
project["name"] = STDIN.gets.chomp | ||
|
||
print colorBlack("Repo: ") | ||
project["repo"] = STDIN.gets.chomp | ||
|
||
print colorBlack("Deploy Location: ") | ||
project["dlocation"] = STDIN.gets.chomp | ||
|
||
print colorBlack("Custom Build Command: ") | ||
project["build"] = STDIN.gets.chomp | ||
|
||
|
||
hash = File.open('pac.yml') do |f| YAML.load f end | ||
|
||
if hash.nil? or hash.eql? false then | ||
hash = {} | ||
end | ||
|
||
if hash["services"].nil? then | ||
projects = {} | ||
hash["projects"] = projects | ||
end | ||
|
||
hash["projects"]["#{project["name"]}"] = project | ||
File.open("pac.yml", 'w') do |f| | ||
f.puts hash.to_yaml | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
Name: | ||
don't really have a good one yet, so took the reverse of cap.. | ||
|
||
Why not use Vlad or Capistrano? | ||
|
||
These are both excellent choices, however, for myself I spend a LOT | ||
of time deploying and don't think I should. I should be able to type one | ||
short command and be set. I should NOT have to spend an equal amount of | ||
time configuring my script and sshing in to make sure something worked. | ||
|
||
Why not use Puppet or Chef? | ||
|
||
These are also excellent programs -- however, once again I do not | ||
wish to spend an afternoon learning the vernacular and spending two hours | ||
to make one small change -- if they work for you -- fine use them -- I'm | ||
using this. | ||
|
||
Running: | ||
I usually have my ssh-keys added during a coding session. Among them | ||
are ones for my git repositories and one for my production server. To | ||
add yours simply: | ||
|
||
ssh-add ~/.ssh/gitrepo | ||
ssh-add ~/.ssh/production | ||
|
||
If you do this before you hop into SCREEN you'll be able to close/open | ||
as many shells as you want without having to retype your password. | ||
|
||
Now you may run pac. | ||
|
||
Options: | ||
generate | ||
-- can be ran multiple times to modify the yaml file from a guided | ||
script | ||
|
||
install | ||
-- can either accept from commandline what host to install from or | ||
choose from list; can modify values on the fly depending on which | ||
host you've chosen; searches for dependencies and auto-installs | ||
them; should be smart enough to grab the right depedencies for | ||
certain things | ||
|
||
upgrade | ||
-- can accept syntax like 'upgrade bluffweb' to do a git diff and | ||
grab the latest code | ||
|
||
restart | ||
-- can accept syntax like 'restart mysql' or 'restart bluffparse' | ||
|
||
Assumptions: | ||
* all ssh-keys have been added in your path, which I do before I start | ||
up a screen session; if not we should eventually be able to point | ||
various keys to whatever project/server and allow it to be smart enough | ||
to where you only have to type in your password once instead of 20 times | ||
|
||
Cucumber Stories/TODO/etc..: | ||
|
||
* easy easy easy auto-provisioining of deployments | ||
|
||
* capistrano sucks ass so much! | ||
|
||
* should have a DSL for doing quick tasks in the shell? | ||
|
||
* should be able to pull multiple projects into a deployment | ||
(java app && merb app) | ||
|
||
* should be able to do extensive conf editing, etc. each time | ||
|
||
* should not have to type in the password every time for something as simple | ||
as restarting a server | ||
|
||
* upgrade should upgrade all code from your repositories by default unless | ||
you specify only repository to upgrade | ||
|
||
* should auto-generate a recipe for you based on various questions | ||
|
||
* also should have the ability to modify this recipe later on | ||
|
||
* basically we are looking at zero-conf editing | ||
|
||
* should support individual keys and/or passwords for each repo you add | ||
|
||
* should try to use ssh-agent logins already available in your environment.. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'Colorify' | ||
|
||
# services are stuff like merb or mysql or memcached | ||
# that might not necesarily be deployed every time | ||
# we want to restart | ||
class Service | ||
include Colorify | ||
|
||
def load | ||
service = {} | ||
|
||
puts colorBlack("creating a new service") | ||
puts colorBlack("-------------------") | ||
print colorBlack("Name: ") | ||
service["name"] = STDIN.gets.chomp | ||
|
||
print colorBlack("Start Cmd: ") | ||
service["start"] = STDIN.gets.chomp | ||
|
||
print colorBlack("Stop Cmd: ") | ||
service["stop"] = STDIN.gets.chomp | ||
|
||
hash = File.open('pac.yml') do |f| YAML.load f end | ||
|
||
if hash.nil? or hash.eql? false then | ||
hash = {} | ||
end | ||
|
||
if hash["services"].nil? then | ||
services = {} | ||
hash["services"] = services | ||
end | ||
|
||
hash["services"]["#{service["name"]}"] = service | ||
|
||
File.open("pac.yml", 'w') do |f| | ||
f.puts hash.to_yaml | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
require 'Colorify' | ||
|
||
class SysDep | ||
|
||
def generate | ||
gen_menu | ||
option = STDIN.gets.chomp | ||
|
||
puts "option:#{option}:" | ||
if option.eql? "1" then | ||
newgem | ||
elsif option.eql? "2" then | ||
newapt | ||
elsif option.eql? "3" then | ||
newtarball | ||
else | ||
not_valid | ||
end | ||
end | ||
|
||
def not_valid | ||
puts "Not a Valid Option." | ||
end | ||
|
||
def gen_menu | ||
puts colorBlack("Create New Dependency") | ||
puts colorBlack("----------") | ||
puts colorBlack("1) Add Ruby Gem") | ||
puts colorBlack("2) Add Apt Package") | ||
puts colorBlack("3) Add tarball (url)") | ||
print colorBlue("> ") | ||
end | ||
|
||
def newapt | ||
puts colorBlack("creating a new (deb/apt) pkg depedency") | ||
puts colorBlack("-------------------") | ||
print colorBlack("Name: ") | ||
name = STDIN.gets.chomp | ||
print colorBlack("Pkg-Name: ") | ||
source = STDIN.gets.chomp | ||
|
||
hash = File.open('pac.yml') do |f| YAML.load f end | ||
|
||
if hash.nil? or hash.eql? false then | ||
hash = {} | ||
end | ||
|
||
if hash["sysdeps"].nil? then | ||
sysdeps = {} | ||
hash["sysdeps"] = sysdeps | ||
sysdeps["apts"] = {} | ||
end | ||
|
||
if hash["sysdeps"]["apts"].nil? then | ||
hash["sysdeps"]["apts"] = {} | ||
end | ||
|
||
hash["sysdeps"]["apts"]["#{name}"] = source | ||
|
||
File.open("pac.yml", 'w') do |f| | ||
f.puts hash.to_yaml | ||
end | ||
end | ||
|
||
def newtarball | ||
puts colorBlack("creating a new tarball depedency") | ||
puts colorBlack("-------------------") | ||
print colorBlack("Name: ") | ||
name = STDIN.gets.chomp | ||
print colorBlack("Source: ") | ||
source = STDIN.gets.chomp | ||
|
||
hash = File.open('pac.yml') do |f| YAML.load f end | ||
|
||
if hash.nil? or hash.eql? false then | ||
hash = {} | ||
end | ||
|
||
if hash["sysdeps"].nil? then | ||
sysdeps = {} | ||
hash["sysdeps"] = sysdeps | ||
sysdeps["tarballs"] = {} | ||
end | ||
|
||
if hash["sysdeps"]["tarballs"].nil? then | ||
hash["sysdeps"]["tarballs"] = {} | ||
end | ||
|
||
hash["sysdeps"]["tarballs"]["#{name}"] = source | ||
|
||
File.open("pac.yml", 'w') do |f| | ||
f.puts hash.to_yaml | ||
end | ||
end | ||
|
||
def newgem | ||
puts colorBlack("creating a new ruby gems depedency") | ||
puts colorBlack("-------------------") | ||
print colorBlack("Name: ") | ||
name = STDIN.gets.chomp | ||
print colorBlack("Source (press ENTER to default to rubygems) : ") | ||
source = STDIN.gets.chomp | ||
|
||
hash = File.open('pac.yml') do |f| YAML.load f end | ||
|
||
if hash.nil? or hash.eql? false then | ||
hash = {} | ||
end | ||
|
||
if hash["sysdeps"].nil? then | ||
sysdeps = {} | ||
hash["sysdeps"] = sysdeps | ||
sysdeps["gems"] = {} | ||
end | ||
|
||
if hash["sysdeps"]["gems"].nil? then | ||
hash["sysdeps"]["gems"] = {} | ||
end | ||
|
||
hash["sysdeps"]["gems"]["#{name}"] = source | ||
|
||
File.open("pac.yml", 'w') do |f| | ||
f.puts hash.to_yaml | ||
end | ||
end | ||
end |
Oops, something went wrong.