centostrano 0.1 → 0.2
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/docs/offline_installation.txt +16 -0
- data/lib/deprec/capistrano_extensions.rb +60 -16
- data/lib/deprec/recipes.rb +1 -0
- data/lib/deprec/recipes/apache.rb +8 -6
- data/lib/deprec/recipes/gitosis.rb +21 -1
- data/lib/deprec/recipes/merb.rb +2 -2
- data/lib/deprec/recipes/mongrel.rb +11 -6
- data/lib/deprec/recipes/mysql.rb +5 -5
- data/lib/deprec/recipes/nginx.rb +23 -19
- data/lib/deprec/recipes/passenger.rb +127 -0
- data/lib/deprec/recipes/rails.rb +15 -25
- data/lib/deprec/recipes/ruby.rb +8 -8
- data/lib/deprec/recipes/sphinx.rb +3 -0
- data/lib/deprec/recipes/svn.rb +1 -1
- data/lib/deprec/templates/mongrel/logrotate.conf.erb +1 -1
- data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
- data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
- data/lib/deprec/templates/nginx/logrotate.conf.erb +1 -1
- data/lib/deprec/templates/nginx/nginx.conf.erb +14 -4
- data/lib/deprec/templates/passenger/apache_vhost.erb +10 -0
- data/lib/deprec/templates/passenger/passenger.erb +20 -0
- data/lib/deprec/templates/ssh/ssh_config.erb +1 -1
- metadata +121 -117
- data/lib/deprec/templates/coraid/aoe-init +0 -55
- data/lib/deprec/templates/mongrel/mongrel_cluster.logrotate.d +0 -14
data/lib/deprec/recipes/rails.rb
CHANGED
@@ -63,16 +63,13 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
63
63
|
top.centos.rubygems.install
|
64
64
|
|
65
65
|
# Stop and deactivate apache 2
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
|
66
|
+
top.centos.apache.stop
|
67
|
+
top.centos.apache.deactivate
|
68
|
+
|
71
69
|
# Install nginx
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
top.centos.nginx.install
|
71
|
+
|
72
|
+
# XXX check this out before removing - Mike
|
76
73
|
deprec2.for_roles('app') do
|
77
74
|
top.centos.svn.install
|
78
75
|
top.centos.git.install
|
@@ -81,16 +78,10 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
81
78
|
top.centos.rails.install
|
82
79
|
end
|
83
80
|
|
84
|
-
|
85
|
-
top.centos.logrotate.install
|
86
|
-
end
|
81
|
+
top.centos.logrotate.install
|
87
82
|
|
88
|
-
|
89
|
-
|
90
|
-
# top.centos.mysql.install
|
91
|
-
# top.centos.mysql.start
|
92
|
-
# end
|
93
|
-
|
83
|
+
top.centos.mysql.install
|
84
|
+
top.centos.mysql.start
|
94
85
|
end
|
95
86
|
|
96
87
|
task :install_rails_stack do
|
@@ -98,7 +89,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
98
89
|
install_stack
|
99
90
|
end
|
100
91
|
|
101
|
-
task :install_gems_for_project do
|
92
|
+
task :install_gems_for_project, :roles => :app do
|
102
93
|
if gems_for_project
|
103
94
|
gems_for_project.each { |gem| gem2.install(gem) }
|
104
95
|
end
|
@@ -123,7 +114,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
123
114
|
deprec2.render_template(:nginx, file)
|
124
115
|
end
|
125
116
|
top.centos.mongrel.config_gen_project
|
126
|
-
top.centos.mongrel.config_project
|
127
117
|
end
|
128
118
|
|
129
119
|
desc "Push out config files for rails app."
|
@@ -131,23 +121,23 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
131
121
|
deprec2.push_configs(:nginx, PROJECT_CONFIG_FILES[:nginx])
|
132
122
|
top.centos.mongrel.config_project
|
133
123
|
symlink_nginx_vhost
|
134
|
-
|
124
|
+
symlink_nginx_logrotate_config
|
135
125
|
end
|
136
126
|
|
137
127
|
task :symlink_nginx_vhost, :roles => :web do
|
138
128
|
sudo "ln -sf #{deploy_to}/nginx/rails_nginx_vhost.conf #{nginx_vhost_dir}/#{application}.conf"
|
139
129
|
end
|
140
130
|
|
141
|
-
task :
|
131
|
+
task :symlink_nginx_logrotate_config, :roles => :web do
|
142
132
|
sudo "ln -sf #{deploy_to}/nginx/logrotate.conf /etc/logrotate.d/nginx-#{application}"
|
143
133
|
end
|
144
134
|
|
145
|
-
task :create_config_dir do
|
135
|
+
task :create_config_dir, :roles => :app do
|
146
136
|
deprec2.mkdir("#{shared_path}/config", :group => group, :mode => 0775, :via => :sudo)
|
147
137
|
end
|
148
138
|
|
149
139
|
desc "Create deployment group and add current user to it"
|
150
|
-
task :setup_user_perms do
|
140
|
+
task :setup_user_perms, :roles => [:app, :web] do
|
151
141
|
deprec2.groupadd(group)
|
152
142
|
deprec2.add_user_to_group(user, group)
|
153
143
|
deprec2.groupadd(mongrel_group)
|
@@ -169,7 +159,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
169
159
|
end
|
170
160
|
|
171
161
|
# setup extra paths required for deployment
|
172
|
-
task :setup_paths, :roles => :app do
|
162
|
+
task :setup_paths, :roles => [:app, :web] do
|
173
163
|
deprec2.mkdir(deploy_to, :mode => 0775, :group => group, :via => :sudo)
|
174
164
|
deprec2.mkdir(shared_path, :mode => 0775, :group => group, :via => :sudo)
|
175
165
|
end
|
data/lib/deprec/recipes/ruby.rb
CHANGED
@@ -9,7 +9,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
9
9
|
:md5sum => "c36e011733a3a3be6f43ba27b7cd7485 ruby-1.8.6-p111.tar.gz",
|
10
10
|
:dir => 'ruby-1.8.6-p111',
|
11
11
|
:url => "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz",
|
12
|
-
:unpack => "tar zxf ruby-1.8.6-p111.tar.gz; cd ruby-1.8.6-p111; wget -q -O - wget http://blog.phusion.nl/assets/r8ee-security-patch-20080623-2.txt | patch -p1",
|
12
|
+
:unpack => "tar zxf ruby-1.8.6-p111.tar.gz; cd ruby-1.8.6-p111; wget -q -O - wget http://blog.phusion.nl/assets/r8ee-security-patch-20080623-2.txt | patch -p1;",
|
13
13
|
:configure => %w(
|
14
14
|
./configure
|
15
15
|
--with-install-readline
|
@@ -28,7 +28,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
task :install_deps do
|
31
|
-
apt.install( {:base => %w(pcre* gcc make openssl openssl-devel readline-devel)}, :stable )
|
31
|
+
apt.install( {:base => %w(pcre* gcc make openssl openssl-devel readline-devel patch)}, :stable )
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
@@ -39,13 +39,13 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
39
39
|
namespace :rubygems do
|
40
40
|
|
41
41
|
SRC_PACKAGES[:rubygems] = {
|
42
|
-
:filename => 'rubygems-1.
|
43
|
-
:md5sum => "
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:unpack => "tar zxf rubygems-1.
|
42
|
+
:filename => 'rubygems-1.3.1.tgz',
|
43
|
+
:md5sum => "a04ee6f6897077c5b75f5fd1e134c5a9 rubygems-1.3.1.tgz",
|
44
|
+
:url => "http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz",
|
45
|
+
:dir => 'rubygems-1.3.1',
|
46
|
+
:unpack => "tar zxf rubygems-1.3.1.tgz;",
|
47
47
|
:install => 'ruby setup.rb;',
|
48
|
-
:version => 'c1.
|
48
|
+
:version => 'c1.3.1',
|
49
49
|
:release => '1'
|
50
50
|
}
|
51
51
|
|
data/lib/deprec/recipes/svn.rb
CHANGED
@@ -34,7 +34,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
34
34
|
set(:svn_backup_dir) { File.join(backup_dir, 'svn') }
|
35
35
|
|
36
36
|
desc "Install Subversion"
|
37
|
-
task :install
|
37
|
+
task :install do
|
38
38
|
install_deps
|
39
39
|
# XXX should really check if apache has already been installed
|
40
40
|
# XXX can do that when we move to rake
|
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/usr/bin/perl
|
2
|
+
use strict;
|
3
|
+
use warnings;
|
4
|
+
use Getopt::Long;
|
5
|
+
use File::Basename;
|
6
|
+
|
7
|
+
# Author: Dean Wilson ; License: GPL
|
8
|
+
# Project Home: http://www.unixdaemon.net/
|
9
|
+
# For documentation look at the bottom of this file, or run with '-h'
|
10
|
+
# Version 0.5 - Tided up arg handling. Added usage
|
11
|
+
|
12
|
+
# Changes:
|
13
|
+
# Usage information corrected, thanks to Bartlomiej Konarski
|
14
|
+
|
15
|
+
# nagios requires a 3 for unknown errors.
|
16
|
+
$SIG{__DIE__} = sub {
|
17
|
+
print @_;
|
18
|
+
exit 3;
|
19
|
+
};
|
20
|
+
|
21
|
+
my $app = basename($0);
|
22
|
+
|
23
|
+
GetOptions(
|
24
|
+
"w|warn=s" => \( my $warn_percent = 30 ),
|
25
|
+
"c|crit=s" => \( my $crit_percent = 20 ),
|
26
|
+
"h|help" => \&usage,
|
27
|
+
);
|
28
|
+
|
29
|
+
# remove any % passed in
|
30
|
+
$warn_percent =~ s/%//;
|
31
|
+
$crit_percent =~ s/%//;
|
32
|
+
|
33
|
+
die "Warning value must be larger than critical value\n"
|
34
|
+
unless $warn_percent >= $crit_percent;
|
35
|
+
|
36
|
+
my $memory_stats_ref = get_mem();
|
37
|
+
my $percentage_free = get_percentage($memory_stats_ref);
|
38
|
+
|
39
|
+
if ($percentage_free <= $crit_percent) {
|
40
|
+
print "CRIT: Only $percentage_free% ($memory_stats_ref->{free_cache}M) of memory free!\n";
|
41
|
+
exit 2;
|
42
|
+
} elsif ($percentage_free <= $warn_percent) {
|
43
|
+
print "WARN: Only $percentage_free% ($memory_stats_ref->{free_cache}M) of memory free!\n";
|
44
|
+
exit 1;
|
45
|
+
} else {
|
46
|
+
print "OK: $percentage_free% ($memory_stats_ref->{free_cache}M) free memory.\n";
|
47
|
+
exit 0;
|
48
|
+
}
|
49
|
+
|
50
|
+
#########################################
|
51
|
+
|
52
|
+
sub get_mem {
|
53
|
+
# get the two values from the free command.
|
54
|
+
# return them as a hash ref
|
55
|
+
|
56
|
+
my %memory_stats;
|
57
|
+
|
58
|
+
open(FREEPIPE, "free -m |")
|
59
|
+
|| die "Failed to open 'free'\n$!\n";
|
60
|
+
|
61
|
+
while(<FREEPIPE>) {
|
62
|
+
chomp;
|
63
|
+
next unless m!buffers/cache:!;
|
64
|
+
m/[^\d]+(\d+)\s+(\d+)$/;
|
65
|
+
$memory_stats{'used_cache'} = $1;
|
66
|
+
$memory_stats{'free_cache'} = $2;
|
67
|
+
}
|
68
|
+
|
69
|
+
close FREEPIPE;
|
70
|
+
|
71
|
+
return \%memory_stats;
|
72
|
+
}
|
73
|
+
|
74
|
+
#------------------------------------------#
|
75
|
+
|
76
|
+
sub get_percentage {
|
77
|
+
my $mem_stats_ref = shift;
|
78
|
+
my $percentage_free;
|
79
|
+
|
80
|
+
my $total = $mem_stats_ref->{'used_cache'} + $mem_stats_ref->{'free_cache'};
|
81
|
+
$percentage_free = int (($mem_stats_ref->{'free_cache'} / $total) * 100);
|
82
|
+
|
83
|
+
return $percentage_free;
|
84
|
+
}
|
85
|
+
|
86
|
+
#------------------------------------------#
|
87
|
+
|
88
|
+
sub usage {
|
89
|
+
print<<EOU;
|
90
|
+
|
91
|
+
$app - Copyright (c) 2006 Dean Wilson. Licensed under the GPL
|
92
|
+
|
93
|
+
This script reports the percentage of memory that's still free along
|
94
|
+
with a warning or a critical based upon user defined threshholds.
|
95
|
+
|
96
|
+
This script was written to be used in conjunction with Nagios.
|
97
|
+
|
98
|
+
Usage Examples:
|
99
|
+
$app -w 20 -c 10
|
100
|
+
$app -warn 30 -crit 15
|
101
|
+
$app -h # shows this information
|
102
|
+
|
103
|
+
Options:
|
104
|
+
-w | -warn
|
105
|
+
Warn if less than this percentage is free.
|
106
|
+
-c | -crit
|
107
|
+
Crit if less than this percentage is free.
|
108
|
+
-h
|
109
|
+
This help and usage information
|
110
|
+
|
111
|
+
Notes:
|
112
|
+
The output format of "free" (which this script wraps) can change
|
113
|
+
between releases. Please double check the outputs before you deploy
|
114
|
+
this script.
|
115
|
+
|
116
|
+
EOU
|
117
|
+
exit 3;
|
118
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
# Exit status
|
6
|
+
OK = 0
|
7
|
+
WARNING = 1
|
8
|
+
CRITICAL = 2
|
9
|
+
|
10
|
+
# use options instead
|
11
|
+
application = ARGV[0]
|
12
|
+
cluster_config_file = "/etc/mongrel_cluster/#{application}.yml"
|
13
|
+
|
14
|
+
def running?(pid)
|
15
|
+
# check if pid is running
|
16
|
+
ps_output = `ps -p #{pid}`
|
17
|
+
ps_output =~ /mongrel_rails/
|
18
|
+
end
|
19
|
+
|
20
|
+
def chdir_cwd
|
21
|
+
pwd = Dir.pwd
|
22
|
+
Dir.chdir(@options["cwd"]) if @options["cwd"]
|
23
|
+
yield
|
24
|
+
Dir.chdir(pwd) if @options["cwd"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def read_pid(port)
|
28
|
+
pid_file = port_pid_file(port)
|
29
|
+
pid = 0
|
30
|
+
chdir_cwd do
|
31
|
+
pid = File.read(pid_file)
|
32
|
+
end
|
33
|
+
pid
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
# Load cluster config from YAML file
|
38
|
+
begin
|
39
|
+
cluster_config = YAML.load_file(cluster_config_file)
|
40
|
+
port = cluster_config['port'].to_i
|
41
|
+
servers = cluster_config['servers']
|
42
|
+
ports = (port..port+servers-1).collect
|
43
|
+
if cluster_config['pid_file'].match(/^\//)
|
44
|
+
pid_file_base = cluster_config['pid_file']
|
45
|
+
else
|
46
|
+
pid_file_base = File.join(cluster_config['cwd'], cluster_config['pid_file'])
|
47
|
+
end
|
48
|
+
rescue
|
49
|
+
print 'CRITICAL'
|
50
|
+
puts " Could not load mongrel cluster file (#{cluster_config_file})"
|
51
|
+
exit CRITICAL
|
52
|
+
end
|
53
|
+
|
54
|
+
# Check each mongrel
|
55
|
+
running = []
|
56
|
+
not_running = []
|
57
|
+
|
58
|
+
ports.each {|port|
|
59
|
+
pidfile = pid_file_base.sub('.pid',".#{port}.pid")
|
60
|
+
if File.readable?(pidfile)
|
61
|
+
pid = File.read(pidfile)
|
62
|
+
if running?(pid)
|
63
|
+
running << port
|
64
|
+
else
|
65
|
+
not_running << port
|
66
|
+
end
|
67
|
+
else
|
68
|
+
not_running << port
|
69
|
+
end
|
70
|
+
}
|
71
|
+
|
72
|
+
# Print response and exit
|
73
|
+
|
74
|
+
if not_running.empty?
|
75
|
+
print 'OK '
|
76
|
+
puts "mongrel running on ports #{running.join(', ')}"
|
77
|
+
exit OK
|
78
|
+
else
|
79
|
+
print 'CRITICAL '
|
80
|
+
puts "mongrel not running on #{not_running.join(', ')}. #{'Running on ' + running.join(', ') unless running.empty?}"
|
81
|
+
exit CRITICAL
|
82
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
user <%= nginx_user %>;
|
3
|
-
worker_processes
|
3
|
+
worker_processes <%= nginx_worker_processes %>;
|
4
4
|
|
5
5
|
#error_log logs/error.log;
|
6
6
|
#error_log logs/error.log notice;
|
@@ -11,10 +11,12 @@ worker_processes 1;
|
|
11
11
|
|
12
12
|
events {
|
13
13
|
worker_connections 1024;
|
14
|
+
use epoll;
|
14
15
|
}
|
15
16
|
|
16
17
|
|
17
18
|
http {
|
19
|
+
server_names_hash_bucket_size 512;
|
18
20
|
include /usr/local/nginx/conf/vhosts/*.conf;
|
19
21
|
include mime.types;
|
20
22
|
default_type application/octet-stream;
|
@@ -26,16 +28,24 @@ http {
|
|
26
28
|
#access_log logs/access.log main;
|
27
29
|
|
28
30
|
sendfile on;
|
29
|
-
|
31
|
+
tcp_nopush on;
|
30
32
|
|
31
33
|
#keepalive_timeout 0;
|
32
34
|
keepalive_timeout 65;
|
33
35
|
|
34
|
-
|
36
|
+
gzip on;
|
37
|
+
gzip_http_version 1.0;
|
38
|
+
gzip_comp_level 5; # 0 - 10, More is heavier on the CPU
|
39
|
+
gzip_proxied any;
|
40
|
+
gzip_buffers 16 8k;
|
41
|
+
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
42
|
+
|
43
|
+
|
44
|
+
|
35
45
|
|
36
46
|
server {
|
37
47
|
listen 80;
|
38
|
-
server_name
|
48
|
+
server_name localhost;
|
39
49
|
|
40
50
|
#charset koi8-r;
|
41
51
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<VirtualHost *:80>
|
2
|
+
ServerName <%= domain %>
|
3
|
+
DocumentRoot "<%= passenger_document_root %>"
|
4
|
+
RailsEnv <%= rails_env %>
|
5
|
+
RailsAllowModRewrite <%= passenger_rails_allow_mod_rewrite %>
|
6
|
+
<directory "<%= passenger_document_root %>">
|
7
|
+
Order allow,deny
|
8
|
+
Allow from all
|
9
|
+
</directory>
|
10
|
+
</VirtualHost>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# http://www.modrails.com/documentation/Users%20guide.html#_configuring_phusion_passenger
|
2
|
+
|
3
|
+
LoadModule passenger_module <%= passenger_install_dir %>/ext/apache2/mod_passenger.so
|
4
|
+
PassengerRoot <%= passenger_install_dir %>
|
5
|
+
PassengerLogLevel <%= passenger_log_level %>
|
6
|
+
PassengerRuby /usr/local/bin/ruby
|
7
|
+
PassengerUserSwitching <%= passenger_user_switching %>
|
8
|
+
PassengerDefaultUser <%= passenger_default_user %>
|
9
|
+
PassengerMaxPoolSize <%= passenger_max_pool_size %>
|
10
|
+
PassengerMaxInstancesPerApp <%= passenger_max_instances_per_app %>
|
11
|
+
PassengerPoolIdleTime <%= passenger_pool_idle_time %>
|
12
|
+
|
13
|
+
# Ruby on Rails Options
|
14
|
+
|
15
|
+
RailsAutoDetect <%= passenger_rails_autodetect %>
|
16
|
+
RailsSpawnMethod <%= passenger_rails_spawn_method %>
|
17
|
+
|
18
|
+
<IfModule passenger_module>
|
19
|
+
NameVirtualHost *:80
|
20
|
+
</IfModule>
|