capitate 0.1.9 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Capfile +3 -2
- data/History.txt +6 -0
- data/Manifest.txt +28 -11
- data/bin/capitate +13 -61
- data/config/hoe.rb +2 -2
- data/docs/nginx.README +12 -0
- data/docs/recipes/centos.txt +33 -0
- data/docs/recipes/deploy-pending.txt +25 -0
- data/docs/recipes/deploy-web.txt +33 -0
- data/docs/recipes/deploy.txt +159 -0
- data/docs/recipes/docs.txt +26 -0
- data/docs/recipes/imagemagick-centos.txt +20 -0
- data/docs/recipes/imagemagick.txt +8 -0
- data/docs/recipes/index.txt +26 -0
- data/docs/recipes/memcached-centos.txt +32 -0
- data/docs/recipes/memcached.txt +35 -0
- data/docs/recipes/mongrel_cluster-centos.txt +27 -0
- data/docs/recipes/mongrel_cluster.txt +40 -0
- data/docs/recipes/monit-centos.txt +32 -0
- data/docs/recipes/monit.txt +8 -0
- data/docs/recipes/mysql-centos.txt +22 -0
- data/docs/recipes/mysql.txt +58 -0
- data/docs/recipes/nginx-centos.txt +43 -0
- data/docs/recipes/nginx.txt +51 -0
- data/docs/recipes/rails.txt +58 -0
- data/docs/recipes/ruby-centos.txt +22 -0
- data/docs/recipes/ruby.txt +8 -0
- data/docs/recipes/sphinx-centos.txt +35 -0
- data/docs/recipes/sphinx.txt +89 -0
- data/lib/capitate/cap_ext/run_via.rb +14 -0
- data/lib/capitate/plugins/gem.rb +2 -3
- data/lib/capitate/plugins/prompt.rb +24 -0
- data/lib/capitate/plugins/script.rb +29 -15
- data/lib/capitate/plugins/templates.rb +45 -40
- data/lib/capitate/plugins/yum.rb +12 -22
- data/lib/capitate/task_node.rb +28 -9
- data/lib/capitate/version.rb +2 -2
- data/lib/capitate.rb +4 -5
- data/lib/deployment/deploy.rb +42 -0
- data/lib/deployment/install-centos-rubyweb.rb +131 -0
- data/lib/recipes/centos/centos.rb +30 -21
- data/lib/recipes/centos/imagemagick.rb +9 -8
- data/lib/recipes/centos/memcached.rb +11 -21
- data/lib/recipes/centos/mongrel_cluster.rb +7 -11
- data/lib/recipes/centos/monit.rb +13 -18
- data/lib/recipes/centos/mysql.rb +6 -9
- data/lib/recipes/centos/nginx.rb +17 -30
- data/lib/recipes/centos/ruby.rb +14 -19
- data/lib/recipes/centos/sphinx.rb +14 -28
- data/lib/recipes/docs.rb +22 -6
- data/lib/recipes/memcached.rb +14 -8
- data/lib/recipes/mongrel_cluster.rb +11 -14
- data/lib/recipes/mysql.rb +22 -40
- data/lib/recipes/nginx.rb +9 -4
- data/lib/recipes/rails.rb +53 -6
- data/lib/recipes/sphinx.rb +86 -17
- data/lib/templates/capistrano/Capfile +2 -6
- data/lib/templates/monit/cert.sh +1 -1
- data/lib/templates/mysql/install_db.sql.erb +2 -2
- data/lib/templates/sphinx/sphinx.conf.erb +28 -399
- data/lib/templates/sphinx/sphinx_app.initd.centos.erb +1 -1
- data/website/index.html +20 -34
- data/website/index.txt +12 -22
- data/website/stylesheets/screen.css +22 -11
- data/website/template.rhtml +7 -5
- data/website/template_recipe.rhtml +7 -3
- metadata +55 -15
- data/lib/capitate/plugins/package.rb +0 -30
- data/lib/capitate/plugins/profiles.rb +0 -33
- data/lib/capitate/plugins/wget.rb +0 -23
- data/lib/profiles/centos-sick.rb +0 -116
- data/lib/recipes/README +0 -5
- data/lib/recipes/centos/README +0 -3
- data/lib/recipes/gems.rb +0 -20
- data/lib/recipes/packages.rb +0 -39
- data/lib/recipes/recipes.rb +0 -30
- data/lib/templates/centos/setup_for_web.sh +0 -17
- data/lib/templates/centos/sudoers +0 -95
@@ -1,22 +1,16 @@
|
|
1
1
|
module Capitate::Plugins::Templates
|
2
2
|
|
3
|
-
#
|
4
|
-
def gem_templates_root
|
5
|
-
File.expand_path(File.dirname(__FILE__) + "/../../templates")
|
6
|
-
end
|
7
|
-
|
8
|
-
# Get full template path from relative path.
|
3
|
+
# Load template. If extension is erb will be evaluated with binding.
|
9
4
|
#
|
10
|
-
#
|
5
|
+
# You can add to the list of places we search for templates by setting:
|
11
6
|
#
|
12
|
-
#
|
13
|
-
# +template_path+:: Relative path
|
7
|
+
# set :templates_dirs, [ "path/to/templates1", "/path/to/templates2" ]
|
14
8
|
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#
|
9
|
+
# It looks for the template from:
|
10
|
+
# * the <tt>:templates_dirs</tt> setting (if set)
|
11
|
+
# * the current directory
|
12
|
+
# * the <tt>:project_root</tt> setting (if set)
|
13
|
+
# * the gem templates path
|
20
14
|
#
|
21
15
|
# ==== Options
|
22
16
|
# +path+:: If starts with '/', absolute path, otherwise relative path to templates dir
|
@@ -27,21 +21,16 @@ module Capitate::Plugins::Templates
|
|
27
21
|
# put template.load("memcached/memcached.monitrc.erb"), "/tmp/memcached.monitrc"
|
28
22
|
#
|
29
23
|
def load(path, override_binding = nil)
|
30
|
-
template_paths = [ path, gem_template_path(path) ]
|
31
24
|
|
32
|
-
|
25
|
+
template_dirs_found = template_dirs.select { |dir| File.exist?("#{dir}/#{path}") }
|
33
26
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
Template not found: #{path}
|
39
|
-
|
40
|
-
EOS
|
27
|
+
# Not found anywhere, throw error
|
28
|
+
if template_dirs_found.empty?
|
29
|
+
raise "\n\nTemplate not found: #{path}\n\n"
|
41
30
|
end
|
42
31
|
|
43
32
|
# Use first
|
44
|
-
template_path =
|
33
|
+
template_path = template_dirs_found.first + "/#{path}"
|
45
34
|
|
46
35
|
template_data = IO.read(template_path)
|
47
36
|
|
@@ -51,21 +40,6 @@ module Capitate::Plugins::Templates
|
|
51
40
|
end
|
52
41
|
template_data
|
53
42
|
end
|
54
|
-
|
55
|
-
# Load template from project.
|
56
|
-
# If extension is erb will be evaluated with binding.
|
57
|
-
#
|
58
|
-
# ==== Options
|
59
|
-
# +path+:: If starts with '/', absolute path, otherwise relative path to templates dir
|
60
|
-
# +override_binding+:: Binding to override, otherwise uses current (task) binding
|
61
|
-
#
|
62
|
-
# ==== Examples
|
63
|
-
# template.project("config/templates/sphinx.conf.erb")
|
64
|
-
# put template.project("config/templates/sphinx.conf.erb"), "#{shared_path}/config/sphinx.conf"
|
65
|
-
#
|
66
|
-
def project(path, override_binding = nil)
|
67
|
-
load(project_root + "/" + path, override_binding || binding)
|
68
|
-
end
|
69
43
|
|
70
44
|
# Write template at (relative path) with binding to LOCAL destination path.
|
71
45
|
#
|
@@ -77,7 +51,7 @@ module Capitate::Plugins::Templates
|
|
77
51
|
# +verbose+:: Verbose output
|
78
52
|
#
|
79
53
|
# ==== Examples
|
80
|
-
# template.write("config/templates/sphinx.conf.erb",
|
54
|
+
# template.write("config/templates/sphinx.conf.erb", "config/sphinx.conf")
|
81
55
|
#
|
82
56
|
def write(template_path, dest_path, override_binding = nil, overwrite = false, verbose = true)
|
83
57
|
# This is gnarly!
|
@@ -93,6 +67,37 @@ module Capitate::Plugins::Templates
|
|
93
67
|
File.open(dest_path, "w") { |file| file.puts(load(template_path, override_binding)) }
|
94
68
|
end
|
95
69
|
|
70
|
+
|
71
|
+
protected
|
72
|
+
|
73
|
+
# Load all possible places for templates
|
74
|
+
def template_dirs
|
75
|
+
@template_dir ||= begin
|
76
|
+
template_dirs = []
|
77
|
+
template_dirs += fetch(:templates_dirs) if exists?(:templates_dirs)
|
78
|
+
template_dirs << [ "." ]
|
79
|
+
template_dirs << project_root if exists?(:project_root)
|
80
|
+
template_dirs << gem_templates_root
|
81
|
+
template_dirs
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Get the absolute base templates path.
|
86
|
+
def gem_templates_root
|
87
|
+
File.expand_path(File.dirname(__FILE__) + "/../../templates")
|
88
|
+
end
|
89
|
+
|
90
|
+
# Get full template path from relative path.
|
91
|
+
#
|
92
|
+
# Something like <tt>monit/monit.cnf => /usr/lib/..../capitate/lib/templates/monit/monit.cnf</tt>.
|
93
|
+
#
|
94
|
+
# ==== Options
|
95
|
+
# +template_path+:: Relative path
|
96
|
+
#
|
97
|
+
def gem_template_path(template_path)
|
98
|
+
File.join(gem_templates_root, template_path)
|
99
|
+
end
|
100
|
+
|
96
101
|
end
|
97
102
|
|
98
103
|
Capistrano.plugin :template, Capitate::Plugins::Templates
|
data/lib/capitate/plugins/yum.rb
CHANGED
@@ -10,12 +10,8 @@ module Capitate::Plugins::Yum
|
|
10
10
|
# yum.update
|
11
11
|
# yum.update([ "aspell" ])
|
12
12
|
#
|
13
|
-
# Also can use package plugin with package.type = :yum, and then:
|
14
|
-
# package.update
|
15
|
-
# package.update([ "aspell" ])
|
16
|
-
#
|
17
13
|
def update(packages = [])
|
18
|
-
|
14
|
+
run_via "yum -y update #{packages.join(" ")}"
|
19
15
|
end
|
20
16
|
|
21
17
|
# Remove via yum.
|
@@ -27,12 +23,8 @@ module Capitate::Plugins::Yum
|
|
27
23
|
# yum.remove
|
28
24
|
# yum.remove([ "aspell" ])
|
29
25
|
#
|
30
|
-
# Also can use package plugin with package.type = :yum, and then:
|
31
|
-
# package.remove
|
32
|
-
# package.remove([ "aspell" ])
|
33
|
-
#
|
34
26
|
def remove(packages)
|
35
|
-
|
27
|
+
run_via "yum -y remove #{packages.join(" ")}"
|
36
28
|
end
|
37
29
|
|
38
30
|
# Install via yum.
|
@@ -44,10 +36,6 @@ module Capitate::Plugins::Yum
|
|
44
36
|
# ==== Examples
|
45
37
|
# yum.install
|
46
38
|
# yum.install([ "aspell" ])
|
47
|
-
#
|
48
|
-
# Also can use package plugin with package.type = :yum, and then:
|
49
|
-
# package.install
|
50
|
-
# package.install([ "aspell" ])
|
51
39
|
#
|
52
40
|
def install(packages, update_existing = true)
|
53
41
|
|
@@ -58,16 +46,21 @@ module Capitate::Plugins::Yum
|
|
58
46
|
|
59
47
|
installed_packages = []
|
60
48
|
|
61
|
-
|
62
|
-
|
49
|
+
run_via "yum -d 0 list installed #{packages.join(" ")}" do |channel, stream, data|
|
50
|
+
lines = data.split("\n")[1..-1]
|
51
|
+
if lines.blank?
|
52
|
+
logger.info "Invalid yum output: #{data}"
|
53
|
+
else
|
54
|
+
installed_packages += lines.collect { |line| line.split(".").first }
|
55
|
+
end
|
63
56
|
end
|
64
57
|
|
65
58
|
packages -= installed_packages
|
66
59
|
|
67
|
-
|
60
|
+
run_via "yum -y update #{installed_packages.join(" ")}" unless installed_packages.blank?
|
68
61
|
end
|
69
62
|
|
70
|
-
|
63
|
+
run_via "yum -y install #{packages.join(" ")}" unless packages.blank?
|
71
64
|
end
|
72
65
|
|
73
66
|
# Clean yum.
|
@@ -75,11 +68,8 @@ module Capitate::Plugins::Yum
|
|
75
68
|
# ==== Examples
|
76
69
|
# yum.clean
|
77
70
|
#
|
78
|
-
# Also can use package plugin with package.type = :yum, and then:
|
79
|
-
# package.clean
|
80
|
-
#
|
81
71
|
def clean
|
82
|
-
|
72
|
+
run_via "yum -y clean all"
|
83
73
|
end
|
84
74
|
|
85
75
|
end
|
data/lib/capitate/task_node.rb
CHANGED
@@ -56,6 +56,12 @@ class Capitate::TaskNode
|
|
56
56
|
nodes.sort_by(&:name)
|
57
57
|
end
|
58
58
|
|
59
|
+
# Get tasks (sorted).
|
60
|
+
#
|
61
|
+
def sorted_tasks
|
62
|
+
tasks.sort_by(&:fully_qualified_name) # { |t| t.name.to_s }
|
63
|
+
end
|
64
|
+
|
59
65
|
# Iterate over ALL "child" nodes, depth first.
|
60
66
|
# Yields |node, level|.
|
61
67
|
#
|
@@ -87,7 +93,9 @@ class Capitate::TaskNode
|
|
87
93
|
name == "top" ? nil : name
|
88
94
|
end
|
89
95
|
|
90
|
-
# Write
|
96
|
+
# Write textile documentation for node (recursively).
|
97
|
+
#
|
98
|
+
# Uses task desc attribute for task details.
|
91
99
|
#
|
92
100
|
# ==== Options
|
93
101
|
# +dir+:: Dir to write to
|
@@ -126,22 +134,33 @@ class Capitate::TaskNode
|
|
126
134
|
#
|
127
135
|
# Namespace
|
128
136
|
#
|
129
|
-
unless
|
130
|
-
file.puts "
|
137
|
+
unless nodes.empty?
|
138
|
+
file.puts "\n\nh2. Namespaces\n\n"
|
131
139
|
each_node do |snode, level|
|
132
|
-
li_level = (0..level).collect { "*" }.join
|
133
|
-
|
140
|
+
#li_level = (0..level).collect { "*" }.join
|
141
|
+
if snode.tasks.length > 0
|
142
|
+
file.puts %{* "#{snode.full_name(":")}":#{snode.full_name}.html (#{snode.tasks.length}) \n}
|
143
|
+
end
|
134
144
|
end
|
135
145
|
end
|
136
146
|
|
137
147
|
#
|
138
148
|
# Tasks
|
149
|
+
#
|
150
|
+
unless tasks.empty?
|
151
|
+
file.puts "\n\nh2. Tasks\n\n"
|
152
|
+
sorted_tasks.each do |task|
|
153
|
+
file.puts %{* "#{task.fully_qualified_name}":##{task.fully_qualified_name} \n}
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
#
|
158
|
+
# Task details
|
139
159
|
#
|
140
160
|
unless tasks.empty?
|
141
|
-
file.puts "\n\n"
|
142
|
-
|
143
|
-
|
144
|
-
file.puts "h3. #{task.fully_qualified_name}\n\n"
|
161
|
+
file.puts "\n\nh2. Task documentation\n\n"
|
162
|
+
sorted_tasks.each do |task|
|
163
|
+
file.puts "h3(##{task.fully_qualified_name}). #{task.fully_qualified_name}\n\n"
|
145
164
|
file.puts "#{unindent(task.desc)}\n\n\n\n"
|
146
165
|
end
|
147
166
|
end
|
data/lib/capitate/version.rb
CHANGED
data/lib/capitate.rb
CHANGED
@@ -15,21 +15,20 @@ end
|
|
15
15
|
|
16
16
|
require 'capitate/plugins/base'
|
17
17
|
require 'capitate/plugins/gem'
|
18
|
-
require 'capitate/plugins/package'
|
19
|
-
require 'capitate/plugins/profiles'
|
20
18
|
require 'capitate/plugins/script'
|
19
|
+
require 'capitate/plugins/prompt'
|
21
20
|
require 'capitate/plugins/templates'
|
22
|
-
require 'capitate/plugins/wget'
|
23
|
-
require 'capitate/plugins/yum'
|
24
|
-
|
25
21
|
require 'capitate/plugins/upload'
|
22
|
+
require 'capitate/plugins/yum'
|
26
23
|
|
27
24
|
require "capitate/cap_ext/connections"
|
28
25
|
require "capitate/cap_ext/extension_proxy"
|
29
26
|
require "capitate/cap_ext/variables"
|
27
|
+
require "capitate/cap_ext/run_via"
|
30
28
|
|
31
29
|
class Capistrano::Configuration
|
32
30
|
include Capitate::CapExt::Variables
|
31
|
+
include Capitate::CapExt::RunVia
|
33
32
|
end
|
34
33
|
|
35
34
|
require 'capitate/task_node'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# Settings for project
|
3
|
+
#
|
4
|
+
|
5
|
+
set :application, "sick"
|
6
|
+
set :user, "sick"
|
7
|
+
set :groups, "admin"
|
8
|
+
|
9
|
+
set :deploy_to, "/var/www/apps/sick"
|
10
|
+
set :web_host, "192.168.1.111"
|
11
|
+
set :db_host, "192.168.1.111"
|
12
|
+
set :db_user, "sick"
|
13
|
+
set :db_pass, prompt.password("DB Password: ")
|
14
|
+
set :db_name, "sick"
|
15
|
+
set :repository, "http://svn.ducktyper.com/scratch/testapp/trunk"
|
16
|
+
set :mongrel_port, 12000
|
17
|
+
set :mongrel_size, 3
|
18
|
+
set :domain_name, "localhost"
|
19
|
+
set :mysql_admin_password, prompt.password('Mysql admin password: ')
|
20
|
+
|
21
|
+
set :deploy_via, :copy
|
22
|
+
set :copy_strategy, :export
|
23
|
+
|
24
|
+
role :web, "192.168.1.111"
|
25
|
+
role :db, "192.168.1.111", :primary => true
|
26
|
+
|
27
|
+
|
28
|
+
# Callbacks
|
29
|
+
before "deploy:setup", "centos:add_user"
|
30
|
+
|
31
|
+
after "deploy:setup", "mysql:setup", "rails:setup", "mongrel_cluster:centos:setup",
|
32
|
+
"nginx:setup_mongrel", "sphinx:centos:setup"
|
33
|
+
|
34
|
+
after "sphinx:centos:setup", "sphinx:setup_monit"
|
35
|
+
after "mongrel_cluster:centos:setup", "mongrel_cluster:setup_monit"
|
36
|
+
|
37
|
+
after "nginx:setup_mongrels", "nginx:centos:restart"
|
38
|
+
|
39
|
+
after "deploy:update_code", "rails:update_code", "sphinx:update_code"
|
40
|
+
|
41
|
+
# Auto cleanup after deploy
|
42
|
+
after "deploy", "deploy:cleanup"
|
@@ -0,0 +1,131 @@
|
|
1
|
+
#
|
2
|
+
# This is an EXAMPLE deployment script based on some recipes in Capitate.
|
3
|
+
#
|
4
|
+
|
5
|
+
#
|
6
|
+
# For installing apps on the thoughpolice centos 5.1 image
|
7
|
+
#
|
8
|
+
task :install do
|
9
|
+
|
10
|
+
# Set templates dir to this here gem
|
11
|
+
set :templates_dirs, [ File.dirname(__FILE__) + "/../templates" ]
|
12
|
+
|
13
|
+
set :user, "root"
|
14
|
+
set :run_method, :run
|
15
|
+
|
16
|
+
# Can use cap HOSTS=192.168.1.111 install
|
17
|
+
# Otherwise prompt for the service
|
18
|
+
role :install, prompt.ask("Server: ") if find_servers_for_task(current_task).blank?
|
19
|
+
|
20
|
+
# Setup for web
|
21
|
+
# * Add admin group
|
22
|
+
# * Change inittab to runlevel 3
|
23
|
+
# * Create web apps directory
|
24
|
+
# * Add admin group to suders ALL=(ALL) ALL
|
25
|
+
script.run_all <<-CMDS
|
26
|
+
egrep "^admin" /etc/group || /usr/sbin/groupadd admin
|
27
|
+
sed -i -e 's/^id:5:initdefault:/id:3:initdefault:/g' /etc/inittab
|
28
|
+
mkdir -p /var/www/apps
|
29
|
+
egrep "^%admin" /etc/sudoers || echo "%admin ALL=(ALL) ALL" > /etc/sudoers
|
30
|
+
CMDS
|
31
|
+
|
32
|
+
# Package installs
|
33
|
+
yum.remove [ "openoffice.org-*", "ImageMagick" ]
|
34
|
+
yum.update
|
35
|
+
yum.install [ "gcc", "kernel-devel", "libevent-devel", "libxml2-devel", "openssl", "openssl-devel",
|
36
|
+
"aspell", "aspell-devel", "aspell-en", "aspell-es" ]
|
37
|
+
|
38
|
+
#
|
39
|
+
# App installs
|
40
|
+
#
|
41
|
+
|
42
|
+
ruby.centos.install
|
43
|
+
# Fix ruby install openssl
|
44
|
+
script.sh("ruby/fix_openssl.sh")
|
45
|
+
|
46
|
+
nginx.centos.install
|
47
|
+
mysql.centos.install
|
48
|
+
sphinx.centos.install
|
49
|
+
monit.centos.install
|
50
|
+
imagemagick.centos.install
|
51
|
+
memcached.centos.install
|
52
|
+
|
53
|
+
#
|
54
|
+
# Install monit hooks
|
55
|
+
#
|
56
|
+
nginx.install_monit
|
57
|
+
mysql.install_monit
|
58
|
+
|
59
|
+
# Gem installs
|
60
|
+
gems.install([ "rake", "mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --with-mysql-config",
|
61
|
+
"raspell", "rmagick", "mongrel", "mongrel_cluster","json" ])
|
62
|
+
|
63
|
+
# Cleanup
|
64
|
+
yum.clean
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
# For mysql:install
|
69
|
+
set :mysql_pid_path, "/var/run/mysqld/mysqld.pid"
|
70
|
+
set :db_port, 3306
|
71
|
+
|
72
|
+
# For sphinx:install
|
73
|
+
set :sphinx_prefix, "/usr/local/sphinx"
|
74
|
+
|
75
|
+
|
76
|
+
#
|
77
|
+
# Install options
|
78
|
+
#
|
79
|
+
|
80
|
+
# Ruby install
|
81
|
+
set :ruby_build_options, {
|
82
|
+
:url => "http://capigen.s3.amazonaws.com/ruby-1.8.6-p110.tar.gz",
|
83
|
+
:build_dest => "/usr/src",
|
84
|
+
:configure_options => "--prefix=/usr",
|
85
|
+
:clean => false
|
86
|
+
}
|
87
|
+
|
88
|
+
set :rubygems_build_options, {
|
89
|
+
:url => "http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz"
|
90
|
+
}
|
91
|
+
|
92
|
+
# Memcached install
|
93
|
+
set :memcached_pid_path, "/var/run/memcached.pid"
|
94
|
+
set :memcached_memory, 64
|
95
|
+
set :memcached_port, 11211
|
96
|
+
set :memcached_build_options, {
|
97
|
+
:url => "http://www.danga.com/memcached/dist/memcached-1.2.4.tar.gz",
|
98
|
+
:configure_options => "--prefix=/usr/local"
|
99
|
+
}
|
100
|
+
|
101
|
+
# Monit install
|
102
|
+
set :monit_conf_dir, "/etc/monit"
|
103
|
+
set :monit_port, 2812
|
104
|
+
set :monit_build_options, {
|
105
|
+
:url => "http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz"
|
106
|
+
}
|
107
|
+
|
108
|
+
# Nginx install
|
109
|
+
set :nginx_bin_path, "/sbin/nginx"
|
110
|
+
set :nginx_conf_path, "/etc/nginx/nginx.conf"
|
111
|
+
set :nginx_pid_path, "/var/run/nginx.pid"
|
112
|
+
set :nginx_prefix_path, "/var/nginx"
|
113
|
+
set :nginx_build_options, {
|
114
|
+
:url => "http://sysoev.ru/nginx/nginx-0.5.35.tar.gz",
|
115
|
+
:configure_options => "--sbin-path=#{nginx_bin_path} --conf-path=#{nginx_conf_path} \
|
116
|
+
--pid-path=#{nginx_pid_path} --error-log-path=/var/log/nginx_master_error.log --lock-path=/var/lock/nginx \
|
117
|
+
--prefix=#{nginx_prefix_path} --with-md5=auto/lib/md5 --with-sha1=auto/lib/sha1 --with-http_ssl_module"
|
118
|
+
}
|
119
|
+
|
120
|
+
# Sphinx install
|
121
|
+
set :sphinx_build_options, {
|
122
|
+
:url => "http://www.sphinxsearch.com/downloads/sphinx-0.9.7.tar.gz",
|
123
|
+
:configure_options => "--with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql \
|
124
|
+
--prefix=#{sphinx_prefix}"
|
125
|
+
}
|
126
|
+
|
127
|
+
# Imagemagick install
|
128
|
+
set :imagemagick_build_options, {
|
129
|
+
:url => "ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz",
|
130
|
+
:unpack_dir => "ImageMagick-*"
|
131
|
+
}
|
@@ -1,34 +1,43 @@
|
|
1
1
|
# Custom tasks for centos OS profiles
|
2
2
|
namespace :centos do
|
3
|
-
|
4
|
-
desc "Setup centos for web"
|
5
|
-
task :setup_for_web do
|
6
|
-
put template.load("centos/sudoers"), "/tmp/sudoers"
|
7
|
-
script.sh("centos/setup_for_web.sh")
|
8
|
-
end
|
9
|
-
|
10
|
-
desc "Cleanup"
|
11
|
-
task :cleanup do
|
12
|
-
yum.clean
|
13
|
-
# TODO: Add cleanup tasks here
|
14
|
-
end
|
15
|
-
|
3
|
+
|
16
4
|
# Add user for an application
|
17
|
-
desc
|
18
|
-
|
5
|
+
desc <<-DESC
|
6
|
+
Add user and set user password for application. Adds user to specified groups.
|
7
|
+
|
8
|
+
*user*: User to add.\n
|
9
|
+
@set :user, "app_user"@
|
10
|
+
*groups*: Groups for user to be in. _Defaults to none_\n
|
11
|
+
@set :groups, "admin,foo"@\n
|
12
|
+
*home*: Home directory for user. _Defaults to <tt>:deploy_to</tt> setting_\n
|
13
|
+
@set :home, "/var/www/apps/app_name"@\n
|
14
|
+
*home_readable*: Whether home permissions are readable by all. Needed if using deploy dir as home. _Defaults to true_\n
|
15
|
+
@set :home_readable, true@\n
|
16
|
+
DESC
|
17
|
+
task :add_user do
|
19
18
|
|
20
19
|
# Settings
|
21
|
-
|
22
|
-
fetch_or_default(:
|
20
|
+
fetch(:user)
|
21
|
+
fetch_or_default(:groups, nil)
|
22
|
+
fetch_or_default(:home, deploy_to)
|
23
|
+
fetch_or_default(:home_readable, true)
|
24
|
+
|
25
|
+
# Need to be root because we don't have any other users at this point
|
26
|
+
install_user = "root"
|
23
27
|
|
24
28
|
with_user(install_user) do
|
29
|
+
|
30
|
+
adduser_options = []
|
31
|
+
adduser_options << "-d #{home}" unless home.blank?
|
32
|
+
adduser_options << "-G #{groups}" unless groups.blank?
|
25
33
|
|
26
|
-
|
27
|
-
|
34
|
+
run "id sick || /usr/sbin/adduser #{adduser_options.join(" ")} #{user}"
|
35
|
+
|
36
|
+
run "chmod a+rx #{home}" if home_readable
|
28
37
|
|
29
|
-
new_password =
|
38
|
+
new_password = prompt.password("Password for user (#{user}): ", true)
|
30
39
|
|
31
|
-
|
40
|
+
run "passwd #{user}" do |channel, stream, data|
|
32
41
|
logger.info data
|
33
42
|
|
34
43
|
if data =~ /password:/i
|
@@ -1,19 +1,20 @@
|
|
1
1
|
namespace :imagemagick do
|
2
2
|
namespace :centos do
|
3
3
|
|
4
|
-
desc
|
4
|
+
desc <<-DESC
|
5
|
+
Install imagemagick.\n
|
6
|
+
*imagemagick_build_options*: Imagemagick build options.
|
7
|
+
DESC
|
5
8
|
task :install do
|
6
9
|
|
10
|
+
# Settings
|
11
|
+
fetch(:imagemagick_build_options)
|
12
|
+
|
7
13
|
# Install dependencies
|
8
14
|
yum.install([ "libjpeg-devel", "libpng-devel", "glib2-devel", "fontconfig-devel", "zlib-devel",
|
9
15
|
"libwmf-devel", "freetype-devel", "libtiff-devel" ])
|
10
|
-
|
11
|
-
|
12
|
-
:url => "ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz",
|
13
|
-
:unpack_dir => "ImageMagick-*"
|
14
|
-
}
|
15
|
-
|
16
|
-
script.make_install("imagemagick", imagemagick_options)
|
16
|
+
|
17
|
+
script.make_install("imagemagick", imagemagick_build_options)
|
17
18
|
end
|
18
19
|
|
19
20
|
end
|
@@ -5,18 +5,13 @@ namespace :memcached do
|
|
5
5
|
desc <<-DESC
|
6
6
|
Install memcached.
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
memcached_pid_path
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
memcached_port: Memcached port. Defaults to 11211.
|
17
|
-
|
18
|
-
set :memcached_port, 11211
|
19
|
-
|
8
|
+
*memcached_build_options*: Memcached build options.\n
|
9
|
+
*memcached_memory*: Memcached memory (in MB).\n
|
10
|
+
@set :memcached_memory, 64@\n
|
11
|
+
*memcached_pid_path*: Path to memcached pid file. Defaults to /var/run/memcached.pid\n
|
12
|
+
@set :memcached_pid_path, "/var/run/memcached.pid"@\n
|
13
|
+
*memcached_port*: Memcached port. Defaults to 11211.\n
|
14
|
+
@set :memcached_port, 11211@\n
|
20
15
|
DESC
|
21
16
|
task :install do
|
22
17
|
|
@@ -24,20 +19,15 @@ namespace :memcached do
|
|
24
19
|
fetch_or_default(:memcached_pid_path, "/var/run/memcached.pid")
|
25
20
|
fetch_or_default(:memcached_port, 11211)
|
26
21
|
fetch(:memcached_memory)
|
27
|
-
|
28
|
-
# Build options
|
29
|
-
memcached_options = {
|
30
|
-
:url => "http://www.danga.com/memcached/dist/memcached-1.2.4.tar.gz",
|
31
|
-
:configure_options => "--prefix=/usr/local"
|
32
|
-
}
|
22
|
+
fetch(:memcached_build_options)
|
33
23
|
|
34
24
|
# Build
|
35
|
-
script.make_install("memcached",
|
25
|
+
script.make_install("memcached", memcached_build_options)
|
36
26
|
|
37
27
|
# Install initscript, service
|
38
28
|
put template.load("memcached/memcached.initd.centos.erb"), "/tmp/memcached.initd"
|
39
|
-
|
40
|
-
|
29
|
+
run_via "install -o root /tmp/memcached.initd /etc/init.d/memcached && rm -f /tmp/memcached.initd"
|
30
|
+
run_via "/sbin/chkconfig --level 345 memcached on"
|
41
31
|
|
42
32
|
end
|
43
33
|
|
@@ -5,15 +5,11 @@ namespace :mongrel_cluster do
|
|
5
5
|
desc <<-DESC
|
6
6
|
Create mongrel cluster.
|
7
7
|
|
8
|
-
mongrel_size
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
mongrel_port
|
13
|
-
9000, 9001, and 9002
|
14
|
-
|
15
|
-
set :mongrel_port, 9000
|
16
|
-
|
8
|
+
*mongrel_size*: Number of mongrels.\n
|
9
|
+
@set :mongrel_size, 3@\n
|
10
|
+
*mongrel_port*: Starting port for mongrels. If there are 3 mongrels with port 9000,
|
11
|
+
then instances will be at 9000, 9001, and 9002\n
|
12
|
+
@set :mongrel_port, 9000@\n
|
17
13
|
DESC
|
18
14
|
task :setup do
|
19
15
|
|
@@ -29,8 +25,8 @@ namespace :mongrel_cluster do
|
|
29
25
|
|
30
26
|
pid_path = "#{shared_path}/pids"
|
31
27
|
|
32
|
-
put template.load("mongrel/mongrel_cluster.initd.erb"
|
33
|
-
put template.load("mongrel/mongrel_cluster.yml.erb"
|
28
|
+
put template.load("mongrel/mongrel_cluster.initd.erb"), "/tmp/mongrel_cluster_#{application}.initd"
|
29
|
+
put template.load("mongrel/mongrel_cluster.yml.erb"), "#{mongrel_config_path}/mongrel_cluster.yml"
|
34
30
|
|
35
31
|
# Setup the mongrel_cluster init script
|
36
32
|
sudo "install -o root /tmp/mongrel_cluster_#{application}.initd /etc/init.d/mongrel_cluster_#{application}"
|