capigen 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Capfile +2 -2
- data/History.txt +4 -0
- data/Manifest.txt +9 -10
- data/lib/capigen/cap_ext/extension_proxy.rb +10 -0
- data/lib/capigen/{helper.rb → plugins/base.rb} +2 -9
- data/lib/capigen/plugins/gem.rb +25 -0
- data/lib/capigen/plugins/package.rb +19 -0
- data/lib/capigen/plugins/profiles.rb +35 -0
- data/lib/capigen/plugins/script.rb +39 -0
- data/lib/capigen/plugins/templates.rb +70 -0
- data/lib/capigen/{helpers/wget_helper.rb → plugins/wget.rb} +10 -4
- data/lib/capigen/{packagers → plugins}/yum.rb +10 -12
- data/lib/capigen/version.rb +1 -1
- data/lib/capigen.rb +10 -15
- data/lib/profiles/centos-sick.rb +35 -24
- data/lib/recipes/centos.rb +3 -5
- data/lib/recipes/gems.rb +4 -2
- data/lib/recipes/imagemagick.rb +2 -1
- data/lib/recipes/install.rb +1 -1
- data/lib/recipes/memcached.rb +3 -4
- data/lib/recipes/mongrel_cluster.rb +3 -3
- data/lib/recipes/monit.rb +9 -6
- data/lib/recipes/mysql.rb +4 -4
- data/lib/recipes/nginx.rb +9 -8
- data/lib/recipes/packages.rb +11 -6
- data/lib/recipes/rails.rb +1 -1
- data/lib/recipes/ruby.rb +2 -2
- data/lib/recipes/sphinx.rb +8 -8
- data/lib/templates/ruby/ruby_install.sh +2 -1
- data/website/index.html +1 -1
- metadata +11 -12
- data/lib/capigen/cap_ext/configuration.rb +0 -5
- data/lib/capigen/cap_ext/namespace.rb +0 -6
- data/lib/capigen/helpers/gem_helper.rb +0 -15
- data/lib/capigen/helpers/package_helper.rb +0 -40
- data/lib/capigen/helpers/script_helper.rb +0 -30
- data/lib/capigen/profiles.rb +0 -19
- data/lib/capigen/templates.rb +0 -65
data/Capfile
CHANGED
@@ -17,8 +17,8 @@ set :user, Proc.new { Capistrano::CLI.ui.ask('Bootstrap user: ') }
|
|
17
17
|
# Roles
|
18
18
|
role :base, Capistrano::CLI.ui.ask('Server: ')
|
19
19
|
|
20
|
-
#
|
21
|
-
set :profile, Proc.new { load
|
20
|
+
# Choose a profile
|
21
|
+
set :profile, Proc.new { load profile.choose }
|
22
22
|
|
23
23
|
# Reset the password var
|
24
24
|
reset_password
|
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -7,20 +7,19 @@ Rakefile
|
|
7
7
|
config/hoe.rb
|
8
8
|
config/requirements.rb
|
9
9
|
lib/capigen.rb
|
10
|
-
lib/capigen/cap_ext/configuration.rb
|
11
10
|
lib/capigen/cap_ext/connections.rb
|
12
|
-
lib/capigen/cap_ext/
|
11
|
+
lib/capigen/cap_ext/extension_proxy.rb
|
13
12
|
lib/capigen/config.rb
|
14
|
-
lib/capigen/
|
15
|
-
lib/capigen/
|
16
|
-
lib/capigen/
|
17
|
-
lib/capigen/
|
18
|
-
lib/capigen/
|
19
|
-
lib/capigen/
|
20
|
-
lib/capigen/
|
13
|
+
lib/capigen/plugins/base.rb
|
14
|
+
lib/capigen/plugins/gem.rb
|
15
|
+
lib/capigen/plugins/package.rb
|
16
|
+
lib/capigen/plugins/profiles.rb
|
17
|
+
lib/capigen/plugins/script.rb
|
18
|
+
lib/capigen/plugins/templates.rb
|
19
|
+
lib/capigen/plugins/wget.rb
|
20
|
+
lib/capigen/plugins/yum.rb
|
21
21
|
lib/capigen/recipes.rb
|
22
22
|
lib/capigen/recipes.yml
|
23
|
-
lib/capigen/templates.rb
|
24
23
|
lib/capigen/version.rb
|
25
24
|
lib/profiles/centos-sick.rb
|
26
25
|
lib/recipes/README
|
@@ -6,16 +6,8 @@ require 'yaml'
|
|
6
6
|
# * Loads the configuration
|
7
7
|
# * Generates files from templates
|
8
8
|
#
|
9
|
-
module Capigen::
|
9
|
+
module Capigen::Plugins::Base
|
10
10
|
|
11
|
-
include Capigen::Templates
|
12
|
-
include Capigen::Profiles
|
13
|
-
|
14
|
-
include Capigen::Helpers::PackageHelper
|
15
|
-
include Capigen::Helpers::WgetHelper
|
16
|
-
include Capigen::Helpers::ScriptHelper
|
17
|
-
include Capigen::Helpers::GemHelper
|
18
|
-
|
19
11
|
# Project root (for rails)
|
20
12
|
def root
|
21
13
|
if respond_to?(:fetch)
|
@@ -49,3 +41,4 @@ module Capigen::Helper
|
|
49
41
|
|
50
42
|
end
|
51
43
|
|
44
|
+
Capistrano.plugin :capigen, Capigen::Plugins::Base
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Capigen::Plugins::Gem
|
2
|
+
|
3
|
+
# Installl a gem.
|
4
|
+
#
|
5
|
+
# ==== Options
|
6
|
+
# +gems+:: List of gem names, or a single gem
|
7
|
+
#
|
8
|
+
# ==== Examples
|
9
|
+
# install("raspell")
|
10
|
+
# install([ "raspell", "foo" ])
|
11
|
+
#
|
12
|
+
def install(gems)
|
13
|
+
# If a single object, wrap in array
|
14
|
+
gems = [ gems ] unless gems.is_a?(Array)
|
15
|
+
|
16
|
+
# Install one at a time because we may need to pass install args (e.g. mysql)
|
17
|
+
# TODO: Fix this
|
18
|
+
gems.each do |gem|
|
19
|
+
sudo "gem install --no-rdoc --no-ri --no-verbose #{gem}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
Capistrano.plugin :gemc, Capigen::Plugins::Gem
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Capigen::Plugins::Package
|
2
|
+
|
3
|
+
# Setup packager
|
4
|
+
#
|
5
|
+
# ==== Options
|
6
|
+
# +packager+:: Packager type (:yum)
|
7
|
+
#
|
8
|
+
def type=(packager_type)
|
9
|
+
case packager_type.to_sym
|
10
|
+
when :yum
|
11
|
+
include Capigen::Plugins::Yum
|
12
|
+
else
|
13
|
+
raise "Invalid packager type: #{packager_type}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
Capistrano.plugin :package, Capigen::Plugins::Package
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Capigen::Plugins::Profiles
|
2
|
+
|
3
|
+
ProfileDir = File.dirname(__FILE__) + "/../../profiles"
|
4
|
+
|
5
|
+
def recipes(prefix = "")
|
6
|
+
Dir[ProfileDir + "/#{prefix}*.rb"].collect { |file| File.basename(file).gsub(File.extname(file), "") }
|
7
|
+
end
|
8
|
+
|
9
|
+
def choose(prefix = "")
|
10
|
+
profile = HighLine.new.choose(*recipes(prefix)) do |menu|
|
11
|
+
menu.header = "Choose recipe profile"
|
12
|
+
end
|
13
|
+
|
14
|
+
"#{ProfileDir}/#{profile}.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
# More helpful fetch
|
18
|
+
def get(var)
|
19
|
+
begin
|
20
|
+
result = fetch(var.to_sym)
|
21
|
+
rescue
|
22
|
+
puts <<-EOS
|
23
|
+
|
24
|
+
Please set :#{var} variable in your Capfile or profile.
|
25
|
+
|
26
|
+
EOS
|
27
|
+
raise "Please set :#{var} in your Capfile or profile."
|
28
|
+
end
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
Capistrano.plugin :profile, Capigen::Plugins::Profiles
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Capigen::Plugins::Script
|
2
|
+
|
3
|
+
# Install (sh) script
|
4
|
+
#
|
5
|
+
# ==== Options
|
6
|
+
# +script+:: Name of file (relative to templates dir)
|
7
|
+
# +files_to_put+:: List of files to upload [ { :file => "foo/bar.txt", :dest "/tmp/bar.txt" }, ... ]
|
8
|
+
#
|
9
|
+
def install(script, files_to_put = [], override_binding = nil)
|
10
|
+
|
11
|
+
files_to_put = [ files_to_put ] if files_to_put.is_a?(Hash)
|
12
|
+
|
13
|
+
files_to_put.each do |file_info|
|
14
|
+
data = template.load(file_info[:file], override_binding || binding)
|
15
|
+
put data, file_info[:dest]
|
16
|
+
end
|
17
|
+
|
18
|
+
if File.extname(script) == ".erb"
|
19
|
+
name = script[0...script.length-4]
|
20
|
+
dest = "/tmp/#{name}"
|
21
|
+
run "mkdir -p #{File.dirname(dest)}"
|
22
|
+
put template.load(script, override_binding || binding), dest
|
23
|
+
else
|
24
|
+
name = script
|
25
|
+
dest = "/tmp/#{name}"
|
26
|
+
run "mkdir -p #{File.dirname(dest)}"
|
27
|
+
put template.load(script), dest
|
28
|
+
end
|
29
|
+
|
30
|
+
# If want verbose, -v
|
31
|
+
sudo "sh #{dest}"
|
32
|
+
|
33
|
+
# Cleanup
|
34
|
+
sudo "rm -rf #{File.dirname(dest)}"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
Capistrano.plugin :script, Capigen::Plugins::Script
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Capigen::Plugins::Templates
|
2
|
+
|
3
|
+
# Root of templates path
|
4
|
+
def gem_templates_root
|
5
|
+
File.expand_path(File.dirname(__FILE__) + "/../../templates")
|
6
|
+
end
|
7
|
+
|
8
|
+
# Get full template path
|
9
|
+
def gem_template_path(template_path)
|
10
|
+
File.join(gem_templates_root, template_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Load template. If extension is erb will be evaluated with binding.
|
14
|
+
#
|
15
|
+
# ==== Options
|
16
|
+
# +path+:: If starts with '/', absolute path, otherwise relative path to templates dir
|
17
|
+
# +binding+:: Binding
|
18
|
+
#
|
19
|
+
def load(path, override_binding = nil)
|
20
|
+
template_paths = [ path, gem_template_path(path) ]
|
21
|
+
|
22
|
+
template_paths = template_paths.select { |file| File.exist?(file) }
|
23
|
+
|
24
|
+
if template_paths.empty?
|
25
|
+
raise <<-EOS
|
26
|
+
|
27
|
+
Template not found: #{template_paths.join("\n\t")}
|
28
|
+
|
29
|
+
EOS
|
30
|
+
end
|
31
|
+
|
32
|
+
# Use first
|
33
|
+
template_path = template_paths.first
|
34
|
+
|
35
|
+
data = IO.read(template_path)
|
36
|
+
|
37
|
+
if File.extname(template_path) == ".erb"
|
38
|
+
template = ERB.new(data)
|
39
|
+
data = template.result(override_binding || binding)
|
40
|
+
end
|
41
|
+
data
|
42
|
+
end
|
43
|
+
|
44
|
+
# Load template from project
|
45
|
+
def project(path, override_binding = nil)
|
46
|
+
load(project_root + "/" + path, override_binding || binding)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Write template at (relative path) with binding to LOCAL destination path.
|
50
|
+
#
|
51
|
+
# ==== Options
|
52
|
+
# +template_path+:: Path to template relative to templates path
|
53
|
+
#
|
54
|
+
def write(template_path, binding, dest_path, overwrite = false, verbose = true)
|
55
|
+
# This is gnarly!
|
56
|
+
relative_dest_path = Pathname.new(File.expand_path(dest_path)).relative_path_from(Pathname.new(File.expand_path(".")))
|
57
|
+
|
58
|
+
if !overwrite && File.exist?(dest_path)
|
59
|
+
puts "%10s %-40s (skipped)" % [ "create", relative_dest_path ] if verbose
|
60
|
+
return
|
61
|
+
end
|
62
|
+
|
63
|
+
puts "%10s %-40s" % [ "create", relative_dest_path ] if verbose
|
64
|
+
|
65
|
+
File.open(dest_path, "w") { |file| file.puts(load(template_path, binding)) }
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
Capistrano.plugin :template, Capigen::Plugins::Templates
|
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
|
3
|
-
|
4
|
-
module Capigen::Helpers::WgetHelper
|
3
|
+
module Capigen::Plugins::Wget
|
5
4
|
|
6
5
|
# Download the uri, then upload it into the remote destination directory
|
7
|
-
|
6
|
+
#
|
7
|
+
# ==== Options
|
8
|
+
# +uri+:: URI to get
|
9
|
+
# +remote_dest_dir+:: Remote destination directory
|
10
|
+
#
|
11
|
+
def uri(uri, remote_dest_dir = "/tmp")
|
8
12
|
|
9
13
|
uri = uri = URI.parse(uri)
|
10
14
|
name = uri.path.split("/").last
|
@@ -14,4 +18,6 @@ module Capigen::Helpers::WgetHelper
|
|
14
18
|
put open(uri).read, remote_dest_path
|
15
19
|
end
|
16
20
|
|
17
|
-
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Capistrano.plugin :wget, Capigen::Plugins::Wget
|
@@ -1,18 +1,14 @@
|
|
1
1
|
# Packages must respond to update, remove, install and clean
|
2
|
-
|
3
|
-
|
4
|
-
def initialize(cap)
|
5
|
-
@cap = cap
|
6
|
-
end
|
2
|
+
module Capigen::Plugins::Yum
|
7
3
|
|
8
4
|
# Update all installed packages
|
9
5
|
def update(packages = [])
|
10
|
-
|
6
|
+
sudo "yum -y update #{packages.join(" ")}"
|
11
7
|
end
|
12
8
|
|
13
9
|
# Remove via yum.
|
14
10
|
def remove(packages)
|
15
|
-
|
11
|
+
sudo "yum -y remove #{packages.join(" ")}"
|
16
12
|
end
|
17
13
|
|
18
14
|
# Install via yum.
|
@@ -26,21 +22,23 @@ class Capigen::Packagers::Yum
|
|
26
22
|
|
27
23
|
installed_packages = []
|
28
24
|
|
29
|
-
|
25
|
+
sudo "yum -d 0 list installed #{packages.join(" ")}" do |channel, stream, data|
|
30
26
|
installed_packages += data.split("\n")[1..-1].collect { |line| line.split(".").first }
|
31
27
|
end
|
32
28
|
|
33
29
|
packages -= installed_packages
|
34
30
|
|
35
|
-
|
31
|
+
sudo "yum -y update #{installed_packages.join(" ")}" unless installed_packages.blank?
|
36
32
|
end
|
37
33
|
|
38
|
-
|
34
|
+
sudo "yum -y install #{packages.join(" ")}" unless packages.blank?
|
39
35
|
end
|
40
36
|
|
41
37
|
# Clean yum
|
42
38
|
def clean
|
43
|
-
|
39
|
+
sudo "yum -y clean all"
|
44
40
|
end
|
45
41
|
|
46
|
-
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Capistrano.plugin :yum, Capigen::Plugins::Yum
|
data/lib/capigen/version.rb
CHANGED
data/lib/capigen.rb
CHANGED
@@ -7,28 +7,23 @@ HighLine.track_eof = false
|
|
7
7
|
$:.unshift File.dirname(__FILE__)
|
8
8
|
|
9
9
|
module Capigen
|
10
|
-
module
|
10
|
+
module Plugins
|
11
11
|
end
|
12
|
-
|
13
|
-
module Packagers
|
14
|
-
end
|
15
12
|
end
|
16
13
|
|
17
|
-
require
|
18
|
-
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require "capigen/helper"
|
14
|
+
require 'capigen/plugins/base'
|
15
|
+
require 'capigen/plugins/gem'
|
16
|
+
require 'capigen/plugins/package'
|
17
|
+
require 'capigen/plugins/profiles'
|
18
|
+
require 'capigen/plugins/script'
|
19
|
+
require 'capigen/plugins/templates'
|
20
|
+
require 'capigen/plugins/wget'
|
21
|
+
require 'capigen/plugins/yum'
|
26
22
|
|
27
23
|
require "capigen/config"
|
28
24
|
|
29
|
-
require "capigen/cap_ext/configuration"
|
30
|
-
require "capigen/cap_ext/namespace"
|
31
25
|
require "capigen/cap_ext/connections"
|
26
|
+
require "capigen/cap_ext/extension_proxy"
|
32
27
|
|
33
28
|
|
34
29
|
|
data/lib/profiles/centos-sick.rb
CHANGED
@@ -1,8 +1,31 @@
|
|
1
1
|
set :namespace, "centos"
|
2
2
|
set :description, "Install based on default centos 5.1 image"
|
3
|
-
|
4
|
-
set :
|
5
|
-
|
3
|
+
|
4
|
+
set :recipes, [
|
5
|
+
# "centos:setup",
|
6
|
+
# "packages:install",
|
7
|
+
# "ruby:install",
|
8
|
+
# "nginx:install",
|
9
|
+
# "nginx:install_monit",
|
10
|
+
# "mysql:install",
|
11
|
+
# "mysql:install_monit",
|
12
|
+
# "sphinx:install",
|
13
|
+
# "monit:install",
|
14
|
+
# "imagemagick:install",
|
15
|
+
# "memcached:install",
|
16
|
+
# "memcached:install_monit",
|
17
|
+
# "gems:install",
|
18
|
+
"centos:cleanup"
|
19
|
+
]
|
20
|
+
|
21
|
+
#
|
22
|
+
# Settings for recipes
|
23
|
+
#
|
24
|
+
|
25
|
+
set :packages, {
|
26
|
+
:type => "yum",
|
27
|
+
:remove => [ "openoffice.org-*", "ImageMagick" ],
|
28
|
+
:add => [
|
6
29
|
"gcc", "kernel-devel", "libevent-devel", "libxml2-devel",
|
7
30
|
"openssl", "openssl-devel",
|
8
31
|
"aspell", "aspell-devel", "aspell-en", "aspell-es",
|
@@ -13,34 +36,22 @@ set :packages_to_add, [
|
|
13
36
|
"flex", "byacc",
|
14
37
|
"libjpeg-devel", "libpng-devel", "glib2-devel", "fontconfig-devel", "libwmf-devel", "freetype-devel",
|
15
38
|
"libtiff-devel"
|
16
|
-
]
|
39
|
+
]
|
40
|
+
}
|
17
41
|
|
18
|
-
set :install_tasks, [
|
19
|
-
"centos:setup",
|
20
|
-
"packages:install",
|
21
|
-
"ruby:install",
|
22
|
-
"nginx:install",
|
23
|
-
"nginx:install_monit",
|
24
|
-
"mysql:install",
|
25
|
-
"mysql:install_monit",
|
26
|
-
"sphinx:install",
|
27
|
-
"monit:install",
|
28
|
-
"imagemagick:install",
|
29
|
-
"memcached:install",
|
30
|
-
"memcached:install_monit",
|
31
|
-
"gems:install",
|
32
|
-
"centos:cleanup"
|
33
|
-
]
|
34
|
-
|
35
42
|
set :gem_list, [
|
36
43
|
"rake",
|
37
44
|
"mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --with-mysql-config",
|
38
|
-
"raspell",
|
45
|
+
"raspell",
|
46
|
+
"rmagick",
|
47
|
+
"mongrel",
|
48
|
+
"mongrel_cluster",
|
49
|
+
"json"
|
39
50
|
]
|
40
51
|
|
41
52
|
# Monit
|
42
53
|
set :monit_port, 2812 # Capistrano::CLI.ui.ask('Monit port: ')
|
43
|
-
set :monit_password, Capistrano::CLI.ui.ask('Monit admin password (to set): ')
|
54
|
+
set :monit_password, Proc.new { Capistrano::CLI.ui.ask('Monit admin password (to set): ') }
|
44
55
|
|
45
56
|
# For nginx
|
46
57
|
set :nginx_bin_path, "/sbin/nginx"
|
@@ -49,7 +60,7 @@ set :nginx_pid_path, "/var/run/nginx.pid"
|
|
49
60
|
set :nginx_prefix_path, "/var/nginx"
|
50
61
|
|
51
62
|
# Mysql
|
52
|
-
set :mysql_admin_password, Capistrano::CLI.ui.ask('Mysql admin password (to set): ')
|
63
|
+
set :mysql_admin_password, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password (to set): ') }
|
53
64
|
set :mysql_pid_path, "/var/run/mysqld/mysqld.pid"
|
54
65
|
set :db_port, 3306 # Capistrano::CLI.ui.ask('Mysql port: ')
|
55
66
|
|
data/lib/recipes/centos.rb
CHANGED
@@ -3,14 +3,12 @@ namespace :centos do
|
|
3
3
|
|
4
4
|
desc "Setup centos"
|
5
5
|
task :setup do
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
6
|
+
script.install("centos/setup.sh", :file => "centos/sudoers", :dest => "/tmp/sudoers")
|
7
|
+
end
|
10
8
|
|
11
9
|
desc "Cleanup"
|
12
10
|
task :cleanup do
|
13
|
-
|
11
|
+
yum.clean
|
14
12
|
end
|
15
13
|
|
16
14
|
# Add user for an application
|
data/lib/recipes/gems.rb
CHANGED
data/lib/recipes/imagemagick.rb
CHANGED
@@ -3,7 +3,8 @@ namespace :imagemagick do
|
|
3
3
|
task :install do
|
4
4
|
# Dependencies: "libjpeg-devel", "libpng-devel", "glib2-devel", "fontconfig-devel", "zlib-devel",
|
5
5
|
# "libwmf-devel", "freetype-devel", "libtiff-devel"
|
6
|
-
|
6
|
+
|
7
|
+
script.install("imagemagick/install.sh")
|
7
8
|
end
|
8
9
|
|
9
10
|
end
|
data/lib/recipes/install.rb
CHANGED
data/lib/recipes/memcached.rb
CHANGED
@@ -2,14 +2,13 @@ namespace :memcached do
|
|
2
2
|
|
3
3
|
desc "Install memcached"
|
4
4
|
task :install do
|
5
|
-
|
6
|
-
script_install("memcached/install.sh")
|
5
|
+
script.install("memcached/install.sh", :file => "memcached/memcached.initd.centos.erb", :dest => "/tmp/memcached.initd")
|
7
6
|
end
|
8
7
|
|
9
8
|
desc "Install memcached monit hooks"
|
10
9
|
task :install_monit do
|
11
|
-
put
|
12
|
-
|
10
|
+
put template.load("memcached/memcached.monitrc.erb", binding), "/tmp/memcached.monitrc"
|
11
|
+
sudo "install -o root /tmp/memcached.monitrc /etc/monit/memcached.monitrc"
|
13
12
|
end
|
14
13
|
|
15
14
|
end
|
@@ -13,8 +13,8 @@ namespace :mongrel_cluster do
|
|
13
13
|
|
14
14
|
pid_path = "#{shared_path}/pids"
|
15
15
|
|
16
|
-
put
|
17
|
-
put
|
16
|
+
put template.load("mongrel/mongrel_cluster.initd.erb", binding), "/tmp/mongrel_cluster_#{application}.initd"
|
17
|
+
put template.load("mongrel/mongrel_cluster.yml.erb", binding), "#{mongrel_config_path}/mongrel_cluster.yml"
|
18
18
|
|
19
19
|
# Setup the mongrel_cluster init script
|
20
20
|
sudo "install -o root /tmp/mongrel_cluster_#{application}.initd /etc/init.d/mongrel_cluster_#{application}"
|
@@ -41,7 +41,7 @@ namespace :mongrel_cluster do
|
|
41
41
|
processes << { :port => port, :start_options => start_options, :stop_options => stop_options, :name => "/usr/bin/mongrel_rails", :pid_path => pid_path }
|
42
42
|
end
|
43
43
|
|
44
|
-
put
|
44
|
+
put template.load("mongrel/mongrel_cluster.monitrc.erb", binding), "/tmp/mongrel_cluster_#{application}.monitrc"
|
45
45
|
|
46
46
|
sudo "install -o root /tmp/mongrel_cluster_#{application}.monitrc /etc/monit/mongrel_cluster_#{application}.monitrc"
|
47
47
|
end
|
data/lib/recipes/monit.rb
CHANGED
@@ -4,13 +4,16 @@ namespace :monit do
|
|
4
4
|
task :install do
|
5
5
|
# Dependencies: "flex", "byacc"
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
install_files = [
|
8
|
+
{ :file => "monit/monit.initd.centos.erb", :dest => "/tmp/monit.initd" },
|
9
|
+
{ :file => "monit/monitrc.erb", :dest => "/tmp/monitrc" }
|
10
|
+
]
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
script.install("monit/install.sh", install_files)
|
13
|
+
|
14
|
+
script.install("monit/patch_inittab.sh")
|
15
|
+
|
16
|
+
script.install("monit/cert.sh", :file => "monit/monit.cnf", :dest => "/tmp/monit.cnf")
|
14
17
|
end
|
15
18
|
|
16
19
|
end
|
data/lib/recipes/mysql.rb
CHANGED
@@ -3,13 +3,13 @@ namespace :mysql do
|
|
3
3
|
|
4
4
|
desc "Install mysql"
|
5
5
|
task :install do
|
6
|
-
|
6
|
+
script.install("mysql/install.sh.erb")
|
7
7
|
end
|
8
8
|
|
9
9
|
desc "Install mysql monit hooks"
|
10
10
|
task :install_monit do
|
11
|
-
put
|
12
|
-
|
11
|
+
put template.load("mysql/mysql.monitrc.erb", binding), "/tmp/mysql.monitrc"
|
12
|
+
sudo "install -o root /tmp/mysql.monitrc /etc/monit/mysql.monitrc"
|
13
13
|
end
|
14
14
|
|
15
15
|
desc "Create database user, and database with appropriate permissions"
|
@@ -17,7 +17,7 @@ namespace :mysql do
|
|
17
17
|
# Add localhost to grant locations
|
18
18
|
locations_for_grant = [ "localhost", web_host ]
|
19
19
|
|
20
|
-
put
|
20
|
+
put template.load("mysql/install_db.sql.erb", binding), "/tmp/install_db_#{application}.sql"
|
21
21
|
run "mysql -u root -p#{mysql_admin_password} < /tmp/install_db_#{application}.sql"
|
22
22
|
end
|
23
23
|
|
data/lib/recipes/nginx.rb
CHANGED
@@ -8,19 +8,20 @@ namespace :nginx do
|
|
8
8
|
task :install do
|
9
9
|
# Dependencies: "pcre-devel", "openssl", "openssl-devel"
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
files = [
|
12
|
+
{ :file => "nginx/nginx.initd.erb", :dest => "/tmp/nginx.initd" },
|
13
|
+
{ :file => "nginx/nginx.conf.erb", :dest => "/tmp/nginx.conf" }
|
14
|
+
]
|
13
15
|
|
14
|
-
|
16
|
+
script.install("nginx/install.sh.erb", files, binding)
|
15
17
|
end
|
16
18
|
|
17
19
|
desc "Install nginx monit hooks"
|
18
20
|
task :install_monit do
|
19
|
-
put
|
20
|
-
|
21
|
+
put template.load("nginx/nginx.monitrc.erb", binding), "/tmp/nginx.monitrc"
|
22
|
+
sudo "install -o root /tmp/nginx.monitrc /etc/monit/nginx.monitrc"
|
21
23
|
end
|
22
|
-
|
23
|
-
|
24
|
+
|
24
25
|
desc "Create and update the nginx vhost include"
|
25
26
|
task :setup do
|
26
27
|
|
@@ -28,7 +29,7 @@ namespace :nginx do
|
|
28
29
|
public_path = current_path + "/public"
|
29
30
|
|
30
31
|
run "mkdir -p #{shared_path}/config"
|
31
|
-
put
|
32
|
+
put template.load("nginx/nginx_vhost.conf.erb", binding), "/tmp/nginx_#{application}.conf"
|
32
33
|
|
33
34
|
sudo "install -o root /tmp/nginx_#{application}.conf /etc/nginx/vhosts/#{application}.conf"
|
34
35
|
end
|
data/lib/recipes/packages.rb
CHANGED
@@ -2,18 +2,23 @@ namespace :packages do
|
|
2
2
|
|
3
3
|
task :install do
|
4
4
|
|
5
|
-
#
|
6
|
-
|
5
|
+
# Settings
|
6
|
+
packages = profile.get(:packages)
|
7
|
+
|
8
|
+
packages_to_remove = packages[:remove]
|
9
|
+
packages_to_add = packages[:add]
|
10
|
+
|
11
|
+
# Set package type
|
12
|
+
package.type = packages[:type]
|
7
13
|
|
8
14
|
# Remove packages
|
9
|
-
|
15
|
+
package.remove(packages_to_remove) unless packages_to_remove.blank?
|
10
16
|
|
11
17
|
# Update all existing packages
|
12
|
-
|
18
|
+
package.update
|
13
19
|
|
14
20
|
# Install packages
|
15
|
-
|
16
|
-
|
21
|
+
package.install(packages_to_add) unless packages_to_add.blank?
|
17
22
|
end
|
18
23
|
|
19
24
|
end
|
data/lib/recipes/rails.rb
CHANGED
@@ -4,7 +4,7 @@ namespace :rails do
|
|
4
4
|
desc "Create database yaml in shared path"
|
5
5
|
task :setup do
|
6
6
|
run "mkdir -p #{shared_path}/config"
|
7
|
-
put
|
7
|
+
put template.load("rails/database.yml.erb", binding), "#{shared_path}/config/database.yml"
|
8
8
|
end
|
9
9
|
|
10
10
|
desc "Make symlink for database yaml"
|
data/lib/recipes/ruby.rb
CHANGED
@@ -5,10 +5,10 @@ namespace :ruby do
|
|
5
5
|
# Dependencies: zlib, zlib-devel
|
6
6
|
|
7
7
|
# Install ruby 1.8.6
|
8
|
-
|
8
|
+
script.install("ruby/ruby_install.sh")
|
9
9
|
|
10
10
|
# Install rubygems
|
11
|
-
|
11
|
+
script.install("ruby/rubygems_install.sh")
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
data/lib/recipes/sphinx.rb
CHANGED
@@ -6,7 +6,7 @@ namespace :sphinx do
|
|
6
6
|
desc "Install sphinx"
|
7
7
|
task :install do
|
8
8
|
# Dependencies: gcc-c++
|
9
|
-
|
9
|
+
script.install("sphinx/install.sh.erb")
|
10
10
|
end
|
11
11
|
|
12
12
|
desc "Setup sphinx for application"
|
@@ -16,7 +16,7 @@ namespace :sphinx do
|
|
16
16
|
sphinx_conf_path = "#{shared_path}/config/sphinx.conf"
|
17
17
|
sphinx_pid_path = "#{shared_path}/pids/searchd.pid"
|
18
18
|
|
19
|
-
put
|
19
|
+
put template.load("sphinx/sphinx_app.initd.centos.erb"), "/tmp/sphinx.initd"
|
20
20
|
|
21
21
|
sudo "install -o root /tmp/sphinx.initd /etc/init.d/sphinx_#{application}"
|
22
22
|
|
@@ -28,7 +28,7 @@ namespace :sphinx do
|
|
28
28
|
desc "Create monit configuration for sphinx"
|
29
29
|
task :setup_monit do
|
30
30
|
sphinx_pid_path = "#{shared_path}/pids/searchd.pid"
|
31
|
-
put
|
31
|
+
put template.load("sphinx/sphinx.monitrc.erb"), "/tmp/sphinx_#{application}.monitrc"
|
32
32
|
|
33
33
|
sudo "install -o root /tmp/sphinx_#{application}.monitrc /etc/monit/sphinx_#{application}.monitrc"
|
34
34
|
end
|
@@ -36,12 +36,12 @@ namespace :sphinx do
|
|
36
36
|
desc "Update sphinx for application"
|
37
37
|
task :update_code do
|
38
38
|
|
39
|
-
rails_root
|
40
|
-
index_root
|
41
|
-
log_root
|
42
|
-
pid_root
|
39
|
+
set :rails_root, current_path
|
40
|
+
set :index_root, "#{shared_path}/var/index";
|
41
|
+
set :log_root, "#{shared_path}/log"
|
42
|
+
set :pid_root, "#{shared_path}/pids"
|
43
43
|
|
44
|
-
put
|
44
|
+
put template.project("config/templates/sphinx.conf.erb"), "#{shared_path}/config/sphinx.conf"
|
45
45
|
end
|
46
46
|
|
47
47
|
desc "Rotate sphinx index for application"
|
@@ -4,7 +4,8 @@ set -e
|
|
4
4
|
trap ERROR ERR
|
5
5
|
|
6
6
|
cd /usr/src
|
7
|
-
|
7
|
+
wget -nv http://capigen.s3.amazonaws.com/ruby-1.8.6-p110.tar.gz
|
8
|
+
# ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p110.tar.gz
|
8
9
|
tar xzf ruby-1.8.6-p110.tar.gz
|
9
10
|
cd ruby-1.8.6-p110
|
10
11
|
echo "Configuring ruby..."
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>capigen</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/capigen"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/capigen" class="numbers">0.1.
|
36
|
+
<a href="http://rubyforge.org/projects/capigen" class="numbers">0.1.4</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘capigen’</h1>
|
39
39
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capigen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ""
|
6
6
|
authors:
|
7
7
|
- Gabriel Handford
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-02-
|
12
|
+
date: 2008-02-07 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -36,20 +36,19 @@ files:
|
|
36
36
|
- config/hoe.rb
|
37
37
|
- config/requirements.rb
|
38
38
|
- lib/capigen.rb
|
39
|
-
- lib/capigen/cap_ext/configuration.rb
|
40
39
|
- lib/capigen/cap_ext/connections.rb
|
41
|
-
- lib/capigen/cap_ext/
|
40
|
+
- lib/capigen/cap_ext/extension_proxy.rb
|
42
41
|
- lib/capigen/config.rb
|
43
|
-
- lib/capigen/
|
44
|
-
- lib/capigen/
|
45
|
-
- lib/capigen/
|
46
|
-
- lib/capigen/
|
47
|
-
- lib/capigen/
|
48
|
-
- lib/capigen/
|
49
|
-
- lib/capigen/
|
42
|
+
- lib/capigen/plugins/base.rb
|
43
|
+
- lib/capigen/plugins/gem.rb
|
44
|
+
- lib/capigen/plugins/package.rb
|
45
|
+
- lib/capigen/plugins/profiles.rb
|
46
|
+
- lib/capigen/plugins/script.rb
|
47
|
+
- lib/capigen/plugins/templates.rb
|
48
|
+
- lib/capigen/plugins/wget.rb
|
49
|
+
- lib/capigen/plugins/yum.rb
|
50
50
|
- lib/capigen/recipes.rb
|
51
51
|
- lib/capigen/recipes.yml
|
52
|
-
- lib/capigen/templates.rb
|
53
52
|
- lib/capigen/version.rb
|
54
53
|
- lib/profiles/centos-sick.rb
|
55
54
|
- lib/recipes/README
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# Gem capistrano helpers
|
2
|
-
module Capigen::Helpers::GemHelper
|
3
|
-
|
4
|
-
# gem_install("raspell") or gem_install([ "raspell", "foo" ])
|
5
|
-
def gem_install(gems)
|
6
|
-
# If a single object, wrap in array
|
7
|
-
gems = [ gems ] unless gems.is_a?(Array)
|
8
|
-
|
9
|
-
# Install one at a time because we may need to pass install args (e.g. mysql)
|
10
|
-
gems.each do |gem|
|
11
|
-
sudo "gem install --no-rdoc --no-ri --no-verbose #{gem}"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# Package, Yum capistrano helpers
|
2
|
-
module Capigen::Helpers::PackageHelper
|
3
|
-
|
4
|
-
def setup_packager(packager)
|
5
|
-
@packager = case packager.to_sym
|
6
|
-
when :yum then Capigen::Packagers::Yum.new(self)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def ensure_packager
|
11
|
-
unless @packager
|
12
|
-
logger.important "No packager defined, defaulting to yum."
|
13
|
-
|
14
|
-
# Currently only have 1 packager, so
|
15
|
-
setup_packager(:yum)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def package_install(packages)
|
20
|
-
ensure_packager
|
21
|
-
@packager.install(packages)
|
22
|
-
end
|
23
|
-
|
24
|
-
def package_update(packages = [])
|
25
|
-
ensure_packager
|
26
|
-
@packager.update(packages)
|
27
|
-
end
|
28
|
-
|
29
|
-
def package_clean
|
30
|
-
ensure_packager
|
31
|
-
@packager.clean
|
32
|
-
end
|
33
|
-
|
34
|
-
def package_remove(packages)
|
35
|
-
ensure_packager
|
36
|
-
@packager.remove(packages)
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Installer capistrano helper
|
2
|
-
module Capigen::Helpers::ScriptHelper
|
3
|
-
|
4
|
-
def script_install(script, files_to_put = {})
|
5
|
-
|
6
|
-
files_to_put.each do |file, dest|
|
7
|
-
put load_file(file), dest
|
8
|
-
end
|
9
|
-
|
10
|
-
if File.extname(script) == ".erb"
|
11
|
-
name = script[0...script.length-4]
|
12
|
-
dest = "/tmp/#{name}"
|
13
|
-
run "mkdir -p #{File.dirname(dest)}"
|
14
|
-
put load_template(script, binding), dest
|
15
|
-
|
16
|
-
else
|
17
|
-
name = script
|
18
|
-
dest = "/tmp/#{name}"
|
19
|
-
run "mkdir -p #{File.dirname(dest)}"
|
20
|
-
put load_file(name), dest
|
21
|
-
end
|
22
|
-
|
23
|
-
# If want verbose, -v
|
24
|
-
sudo "sh #{dest}"
|
25
|
-
|
26
|
-
# Cleanup
|
27
|
-
sudo "rm -rf #{File.dirname(dest)}"
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
data/lib/capigen/profiles.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Capigen::Profiles
|
2
|
-
|
3
|
-
ProfileDir = File.dirname(__FILE__) + "/../profiles"
|
4
|
-
|
5
|
-
def recipe_profiles(prefix = "")
|
6
|
-
Dir[ProfileDir + "/#{prefix}*.rb"].collect { |file| File.basename(file)[0...-3] }
|
7
|
-
end
|
8
|
-
|
9
|
-
def choose_profile(prefix = "")
|
10
|
-
profile = HighLine.new.choose(*recipe_profiles(prefix)) do |menu|
|
11
|
-
menu.header = "Choose recipe profile"
|
12
|
-
end
|
13
|
-
|
14
|
-
"#{ProfileDir}/#{profile}.rb"
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
|
data/lib/capigen/templates.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
module Capigen::Templates
|
2
|
-
|
3
|
-
# Root of templates path
|
4
|
-
def template_root
|
5
|
-
@template_root ||= File.expand_path(File.dirname(__FILE__) + "/../templates")
|
6
|
-
end
|
7
|
-
|
8
|
-
# Get full template path
|
9
|
-
def full_template_path(template_path)
|
10
|
-
File.join(template_root, template_path)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Load template at (full) path with binding.
|
14
|
-
# If options[:project] is true will load template relative to project root.
|
15
|
-
def load_template(path, binding, options = {})
|
16
|
-
template_path = options[:project] ? "#{root}/#{path}" : full_template_path(path)
|
17
|
-
|
18
|
-
unless File.exist?(template_path)
|
19
|
-
raise <<-EOS
|
20
|
-
|
21
|
-
Template not found: #{template_path}
|
22
|
-
|
23
|
-
EOS
|
24
|
-
end
|
25
|
-
|
26
|
-
template = ERB.new(IO.read(template_path))
|
27
|
-
template.result(binding)
|
28
|
-
end
|
29
|
-
|
30
|
-
def load_project_template(path, binding)
|
31
|
-
load_template(path, binding, { :project => true })
|
32
|
-
end
|
33
|
-
|
34
|
-
def load_file(path)
|
35
|
-
template_path = full_template_path(path)
|
36
|
-
IO.read(template_path)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Write template at (relative path) with binding to destination path.
|
40
|
-
#
|
41
|
-
# template_path is relative <tt>"capistrano/deploy.rb.erb"</tt>
|
42
|
-
def write_template(template_path, binding, dest_path, overwrite = false, verbose = true)
|
43
|
-
# This is gnarly!
|
44
|
-
relative_dest_path = Pathname.new(File.expand_path(dest_path)).relative_path_from(Pathname.new(File.expand_path(".")))
|
45
|
-
|
46
|
-
if !overwrite && File.exist?(dest_path)
|
47
|
-
puts "%10s %-40s (skipped)" % [ "create", relative_dest_path ] if verbose
|
48
|
-
return
|
49
|
-
end
|
50
|
-
|
51
|
-
puts "%10s %-40s" % [ "create", relative_dest_path ] if verbose
|
52
|
-
|
53
|
-
File.open(dest_path, "w") { |file| file.puts(load_template(template_path, binding)) }
|
54
|
-
end
|
55
|
-
|
56
|
-
# Remove files from root
|
57
|
-
def clean(files, verbose = true)
|
58
|
-
rm_files = files.collect { |f| File.join(root, f) }
|
59
|
-
rm_files.each do |rm_file|
|
60
|
-
puts "%10s %-40s" % [ "delete", rm_file ] if verbose
|
61
|
-
FileUtils.rm_rf(rm_file)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|