capitate 0.2.8 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Capfile +22 -0
- data/History.txt +18 -0
- data/Manifest.txt +13 -3
- data/lib/capitate/plugins/prompt.rb +8 -2
- data/lib/capitate/plugins/script.rb +4 -1
- data/lib/capitate/plugins/utils.rb +94 -4
- data/lib/capitate/version.rb +1 -1
- data/lib/deployment/centos-5.1-64-web/install.rb +28 -21
- data/lib/recipes/backgroundrb.rb +30 -0
- data/lib/recipes/centos/backgroundrb.rb +27 -0
- data/lib/recipes/centos/monit.rb +24 -9
- data/lib/recipes/logrotate/mongrel_cluster.rb +24 -0
- data/lib/recipes/logrotate/monit.rb +23 -0
- data/lib/recipes/logrotate/nginx.rb +37 -0
- data/lib/recipes/logrotate/rails.rb +21 -0
- data/lib/recipes/logrotate/sphinx.rb +21 -0
- data/lib/recipes/logrotated.rb +64 -0
- data/lib/recipes/memcached.rb +22 -0
- data/lib/recipes/rails.rb +41 -31
- data/lib/recipes/sshd.rb +50 -1
- data/lib/recipes/syslogd.rb +57 -0
- data/lib/templates/backgroundrb/backgroundrb.initd.centos.erb +58 -0
- data/lib/templates/backgroundrb/backgroundrb.yml.erb +10 -0
- data/lib/templates/logrotated/conf.erb +3 -0
- data/lib/templates/memcached/memcached.yml.erb +14 -0
- data/lib/templates/monit/monit.initd.centos.erb +1 -1
- data/lib/templates/sphinx/sphinx_app.initd.centos.erb +1 -1
- data/website/index.html +1 -1
- metadata +15 -5
- data/lib/deployment/deploy.rb +0 -37
- data/lib/templates/monit/cert.sh +0 -14
- data/lib/templates/monit/patch_inittab.sh +0 -15
data/Capfile
CHANGED
@@ -11,3 +11,25 @@ require 'lib/capitate/recipes'
|
|
11
11
|
|
12
12
|
require 'erb'
|
13
13
|
|
14
|
+
# Test
|
15
|
+
task :test_egrep do
|
16
|
+
role :test, "10.0.6.118", :user => "root"
|
17
|
+
|
18
|
+
found = utils.egrep("^mail.\\*", "/etc/syslog.conf")
|
19
|
+
puts "Found? #{found}"
|
20
|
+
|
21
|
+
found = utils.egrep("^fooo", "/etc/syslog.conf")
|
22
|
+
puts "Found? #{found}"
|
23
|
+
end
|
24
|
+
|
25
|
+
task :test_app do
|
26
|
+
set :application, "sick"
|
27
|
+
set :deploy_to, "/var/www/apps/sick"
|
28
|
+
role :web, "10.0.6.118", :user => "root"
|
29
|
+
role :app, "10.0.6.118", :user => "root"
|
30
|
+
end
|
31
|
+
|
32
|
+
task :test_install do
|
33
|
+
load File.dirname(__FILE__) + "/lib/deployment/centos-5.1-64-web/install.rb"
|
34
|
+
role :test, "10.0.6.118", :user => "root"
|
35
|
+
end
|
data/History.txt
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
== 0.2.11 2008-03-25
|
2
|
+
|
3
|
+
* Backgroundrb recipes and templates
|
4
|
+
* Memcached yml template and recipe
|
5
|
+
* Rails update code task
|
6
|
+
|
7
|
+
== 0.2.9 <never>
|
8
|
+
|
9
|
+
* SSH keygen and authorize key recipes
|
10
|
+
* Updated rails:setup recipe to include option for specifying path to database yml template
|
11
|
+
* Logrotate recipes
|
12
|
+
|
13
|
+
* Plugin adds/changes:
|
14
|
+
** utils.install_template
|
15
|
+
** utils.append_to
|
16
|
+
** utils.egrep
|
17
|
+
** utils.exist?
|
18
|
+
|
1
19
|
== 0.2.8 2008-03-13
|
2
20
|
|
3
21
|
* Recipe, mysql:centos:install, doing restart incase already run
|
data/Manifest.txt
CHANGED
@@ -26,7 +26,8 @@ lib/capitate/recipes.rb
|
|
26
26
|
lib/capitate/task_node.rb
|
27
27
|
lib/capitate/version.rb
|
28
28
|
lib/deployment/centos-5.1-64-web/install.rb
|
29
|
-
lib/
|
29
|
+
lib/recipes/backgroundrb.rb
|
30
|
+
lib/recipes/centos/backgroundrb.rb
|
30
31
|
lib/recipes/centos/centos.rb
|
31
32
|
lib/recipes/centos/imagemagick.rb
|
32
33
|
lib/recipes/centos/memcached.rb
|
@@ -37,6 +38,12 @@ lib/recipes/centos/nginx.rb
|
|
37
38
|
lib/recipes/centos/ruby.rb
|
38
39
|
lib/recipes/centos/sphinx.rb
|
39
40
|
lib/recipes/docs.rb
|
41
|
+
lib/recipes/logrotate/mongrel_cluster.rb
|
42
|
+
lib/recipes/logrotate/monit.rb
|
43
|
+
lib/recipes/logrotate/nginx.rb
|
44
|
+
lib/recipes/logrotate/rails.rb
|
45
|
+
lib/recipes/logrotate/sphinx.rb
|
46
|
+
lib/recipes/logrotated.rb
|
40
47
|
lib/recipes/memcached.rb
|
41
48
|
lib/recipes/mongrel_cluster.rb
|
42
49
|
lib/recipes/monit.rb
|
@@ -45,17 +52,20 @@ lib/recipes/nginx.rb
|
|
45
52
|
lib/recipes/rails.rb
|
46
53
|
lib/recipes/sphinx.rb
|
47
54
|
lib/recipes/sshd.rb
|
55
|
+
lib/recipes/syslogd.rb
|
56
|
+
lib/templates/backgroundrb/backgroundrb.initd.centos.erb
|
57
|
+
lib/templates/backgroundrb/backgroundrb.yml.erb
|
48
58
|
lib/templates/capistrano/Capfile
|
59
|
+
lib/templates/logrotated/conf.erb
|
49
60
|
lib/templates/memcached/memcached.initd.centos.erb
|
50
61
|
lib/templates/memcached/memcached.monitrc.erb
|
62
|
+
lib/templates/memcached/memcached.yml.erb
|
51
63
|
lib/templates/mongrel/mongrel_cluster.initd.erb
|
52
64
|
lib/templates/mongrel/mongrel_cluster.monitrc.erb
|
53
65
|
lib/templates/mongrel/mongrel_cluster.yml.erb
|
54
|
-
lib/templates/monit/cert.sh
|
55
66
|
lib/templates/monit/monit.cnf
|
56
67
|
lib/templates/monit/monit.initd.centos.erb
|
57
68
|
lib/templates/monit/monitrc.erb
|
58
|
-
lib/templates/monit/patch_inittab.sh
|
59
69
|
lib/templates/mysql/install_db.sql.erb
|
60
70
|
lib/templates/mysql/mysql.monitrc.erb
|
61
71
|
lib/templates/nginx/nginx.conf.erb
|
@@ -1,8 +1,14 @@
|
|
1
1
|
require 'md5'
|
2
2
|
|
3
3
|
module Capitate::Plugins::Prompt
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
# Prompt.
|
6
|
+
#
|
7
|
+
# ==== Options
|
8
|
+
# +label+:: Label
|
9
|
+
# +options+:: Options (none yet)
|
10
|
+
#
|
11
|
+
def ask(label, options = {}, &block)
|
6
12
|
Capistrano::CLI.ui.ask(label, &block)
|
7
13
|
end
|
8
14
|
|
@@ -74,6 +74,9 @@ module Capitate::Plugins::Script
|
|
74
74
|
end
|
75
75
|
|
76
76
|
# Run all commands (separated by newlines).
|
77
|
+
#
|
78
|
+
# Uses run_via to execute, so will use <tt>run</tt> or <tt>sudo</tt>
|
79
|
+
# depending on the current <tt>:run_method</tt>
|
77
80
|
#
|
78
81
|
# ==== Options
|
79
82
|
# +cmds+:: Commands (separated by newlines)
|
@@ -84,7 +87,7 @@ module Capitate::Plugins::Script
|
|
84
87
|
cmd = cmd.gsub(/^\s+/, "")
|
85
88
|
run_via(cmd, options, &block)
|
86
89
|
end
|
87
|
-
end
|
90
|
+
end
|
88
91
|
|
89
92
|
end
|
90
93
|
|
@@ -6,7 +6,8 @@ module Capitate::Plugins::Utils
|
|
6
6
|
# +args+:: Arguments. If argument is hash, then key is symlinked to value.
|
7
7
|
#
|
8
8
|
# ==== Examples
|
9
|
-
# ln("src/foo" => "dest/foo") # Run: ln -nfs src/foo dest/foo
|
9
|
+
# utils.ln("src/foo" => "dest/foo") # Run: ln -nfs src/foo dest/foo
|
10
|
+
# utils.ln("src/foo" => "dest/foo", "src/bar" => "dest/bar") # Links both
|
10
11
|
#
|
11
12
|
def ln(*args)
|
12
13
|
args.each do |arg|
|
@@ -18,9 +19,98 @@ module Capitate::Plugins::Utils
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
# Load template and install it.
|
23
|
+
# Removes temporary files during transfer and ensures desination directory is created before install.
|
24
|
+
#
|
25
|
+
# See template plugin for where template paths are loaded from.
|
26
|
+
#
|
27
|
+
# ==== Options
|
28
|
+
# +template_path+:: Path to template
|
29
|
+
# +destination+:: Remote path to evaluated template
|
30
|
+
# +options+::
|
31
|
+
# - +user+:: User to install (-o)
|
32
|
+
# - +mode+:: Mode to install file (-m)
|
33
|
+
#
|
34
|
+
# ==== Example
|
35
|
+
# utils.install_template("monit/memcached.monitrc.erb", "/etc/monit/memcached.monitrc")
|
36
|
+
#
|
37
|
+
def install_template(template_path, destination, options = {})
|
38
|
+
# Truncate extension
|
39
|
+
tmp_file_path = template_path.gsub("/", "_").gsub(/.erb$/, "")
|
40
|
+
tmp_path = "/tmp/#{tmp_file_path}"
|
41
|
+
|
42
|
+
options[:user] ||= "root"
|
43
|
+
|
44
|
+
install_options = []
|
45
|
+
install_options << "-o #{options[:user]}"
|
46
|
+
install_options << "-m #{options[:mode]}" if options.has_key?(:mode)
|
47
|
+
|
48
|
+
put template.load(template_path), tmp_path
|
49
|
+
# TOOD: Ensure directory exists? mkdir -p #{File.dirname(destination)}
|
50
|
+
run_via "install #{install_options.join(" ")} #{tmp_path} #{destination} && rm -f #{tmp_path}"
|
51
|
+
end
|
52
|
+
|
53
|
+
# Grep file for regex. Returns true if found, false otherwise.
|
54
|
+
#
|
55
|
+
# ==== Options
|
56
|
+
# +grep+:: Regular expression
|
57
|
+
# +path+:: Path to file
|
58
|
+
#
|
59
|
+
# ==== Example
|
60
|
+
# utils.egrep("^mail.\\*", "/etc/syslog.conf") => true
|
61
|
+
#
|
62
|
+
def egrep(grep, path)
|
63
|
+
found = true
|
64
|
+
run_via %{egrep '#{grep}' #{path} || echo $?} do |channel, stream, data|
|
65
|
+
if data =~ /^(\d+)/
|
66
|
+
if $1.to_i > 0
|
67
|
+
logger.trace "Not found"
|
68
|
+
found = false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
found
|
73
|
+
end
|
74
|
+
|
75
|
+
# Check if file exists.
|
76
|
+
#
|
77
|
+
# ==== Options
|
78
|
+
# +path+:: Path to file
|
79
|
+
#
|
80
|
+
def exist?(path)
|
81
|
+
found = true
|
82
|
+
run_via "head -1 #{path} >/dev/null 2>&1 || echo $?" do |channel, stream, data|
|
83
|
+
if data =~ /^(\d+)/
|
84
|
+
if $1.to_i > 0
|
85
|
+
logger.trace "Not found"
|
86
|
+
found = false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
found
|
91
|
+
end
|
92
|
+
|
93
|
+
# Append data to a file.
|
94
|
+
# Optionally check that it exists before adding.
|
95
|
+
#
|
96
|
+
# ==== Options
|
97
|
+
# +path+:: Path to file to append to
|
98
|
+
# +data+:: String data to append
|
99
|
+
# +check+:: If not nil, will check to see if egrep matches "^string_to_check" and will not re-append
|
100
|
+
# +left_strip+:: If true (default), remove whitespace before lines
|
101
|
+
# +should_exist+:: If true (default), raise error if file does not exist
|
102
|
+
#
|
103
|
+
def append_to(path, data, check = nil, left_strip = true, should_exist = true)
|
104
|
+
# If checking and found expression then abort append
|
105
|
+
return if check and egrep(check, path)
|
106
|
+
|
107
|
+
# If should exist and doesn't then abort append
|
108
|
+
raise "Can't append to file. File should exist: #{path}" if should_exist and !exist?(path)
|
109
|
+
|
110
|
+
data.split("\n").each do |line|
|
111
|
+
line = line.gsub(/^\s+/, "") if left_strip
|
112
|
+
run_via "echo '#{line}' >> #{path}"
|
113
|
+
end
|
24
114
|
end
|
25
115
|
|
26
116
|
end
|
data/lib/capitate/version.rb
CHANGED
@@ -1,25 +1,39 @@
|
|
1
|
-
#
|
1
|
+
#
|
2
|
+
# Install recipe for Centos 5.1 x86_64 (@base install)
|
3
|
+
#
|
4
|
+
# To use this script:
|
5
|
+
#
|
6
|
+
# cap HOSTS=10.0.6.118:2023 -s user=root -f install.rb install
|
7
|
+
#
|
8
|
+
# Centos 5.1 x86_64 with packages, including:
|
9
|
+
# * Ruby
|
10
|
+
# * Nginx
|
11
|
+
# * Mysql
|
12
|
+
# * Sphinx
|
13
|
+
# * Monit
|
14
|
+
# * ImageMagick
|
15
|
+
# * Memcached
|
16
|
+
# * Gems: rake, mysql, raspell, rmagick, mongrel, mongrel_cluster, json, mime-types, hpricot
|
17
|
+
#
|
2
18
|
|
3
19
|
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
|
4
20
|
|
5
21
|
require 'erb'
|
6
22
|
|
7
23
|
# Load capitate
|
24
|
+
gem 'capitate', '>= 0.2.9'
|
8
25
|
require 'capitate'
|
9
26
|
require 'capitate/recipes'
|
10
27
|
|
11
28
|
# Load more recipes
|
12
29
|
Dir[File.dirname(__FILE__) + "/recipes/*.rb"].each { |recipe| load recipe }
|
13
30
|
|
14
|
-
# Add a templates dir
|
15
|
-
set :templates_dirs, [ File.dirname(__FILE__) + "/templates" ]
|
16
|
-
|
17
|
-
# Install task
|
18
31
|
namespace :install do
|
19
32
|
|
20
33
|
task :default do
|
21
34
|
|
22
|
-
|
35
|
+
set :user, "root"
|
36
|
+
set :run_method, :run
|
23
37
|
check_role
|
24
38
|
|
25
39
|
# NTP Setup
|
@@ -74,13 +88,15 @@ namespace :install do
|
|
74
88
|
memcached.monit.install
|
75
89
|
|
76
90
|
# Install gems
|
77
|
-
|
91
|
+
gems_only
|
78
92
|
|
79
|
-
# Install renderer
|
80
|
-
renderer.install
|
81
|
-
|
82
93
|
# Cleanup
|
83
94
|
yum.clean
|
95
|
+
|
96
|
+
# Log rotate tasks
|
97
|
+
monit.logrotate.install
|
98
|
+
nginx.logrotate.install
|
99
|
+
|
84
100
|
end
|
85
101
|
|
86
102
|
desc "Install gems only"
|
@@ -89,15 +105,6 @@ namespace :install do
|
|
89
105
|
end
|
90
106
|
end
|
91
107
|
|
92
|
-
#
|
93
|
-
# To be root, cap as_root nginx:centos:install
|
94
|
-
#
|
95
|
-
desc "Be root"
|
96
|
-
task :as_root do
|
97
|
-
set :user, "root"
|
98
|
-
set :run_method, :run
|
99
|
-
end
|
100
|
-
|
101
108
|
# Prompt for server if host not given
|
102
109
|
task :check_role do
|
103
110
|
# Can use cap HOSTS=192.168.1.111 install
|
@@ -185,5 +192,5 @@ set :imagemagick_build_options, {
|
|
185
192
|
}
|
186
193
|
|
187
194
|
# For sshd:monit:install
|
188
|
-
set :sshd_pid_path, "/var/run/
|
189
|
-
set :sshd_port, 2023
|
195
|
+
set :sshd_pid_path, "/var/run/sshd.pid"
|
196
|
+
set :sshd_port, 2023
|
@@ -0,0 +1,30 @@
|
|
1
|
+
namespace :backgroundrb do
|
2
|
+
|
3
|
+
desc <<-DESC
|
4
|
+
Create backgroundrb.yml configuration.
|
5
|
+
|
6
|
+
For pid path support, change backgroundrb script pid_file line to:
|
7
|
+
|
8
|
+
pid_file = "\#{CONFIG_FILE[:backgroundrb][:pid_file]}"
|
9
|
+
|
10
|
+
*backgroundrb_host*: Backgroundrb host. _Defaults to 0.0.0.0_\n
|
11
|
+
*backgroundrb_port*: Backgroundrb port. _Defaults to 11006_\n
|
12
|
+
*backgroundrb_yml_template*: Backgroundrb yml template. _Defaults to @backgroundrb/backgroundrb.yml.erb@ in this gem.\n
|
13
|
+
DESC
|
14
|
+
task :setup do
|
15
|
+
fetch_or_default(:backgroundrb_host, "0.0.0.0")
|
16
|
+
fetch_or_default(:backgroundrb_port, 11006)
|
17
|
+
fetch_or_default(:backgroundrb_pid_path, "#{shared_path}/pids/backgroundrb.pid")
|
18
|
+
fetch_or_default(:backgroundrb_yml_template, "backgroundrb/backgroundrb.yml.erb")
|
19
|
+
|
20
|
+
utils.install_template(backgroundrb_yml_template, "#{shared_path}/config/backgroundrb.yml")
|
21
|
+
end
|
22
|
+
|
23
|
+
desc <<-DESC
|
24
|
+
Symlink backgroundrb config into release path.
|
25
|
+
DESC
|
26
|
+
task :update_code do
|
27
|
+
run "ln -nfs #{shared_path}/config/backgroundrb.yml #{release_path}/config/backgroundrb.yml"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
namespace :backgroundrb do
|
2
|
+
|
3
|
+
namespace :centos do
|
4
|
+
|
5
|
+
desc <<-DESC
|
6
|
+
Setup backgroundrb for application.
|
7
|
+
|
8
|
+
*backgroundrb_bin_path*: Path to start. _Defaults to @{current_path}/script/backgroundrb start@_\n
|
9
|
+
*backgroundrb_pid_path*: Path to backgroundrb pid file. _Defaults to @{shared_path}/pids/backgroundrb.pid@_\n
|
10
|
+
DESC
|
11
|
+
task :setup do
|
12
|
+
|
13
|
+
# Settings
|
14
|
+
fetch_or_default(:backgroundrb_bin_path, "#{current_path}/script/backgroundrb -e production")
|
15
|
+
fetch_or_default(:backgroundrb_pid_path, "#{shared_path}/pids/backgroundrb.pid")
|
16
|
+
|
17
|
+
# Install initscript
|
18
|
+
utils.install_template("backgroundrb/backgroundrb.initd.centos.erb", "/etc/init.d/backgroundrb_#{application}")
|
19
|
+
|
20
|
+
# Enable service
|
21
|
+
run_via "/sbin/chkconfig --level 345 backgroundrb_#{application} on"
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/recipes/centos/monit.rb
CHANGED
@@ -15,6 +15,7 @@ namespace :monit do
|
|
15
15
|
@set :monit_conf_dir, "/etc/monit"@\n
|
16
16
|
*monit_pid_path*: Path to monit pid.\n
|
17
17
|
@set :monit_pid_path, "/var/run/monit.pid"@\n
|
18
|
+
*monit_log_path*: Path to monit log file.\n _Defaults to <tt>/var/log/monit.log</tt>_
|
18
19
|
DESC
|
19
20
|
task :install do
|
20
21
|
|
@@ -23,28 +24,42 @@ namespace :monit do
|
|
23
24
|
fetch_or_default(:monit_password, prompt.password('Monit admin password (to set): ', :verify => true))
|
24
25
|
fetch_or_default(:monit_conf_dir, "/etc/monit")
|
25
26
|
fetch_or_default(:monit_pid_path, "/var/run/monit.pid")
|
27
|
+
fetch_or_default(:monit_log_path, "/var/log/monit.log")
|
26
28
|
fetch(:monit_build_options)
|
27
29
|
|
28
30
|
# Install dependencies
|
29
31
|
yum.install([ "flex", "byacc" ])
|
30
32
|
|
31
33
|
# Build
|
32
|
-
build.make_install("monit", monit_build_options)
|
34
|
+
#build.make_install("monit", monit_build_options)
|
33
35
|
|
34
36
|
# Install initscript
|
35
|
-
|
36
|
-
run_via "install -o root /tmp/monit.initd /etc/init.d/monit && rm -f /tmp/monit.initd"
|
37
|
+
utils.install_template("monit/monit.initd.centos.erb", "/etc/init.d/monit")
|
37
38
|
|
38
39
|
# Install monitrc
|
39
|
-
|
40
|
-
|
40
|
+
run_via "mkdir -p /etc/monit"
|
41
|
+
utils.install_template("monit/monitrc.erb", "/etc/monitrc", :user => "root", :mode => "700")
|
41
42
|
|
42
43
|
# Build cert
|
43
|
-
|
44
|
-
|
44
|
+
run_via "mkdir -p /var/certs"
|
45
|
+
utils.install_template("monit/monit.cnf", "/var/certs/monit.cnf")
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
script.run_all <<-CMDS
|
48
|
+
openssl req -new -x509 -days 365 -nodes -config /var/certs/monit.cnf -out /var/certs/monit.pem -keyout /var/certs/monit.pem -batch > /var/certs/debug_req.log 2>&1
|
49
|
+
openssl gendh 512 >> /var/certs/monit.pem 2> /var/certs/debug_gendh.log
|
50
|
+
openssl x509 -subject -dates -fingerprint -noout -in /var/certs/monit.pem > /var/certs/debug_x509.log
|
51
|
+
chmod 700 /var/certs/monit.pem
|
52
|
+
CMDS
|
53
|
+
|
54
|
+
# Install to inittab
|
55
|
+
utils.append_to("/etc/inittab", <<-APPEND, "^mo:345:respawn:/usr/local/bin/monit")
|
56
|
+
|
57
|
+
# Run monit in standard run-levels
|
58
|
+
mo:345:respawn:/usr/local/bin/monit -Ic /etc/monitrc -l #{monit_log_path} -p #{monit_pid_path}
|
59
|
+
APPEND
|
60
|
+
|
61
|
+
# HUP the inittab
|
62
|
+
run_via "telinit q"
|
48
63
|
end
|
49
64
|
|
50
65
|
desc <<-DESC
|
@@ -0,0 +1,24 @@
|
|
1
|
+
namespace :mongrel do
|
2
|
+
|
3
|
+
namespace :cluster do
|
4
|
+
|
5
|
+
namespace :logrotate do
|
6
|
+
desc <<-DESC
|
7
|
+
Install logrotated conf for mongrel cluster.
|
8
|
+
|
9
|
+
*mongrel_cluster_logrotate_path*: Mongrel cluster logrotate path. _Defaults to <tt>{shared_path}/log/mongrel_cluster_*.log</tt>_
|
10
|
+
DESC
|
11
|
+
task :install do
|
12
|
+
fetch_or_default(:mongrel_cluster_logrotate_path, "#{shared_path}/log/mongrel_cluster_*.log")
|
13
|
+
|
14
|
+
set :logrotate_name, "mongrel_cluster_#{application}"
|
15
|
+
set :logrotate_log_path, mongrel_cluster_logrotate_path
|
16
|
+
set :logrotate_options, [ { :rotate => 7 }, :daily, :missingok, :notifempty, :copytruncate ]
|
17
|
+
|
18
|
+
logrotated.install_conf
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :monit do
|
2
|
+
|
3
|
+
namespace :logrotate do
|
4
|
+
|
5
|
+
desc <<-DESC
|
6
|
+
Install logrotated conf for monit.
|
7
|
+
|
8
|
+
*monit_log_path*: Path to monit log. _Defaults to <tt>/var/log/monit.log</tt>_
|
9
|
+
DESC
|
10
|
+
task :install do
|
11
|
+
|
12
|
+
fetch_or_default(:monit_log_path, "/var/log/monit.log")
|
13
|
+
|
14
|
+
set :logrotate_name, "monit"
|
15
|
+
set :logrotate_log_path, monit_log_path
|
16
|
+
set :logrotate_options, [ { :rotate => 1, :size => "200k" }, :weekly, :missingok, :notifempty, :copytruncate ]
|
17
|
+
|
18
|
+
logrotated.install_conf
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
namespace :nginx do
|
2
|
+
|
3
|
+
# Logrotate recipes for nginx
|
4
|
+
namespace :logrotate do
|
5
|
+
|
6
|
+
desc <<-DESC
|
7
|
+
Install logrotated conf for nginx.
|
8
|
+
|
9
|
+
*nginx_logrotate_path*: Nginx logrotate path. _Defaults to <tt>/var/log/nginx_*.log</tt>_
|
10
|
+
DESC
|
11
|
+
task :install do
|
12
|
+
fetch_or_default(:nginx_logrotate_path, "/var/log/nginx_*.log")
|
13
|
+
|
14
|
+
set :logrotate_name, "nginx_main"
|
15
|
+
set :logrotate_log_path, nginx_logrotate_path
|
16
|
+
set :logrotate_options, [ { :rotate => 2, :size => "10M" }, :daily, :missingok, :notifempty, :copytruncate ]
|
17
|
+
|
18
|
+
logrotated.install_conf
|
19
|
+
end
|
20
|
+
|
21
|
+
desc <<-DESC
|
22
|
+
Install logrotated conf for vhost.
|
23
|
+
|
24
|
+
*nginx_vhost_logrotate_path*: Nginx logrotate path (for vhost). _Defaults to <tt>{shared_path}/log/nginx.*.log</tt>_
|
25
|
+
DESC
|
26
|
+
task :install_vhost do
|
27
|
+
fetch_or_default(:nginx_vhost_logrotate_path, "#{shared_path}/log/nginx.*.log")
|
28
|
+
|
29
|
+
set :logrotate_name, "nginx_#{application}"
|
30
|
+
set :logrotate_log_path, nginx_vhost_logrotate_path
|
31
|
+
set :logrotate_options, [ { :rotate => 2, :size => "10M" }, :daily, :missingok, :notifempty, :copytruncate ]
|
32
|
+
|
33
|
+
logrotated.install_conf
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :rails do
|
2
|
+
|
3
|
+
# Log rotate tasks
|
4
|
+
namespace :logrotate do
|
5
|
+
desc <<-DESC
|
6
|
+
Install logrotated conf for rails.
|
7
|
+
|
8
|
+
*rails_logrotate_path*: Rails logrotate path. _Defaults to <tt>{shared_path}/log/production.log</tt>_
|
9
|
+
DESC
|
10
|
+
task :install do
|
11
|
+
fetch_or_default(:rails_logrotate_path, "#{shared_path}/log/production.log")
|
12
|
+
|
13
|
+
set :logrotate_name, "rails_#{application}"
|
14
|
+
set :logrotate_log_path, rails_logrotate_path
|
15
|
+
set :logrotate_options, [ { :rotate => 7, :size => "10M" }, :daily, :missingok, :notifempty, :copytruncate ]
|
16
|
+
|
17
|
+
logrotated.install_conf
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :sphinx do
|
2
|
+
|
3
|
+
# Log rotate tasks
|
4
|
+
namespace :logrotate do
|
5
|
+
desc <<-DESC
|
6
|
+
Install logrotated conf for sphinx.
|
7
|
+
|
8
|
+
*sphinx_logrotate_path*: Sphinx logrotate paths. _Defaults to <tt>{shared_path}/log/query.log {shared_path}/log/searchd.log</tt>_
|
9
|
+
DESC
|
10
|
+
task :install do
|
11
|
+
fetch_or_default(:sphinx_logrotate_path, "#{shared_path}/log/query.log #{shared_path}/log/searchd.log")
|
12
|
+
|
13
|
+
set :logrotate_name, "sphinx_#{application}"
|
14
|
+
set :logrotate_log_path, sphinx_logrotate_path
|
15
|
+
set :logrotate_options, [ { :rotate => 7 }, :daily, :missingok, :notifempty, :copytruncate ]
|
16
|
+
|
17
|
+
logrotated.install_conf
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
namespace :logrotated do
|
3
|
+
|
4
|
+
desc <<-DESC
|
5
|
+
Create logrotated conf. You probably use this in other recipes and not standalone.
|
6
|
+
|
7
|
+
*logrotate_name*: Name of file in /etc/logrotate.d/\n
|
8
|
+
*logrotate_log_path*: Path to log file. Can include wildcards, like /var/log/foo_*.log.\n
|
9
|
+
|
10
|
+
*logrotate_options*:
|
11
|
+
- :rotate (Number of times to rotate before discarding)
|
12
|
+
- :size (Rotate when file hits this size)
|
13
|
+
- :daily, :weekly, :monthly (How often to perform rotate)
|
14
|
+
- :missingok
|
15
|
+
- :compress
|
16
|
+
- :delaycompress
|
17
|
+
- :notifempty
|
18
|
+
- :copytruncate
|
19
|
+
|
20
|
+
See man page for all the options.
|
21
|
+
|
22
|
+
<pre>
|
23
|
+
set :logrotate_options, [ { :rotate => 7, :size => 10MB },
|
24
|
+
:daily, :missingok, :compress, :delaycompress, :notifempty, :copytruncate ]
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
DESC
|
28
|
+
task :install_conf do
|
29
|
+
|
30
|
+
fetch(:logrotate_name)
|
31
|
+
fetch(:logrotate_log_path)
|
32
|
+
fetch(:logrotate_options)
|
33
|
+
|
34
|
+
text = []
|
35
|
+
logrotate_options.each do |option|
|
36
|
+
if option.is_a?(Hash)
|
37
|
+
option.each do |key, value|
|
38
|
+
text << "#{key.to_s} #{value.to_s}"
|
39
|
+
end
|
40
|
+
else
|
41
|
+
text << option.to_s
|
42
|
+
end
|
43
|
+
end
|
44
|
+
set :logrotate_options_text, " " + text.join("\n ")
|
45
|
+
|
46
|
+
utils.install_template("logrotated/conf.erb", "/etc/logrotate.d/#{logrotate_name}")
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
desc <<-DESC
|
51
|
+
Force rotate files.
|
52
|
+
DESC
|
53
|
+
task :force do
|
54
|
+
|
55
|
+
fetch_or_default(:logrotate_prefix, "")
|
56
|
+
fetch_or_default(:logrotate_conf_path, "/etc/logrotate.conf")
|
57
|
+
|
58
|
+
command = "logrotate"
|
59
|
+
command = "#{logrotate_prefix}/logrotate" unless logrotate_prefix.blank?
|
60
|
+
|
61
|
+
run_via "#{command} -f #{logrotate_conf_path}"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
data/lib/recipes/memcached.rb
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
namespace :memcached do
|
2
2
|
|
3
|
+
desc "Create memcached yaml in shared path."
|
4
|
+
task :setup do
|
5
|
+
|
6
|
+
# Settings
|
7
|
+
fetch(:memcached_namespace)
|
8
|
+
fetch_or_default(:memcached_ttl, 3600)
|
9
|
+
fetch_or_default(:memcached_readonly, false)
|
10
|
+
fetch_or_default(:memcached_urlencode, false)
|
11
|
+
fetch_or_default(:memcached_c_threshold, 10000)
|
12
|
+
fetch_or_default(:memcached_compression, true)
|
13
|
+
fetch_or_default(:memcached_debug, false)
|
14
|
+
fetch_or_default(:memcached_servers, [ "localhost:11211" ])
|
15
|
+
fetch_or_default(:memcached_yml_template, "memcached/memcached.yml.erb")
|
16
|
+
|
17
|
+
utils.install_template(memcached_yml_template, "#{shared_path}/config/memcached.yml")
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Symlink memcached configuration after deploy."
|
21
|
+
task :update_code, :roles => :app do
|
22
|
+
run "ln -nfs #{shared_path}/config/memcached.yml #{release_path}/config/memcached.yml"
|
23
|
+
end
|
24
|
+
|
3
25
|
namespace :monit do
|
4
26
|
|
5
27
|
desc <<-DESC
|
data/lib/recipes/rails.rb
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
namespace :rails do
|
3
3
|
|
4
4
|
desc <<-DESC
|
5
|
-
Create database yaml in shared path.
|
5
|
+
Create database yaml in shared path. Note: If both <tt>:db_host</tt> and <tt>:db_socket</tt> are used,
|
6
|
+
db_socket wins.
|
6
7
|
|
7
8
|
*db_name*: Database name (rails).\n
|
8
9
|
@set :db_name, "app_db_name"@\n
|
@@ -11,10 +12,11 @@ namespace :rails do
|
|
11
12
|
*db_pass*: Database password (rails).\n
|
12
13
|
@set :db_pass, "the_password"@\n
|
13
14
|
*db_host*: Database host (can be nil, if you are using socket). _Defaults to nil_\n
|
14
|
-
*db_socket*: Database socket (can be nil, if you are using host). _Defaults to nil_\n
|
15
|
+
*db_socket*: Database socket (can be nil, if you are using host). _Defaults to nil_\n
|
15
16
|
@set :db_socket, "/var/lib/mysql/mysql.sock"@\n
|
17
|
+
*database_yml_template*: Path to database yml erb template. _Defaults to <tt>rails/database.yml.erb</tt>_ (in this GEM)\n
|
16
18
|
DESC
|
17
|
-
task :setup do
|
19
|
+
task :setup, :roles => :app do
|
18
20
|
|
19
21
|
# Settings
|
20
22
|
fetch(:db_name)
|
@@ -22,6 +24,7 @@ namespace :rails do
|
|
22
24
|
fetch(:db_pass)
|
23
25
|
fetch_or_default(:db_host, nil)
|
24
26
|
fetch_or_default(:db_socket, nil)
|
27
|
+
fetch_or_default(:database_yml_template, "rails/database.yml.erb")
|
25
28
|
|
26
29
|
unless db_host.blank?
|
27
30
|
set :db_connect_type, "host"
|
@@ -34,7 +37,7 @@ namespace :rails do
|
|
34
37
|
end
|
35
38
|
|
36
39
|
run "mkdir -p #{shared_path}/config"
|
37
|
-
put template.load(
|
40
|
+
put template.load(database_yml_template), "#{shared_path}/config/database.yml"
|
38
41
|
end
|
39
42
|
|
40
43
|
desc "Make symlink for database yaml"
|
@@ -42,43 +45,50 @@ namespace :rails do
|
|
42
45
|
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
43
46
|
end
|
44
47
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
# Log tasks
|
49
|
+
namespace :logs do
|
50
|
+
|
51
|
+
desc <<-DESC
|
52
|
+
Tail production log files.\n
|
53
|
+
http://errtheblog.com/posts/19-streaming-capistrano
|
54
|
+
DESC
|
55
|
+
task :tail, :roles => :web do
|
56
|
+
run "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
|
57
|
+
puts # for an extra line break before the host name
|
58
|
+
puts "#{channel[:host]}: #{data}"
|
59
|
+
break if stream == :err
|
60
|
+
end
|
53
61
|
end
|
54
|
-
end
|
55
62
|
|
56
63
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
64
|
+
desc <<-DESC
|
65
|
+
Check production log files in TextMate.\n
|
66
|
+
See http://errtheblog.com/posts/19-streaming-capistrano
|
67
|
+
DESC
|
68
|
+
task :mate, :roles => :app do
|
61
69
|
|
62
|
-
|
63
|
-
|
64
|
-
|
70
|
+
require 'tempfile'
|
71
|
+
tmp = Tempfile.open('w')
|
72
|
+
logs = Hash.new { |h,k| h[k] = '' }
|
65
73
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
74
|
+
run "tail -n500 #{shared_path}/log/production.log" do |channel, stream, data|
|
75
|
+
logs[channel[:host]] << data
|
76
|
+
break if stream == :err
|
77
|
+
end
|
70
78
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
79
|
+
logs.each do |host, log|
|
80
|
+
tmp.write("--- #{host} ---\n\n")
|
81
|
+
tmp.write(log + "\n")
|
82
|
+
end
|
75
83
|
|
76
|
-
|
77
|
-
|
84
|
+
exec "mate -w #{tmp.path}"
|
85
|
+
tmp.close
|
86
|
+
end
|
78
87
|
end
|
79
88
|
|
80
89
|
desc <<-DESC
|
81
|
-
Remotely console
|
90
|
+
Remotely console.\n
|
91
|
+
See http://errtheblog.com/posts/19-streaming-capistrano
|
82
92
|
DESC
|
83
93
|
task :console, :roles => :app do
|
84
94
|
input = ''
|
data/lib/recipes/sshd.rb
CHANGED
@@ -5,7 +5,7 @@ namespace :sshd do
|
|
5
5
|
desc <<-DESC
|
6
6
|
Install sshd monit hooks.
|
7
7
|
|
8
|
-
*sshd_port*: SSH daemon port. _Defaults to
|
8
|
+
*sshd_port*: SSH daemon port. _Defaults to 22_\n
|
9
9
|
*sshd_pid_path*: Path to mysql pid file. _Defaults to /var/run/sshd.pid_\n
|
10
10
|
*monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
|
11
11
|
DESC
|
@@ -22,4 +22,53 @@ namespace :sshd do
|
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
|
+
desc <<-DESC
|
26
|
+
Create public and private keys for ssh.
|
27
|
+
|
28
|
+
*ssh_keygen_type*: SSH keygen type. _Defaults to rsa_\n
|
29
|
+
*ssh_keygen_bits*: SSH keygen bits. _Defaults to 2048_\n
|
30
|
+
DESC
|
31
|
+
task :keygen do
|
32
|
+
# Settings
|
33
|
+
fetch_or_default(:ssh_keygen_type, "rsa")
|
34
|
+
fetch_or_default(:ssh_keygen_bits, 2048)
|
35
|
+
|
36
|
+
run "ssh-keygen -t #{ssh_keygen_type} -b #{ssh_keygen_bits}" do |channel, stream, data|
|
37
|
+
logger.trace data
|
38
|
+
|
39
|
+
if data =~ /^Overwrite (y\/n)?/
|
40
|
+
channel.send_data "n\n"
|
41
|
+
logger.important "This key already exists! Aborting."
|
42
|
+
|
43
|
+
# Use default for file and empty password
|
44
|
+
elsif data =~ /^Enter file/ or
|
45
|
+
data =~ /^Enter passphrase/ or
|
46
|
+
data =~ /^Enter same passphrase again/
|
47
|
+
|
48
|
+
channel.send_data "\n"
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
desc <<-DESC
|
56
|
+
Add to authorized keys. Uses <tt>.ssh/authorized_keys</tt>.
|
57
|
+
|
58
|
+
*ssh_public_key*: The public key from ssh:keygen.
|
59
|
+
DESC
|
60
|
+
task :authorize_key do
|
61
|
+
|
62
|
+
fetch(:ssh_public_key)
|
63
|
+
|
64
|
+
ssh_dir = "~/.ssh"
|
65
|
+
authorized_keys_path = "#{ssh_dir}/authorized_keys"
|
66
|
+
|
67
|
+
run_all <<-CMDS
|
68
|
+
if [ ! -d #{ssh_dir} ]; then mkdir #{ssh_dir} ; chmod 700 #{ssh_dir} ; fi
|
69
|
+
if [ ! -f #{authorized_keys_path} ]; then touch #{authorized_keys_path} ; chmod 600 #{authorized_keys_path} ; fi
|
70
|
+
echo "#{ssh_public_key}" >> #{authorized_keys_path}
|
71
|
+
CMDS
|
72
|
+
end
|
73
|
+
|
25
74
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
namespace :syslogd do
|
2
|
+
|
3
|
+
desc <<-DESC
|
4
|
+
Add entry to syslog for application.
|
5
|
+
|
6
|
+
*syslog_program_name*: syslog program name. What you used for <tt>SyslogLogger.new("program_name_here")</tt>\n
|
7
|
+
*syslog_log_path*: Path to log.\n
|
8
|
+
*syslog_conf_path*: Path to syslog conf. _Defaults to <tt>/etc/syslog.conf</tt>_\n
|
9
|
+
DESC
|
10
|
+
task :setup_conf do
|
11
|
+
|
12
|
+
fetch(:syslog_program_name)
|
13
|
+
fetch(:syslog_log_path)
|
14
|
+
fetch_or_default(:syslog_conf_path, "/etc/syslog.conf")
|
15
|
+
|
16
|
+
utils.append_to(syslog_conf_path, <<-DATA, "^!#{syslog_program_name}")
|
17
|
+
|
18
|
+
# Entry for #{syslog_program_name}
|
19
|
+
!#{syslog_program_name}
|
20
|
+
*.* #{syslog_log_path}
|
21
|
+
DATA
|
22
|
+
end
|
23
|
+
|
24
|
+
desc <<-DESC
|
25
|
+
Add entry to newsyslog for application. See newsyslog man page for details.
|
26
|
+
|
27
|
+
Adds entry like:
|
28
|
+
|
29
|
+
<pre>
|
30
|
+
/var/log/my_app.log 640 7 * @T00 Z
|
31
|
+
</pre>
|
32
|
+
|
33
|
+
*syslog_log_path*: Path to log. _Defaults to <tt>/var/log/[syslog_program_name].log</tt>_\n
|
34
|
+
*newsyslog_conf_path*: Path to newsyslog conf.\n
|
35
|
+
*newsyslog_mode*: File mode (to create log with). _Defaults to _\n
|
36
|
+
*newsyslog_count*: Number of files to keep. _Defaults to 7_\n
|
37
|
+
*newsyslog_size*: Max size. _Defaults to *_\n
|
38
|
+
*newsyslog_when*: When to rotate. _Defaults to @T00_\n
|
39
|
+
*newsyslog_zb*: Whether to gzip or tarball. _Defaults to Z_\n
|
40
|
+
DESC
|
41
|
+
task :setup_newsyslog_conf do
|
42
|
+
|
43
|
+
fetch(:syslog_log_path)
|
44
|
+
fetch_or_default(:newsyslog_conf_path, "/etc/newsyslog.conf")
|
45
|
+
|
46
|
+
fetch_or_default(:newsyslog_mode, "640")
|
47
|
+
fetch_or_default(:newsyslog_count, "7")
|
48
|
+
fetch_or_default(:newsyslog_size, "*")
|
49
|
+
fetch_or_default(:newsyslog_when, "@T00")
|
50
|
+
fetch_or_default(:newsyslog_zb, "Z")
|
51
|
+
|
52
|
+
entry = "#{syslog_log_path} \t#{newsyslog_mode} \t#{newsyslog_count} \t#{newsyslog_size} \t#{newsyslog_when} \t#{newsyslog_zb}"
|
53
|
+
|
54
|
+
utils.append_to(newsyslog_conf_path, entry, "^#{syslog_log_path}")
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
# backgroundrb_<%= application %>: Backgroundrb daemon for <%= application %>
|
3
|
+
#
|
4
|
+
# chkconfig: - 86 14
|
5
|
+
# description: backgroundrb daemon
|
6
|
+
# processname: backgroundrb
|
7
|
+
#
|
8
|
+
# Author: Gabriel Handford http://ducktyper.com
|
9
|
+
|
10
|
+
# Source function library
|
11
|
+
. /etc/rc.d/init.d/functions
|
12
|
+
|
13
|
+
RETVAL=0
|
14
|
+
|
15
|
+
DESC="backgroundrb daemon (<%= application %>)"
|
16
|
+
DAEMON="<%= backgroundrb_bin_path %>"
|
17
|
+
PIDFILE="<%= backgroundrb_pid_path %>"
|
18
|
+
|
19
|
+
# For stop/reload support using patched backgroundrb that takes
|
20
|
+
# pidfile as argument into backgroundrb.yml config.
|
21
|
+
|
22
|
+
start() {
|
23
|
+
daemon --user <%= user %> --pidfile $PIDFILE $DAEMON
|
24
|
+
RETVAL=$?
|
25
|
+
echo
|
26
|
+
return $RETVAL;
|
27
|
+
}
|
28
|
+
|
29
|
+
stop() {
|
30
|
+
kill -QUIT `cat $PIDFILE` || echo -n " not running"
|
31
|
+
}
|
32
|
+
|
33
|
+
case "$1" in
|
34
|
+
start)
|
35
|
+
echo -n "Starting $DESC: $NAME"
|
36
|
+
start
|
37
|
+
RETVAL=$?;
|
38
|
+
;;
|
39
|
+
stop)
|
40
|
+
echo -n "Stopping $DESC: $NAME"
|
41
|
+
stop
|
42
|
+
RETVAL=$?;
|
43
|
+
;;
|
44
|
+
restart)
|
45
|
+
echo -n "Restarting $DESC: $NAME"
|
46
|
+
stop
|
47
|
+
# Sleep after stop
|
48
|
+
sleep 1
|
49
|
+
start
|
50
|
+
RETVAL=$?;
|
51
|
+
;;
|
52
|
+
*)
|
53
|
+
echo "Usage: $0 {start|stop|restart}" >&2
|
54
|
+
RETVAL=3;
|
55
|
+
;;
|
56
|
+
esac
|
57
|
+
|
58
|
+
exit $RETVAL;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
defaults:
|
2
|
+
ttl: <%= memcached_ttl %>
|
3
|
+
readonly: <%= memcached_readonly.to_s %>
|
4
|
+
urlencode: <%= memcached_urlencode.to_s %>
|
5
|
+
c_threshold: <%= memcached_c_threshold %>
|
6
|
+
compression: <%= memcached_compression.to_s %>
|
7
|
+
debug: <%= memcached_debug.to_s %>
|
8
|
+
namespace: <%= memcached_namespace %>
|
9
|
+
|
10
|
+
development:
|
11
|
+
servers: localhost:11211
|
12
|
+
|
13
|
+
production:
|
14
|
+
servers: <%= memcached_servers.inspect %>
|
data/website/index.html
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
<div id="version" class="clickable box" onclick='document.location = "http://rubyforge.org/projects/capitate"; return false'>
|
40
40
|
<p>Get Version</p>
|
41
|
-
<a href="http://rubyforge.org/projects/capitate" class="numbers">0.2.
|
41
|
+
<a href="http://rubyforge.org/projects/capitate" class="numbers">0.2.11</a>
|
42
42
|
</div>
|
43
43
|
|
44
44
|
<div id="recipes">
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capitate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
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-03-
|
12
|
+
date: 2008-03-25 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -63,7 +63,8 @@ files:
|
|
63
63
|
- lib/capitate/task_node.rb
|
64
64
|
- lib/capitate/version.rb
|
65
65
|
- lib/deployment/centos-5.1-64-web/install.rb
|
66
|
-
- lib/
|
66
|
+
- lib/recipes/backgroundrb.rb
|
67
|
+
- lib/recipes/centos/backgroundrb.rb
|
67
68
|
- lib/recipes/centos/centos.rb
|
68
69
|
- lib/recipes/centos/imagemagick.rb
|
69
70
|
- lib/recipes/centos/memcached.rb
|
@@ -74,6 +75,12 @@ files:
|
|
74
75
|
- lib/recipes/centos/ruby.rb
|
75
76
|
- lib/recipes/centos/sphinx.rb
|
76
77
|
- lib/recipes/docs.rb
|
78
|
+
- lib/recipes/logrotate/mongrel_cluster.rb
|
79
|
+
- lib/recipes/logrotate/monit.rb
|
80
|
+
- lib/recipes/logrotate/nginx.rb
|
81
|
+
- lib/recipes/logrotate/rails.rb
|
82
|
+
- lib/recipes/logrotate/sphinx.rb
|
83
|
+
- lib/recipes/logrotated.rb
|
77
84
|
- lib/recipes/memcached.rb
|
78
85
|
- lib/recipes/mongrel_cluster.rb
|
79
86
|
- lib/recipes/monit.rb
|
@@ -82,17 +89,20 @@ files:
|
|
82
89
|
- lib/recipes/rails.rb
|
83
90
|
- lib/recipes/sphinx.rb
|
84
91
|
- lib/recipes/sshd.rb
|
92
|
+
- lib/recipes/syslogd.rb
|
93
|
+
- lib/templates/backgroundrb/backgroundrb.initd.centos.erb
|
94
|
+
- lib/templates/backgroundrb/backgroundrb.yml.erb
|
85
95
|
- lib/templates/capistrano/Capfile
|
96
|
+
- lib/templates/logrotated/conf.erb
|
86
97
|
- lib/templates/memcached/memcached.initd.centos.erb
|
87
98
|
- lib/templates/memcached/memcached.monitrc.erb
|
99
|
+
- lib/templates/memcached/memcached.yml.erb
|
88
100
|
- lib/templates/mongrel/mongrel_cluster.initd.erb
|
89
101
|
- lib/templates/mongrel/mongrel_cluster.monitrc.erb
|
90
102
|
- lib/templates/mongrel/mongrel_cluster.yml.erb
|
91
|
-
- lib/templates/monit/cert.sh
|
92
103
|
- lib/templates/monit/monit.cnf
|
93
104
|
- lib/templates/monit/monit.initd.centos.erb
|
94
105
|
- lib/templates/monit/monitrc.erb
|
95
|
-
- lib/templates/monit/patch_inittab.sh
|
96
106
|
- lib/templates/mysql/install_db.sql.erb
|
97
107
|
- lib/templates/mysql/mysql.monitrc.erb
|
98
108
|
- lib/templates/nginx/nginx.conf.erb
|
data/lib/deployment/deploy.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# Example deploy.rb
|
2
|
-
|
3
|
-
set :application, "sick"
|
4
|
-
set :user, "sick"
|
5
|
-
set :groups, "admin"
|
6
|
-
|
7
|
-
set :deploy_to, "/var/www/apps/sick"
|
8
|
-
set :web_host, "192.168.1.111"
|
9
|
-
set :db_host, "192.168.1.111"
|
10
|
-
set :db_user, "sick"
|
11
|
-
set :db_pass, prompt.password("DB Password: ")
|
12
|
-
set :db_name, "sick"
|
13
|
-
set :repository, "http://svn.ducktyper.com/scratch/testapp/trunk"
|
14
|
-
set :mongrel_port, 12000
|
15
|
-
set :mongrel_size, 3
|
16
|
-
set :domain_name, "localhost"
|
17
|
-
set :mysql_admin_password, prompt.password('Mysql admin password: ')
|
18
|
-
|
19
|
-
set :deploy_via, :copy
|
20
|
-
set :copy_strategy, :export
|
21
|
-
|
22
|
-
role :web, "192.168.1.111"
|
23
|
-
role :db, "192.168.1.111", :primary => true
|
24
|
-
|
25
|
-
|
26
|
-
# Callbacks
|
27
|
-
before "deploy:setup", "centos:add_user"
|
28
|
-
|
29
|
-
after "deploy:setup", "mysql:setup", "rails:setup", "mongrel:cluster:centos:setup",
|
30
|
-
"nginx:mongrel:setup", "sphinx:centos:setup", "sphinx:setup_monit", "mongrel:cluster:monit:setup"
|
31
|
-
|
32
|
-
after "nginx:mongrel:setup", "nginx:centos:restart"
|
33
|
-
|
34
|
-
after "deploy:update_code", "rails:update_code", "sphinx:update_conf"
|
35
|
-
|
36
|
-
# Auto cleanup after deploy
|
37
|
-
after "deploy", "deploy:cleanup"
|
data/lib/templates/monit/cert.sh
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#! /bin/sh
|
2
|
-
|
3
|
-
set -e
|
4
|
-
trap ERROR ERR
|
5
|
-
|
6
|
-
mkdir -p /var/certs
|
7
|
-
mv /tmp/monit.cnf /var/certs/monit.cnf
|
8
|
-
|
9
|
-
echo "Generating PEM..."
|
10
|
-
openssl req -new -x509 -days 365 -nodes -config /var/certs/monit.cnf -out /var/certs/monit.pem -keyout /var/certs/monit.pem -batch > /var/certs/debug_req.log 2>&1
|
11
|
-
openssl gendh 512 >> /var/certs/monit.pem 2> /var/certs/debug_gendh.log
|
12
|
-
echo "Generating x509..."
|
13
|
-
openssl x509 -subject -dates -fingerprint -noout -in /var/certs/monit.pem > /var/certs/debug_x509.log
|
14
|
-
chmod 700 /var/certs/monit.pem
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#! /bin/sh
|
2
|
-
|
3
|
-
set -e
|
4
|
-
trap ERROR ERR
|
5
|
-
|
6
|
-
NO_MONIT=0
|
7
|
-
grep -q monit /etc/inittab > /dev/null || export NO_MONIT=1
|
8
|
-
|
9
|
-
if [ $NO_MONIT == 1 ]; then
|
10
|
-
echo "Patching inittab with monit..."
|
11
|
-
echo "" >> /etc/inittab
|
12
|
-
echo "# Run monit in standard run-levels" >> /etc/inittab
|
13
|
-
echo "mo:345:respawn:/usr/local/bin/monit -Ic /etc/monitrc -l /var/log/monit.log -p /var/run/monit.pid" >> /etc/inittab
|
14
|
-
telinit q
|
15
|
-
fi
|