winton-cookbook 1.0.3 → 1.1.0
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/README.markdown +4 -2
- data/deploy.rb.example +12 -9
- data/lib/cookbook.rb +9 -1
- data/lib/cookbook_helpers.rb +1 -1
- data/lib/recipes/debian.rb +19 -9
- data/lib/recipes/gems.rb +7 -1
- data/lib/recipes/rails.rb +33 -4
- data/lib/recipes/ssh.rb +3 -3
- data/lib/templates/debian/bash_profile.erb +1 -1
- data/lib/templates/monit/mongrel.erb +2 -2
- metadata +1 -1
data/README.markdown
CHANGED
@@ -76,9 +76,11 @@ Set up your fresh Debian server
|
|
76
76
|
|
77
77
|
### On your machine
|
78
78
|
|
79
|
-
|
79
|
+
You may want to run the commands in **[debian:aptitude](http://github.com/winton/cookbook/tree/master/lib/recipes/debian.rb)** from the remote shell if it is your first time doing so.
|
80
80
|
|
81
|
-
|
81
|
+
cap debian:aptitude
|
82
|
+
cap debian:config
|
83
|
+
cap debian:install
|
82
84
|
|
83
85
|
### On the server
|
84
86
|
|
data/deploy.rb.example
CHANGED
@@ -2,7 +2,7 @@ set :cookbook, {
|
|
2
2
|
:application => 'my_app',
|
3
3
|
:base_dir => '/var/www',
|
4
4
|
:repository => 'git@github.com:user/my-app.git',
|
5
|
-
#:platform => :php
|
5
|
+
#:platform => :php, # If enabled, you can remove all mongrel* lines
|
6
6
|
:mongrel_port => 3000, # Your next app should be 3003
|
7
7
|
:ssh_port => 22, # Or any unused port above 1024 (best practice)
|
8
8
|
|
@@ -31,15 +31,18 @@ set :cookbook, {
|
|
31
31
|
},
|
32
32
|
|
33
33
|
:sources => {
|
34
|
-
:git
|
35
|
-
:lighttpd
|
36
|
-
:nginx
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
34
|
+
:git => 'http://kernel.org/pub/software/scm/git/git-1.6.0.1.tar.gz',
|
35
|
+
:lighttpd => 'http://www.lighttpd.net/download/lighttpd-1.4.19.tar.gz',
|
36
|
+
:nginx => 'http://sysoev.ru/nginx/nginx-0.6.32.tar.gz',
|
37
|
+
:mysecureshell => 'http://internap.dl.sourceforge.net/sourceforge/mysecureshell/MySecureShell-1.0_source.tgz',
|
38
|
+
:ruby => 'ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz',
|
39
|
+
:rubygems => 'http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz',
|
40
|
+
:sphinx => 'http://www.sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz'
|
40
41
|
}
|
41
42
|
}
|
42
43
|
|
43
|
-
#
|
44
|
+
# If installed from gem
|
45
|
+
require 'cookbook'
|
44
46
|
|
45
|
-
|
47
|
+
# If installed from plugin
|
48
|
+
# require 'vendor/plugins/cookbook/lib/cookbook'
|
data/lib/cookbook.rb
CHANGED
@@ -30,7 +30,9 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
30
30
|
set :auth_user, fetch(:auth_user, false)
|
31
31
|
set :nginx_dir, fetch(:nginx_dir, '/usr/local/nginx/conf')
|
32
32
|
set :mysql_dir, fetch(:mysql_dir, '/etc/mysql')
|
33
|
+
set :app_helpers, fetch(:app_helpers, false)
|
33
34
|
set :ultrasphinx, fetch(:ultrasphinx, false)
|
35
|
+
set :thinking_sphinx, fetch(:thinking_sphinx, false)
|
34
36
|
set :attachment_fu, fetch(:attachment_fu, false)
|
35
37
|
set :asset_packager, fetch(:asset_packager, false)
|
36
38
|
set :mongrel_etc_dir, fetch(:mongrel_etc_dir, '/usr/local/etc/mongrel_cluster')
|
@@ -50,8 +52,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
50
52
|
|
51
53
|
on :before, 'setup_stage', :except => [ :staging, :testing ] # Executed before every task
|
52
54
|
if platform == :rails
|
53
|
-
after 'deploy:update_code', 'rails:setup_git' # Initialize submodules
|
55
|
+
#after 'deploy:update_code', 'rails:setup_git' # Initialize submodules
|
54
56
|
after 'deploy:update_code', 'rails:config:to_app' # Copy shared config to app
|
57
|
+
if app_helpers
|
58
|
+
after 'deploy:update_code', 'rails:config:app_helpers' # Set up app with app_helpers
|
59
|
+
end
|
55
60
|
if asset_packager
|
56
61
|
after 'deploy:update_code', 'rails:config:asset_packager' # Configure attachment_fu
|
57
62
|
end
|
@@ -61,6 +66,9 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
61
66
|
if ultrasphinx
|
62
67
|
after 'deploy:update_code', 'rails:config:ultrasphinx' # Configure ultrasphinx
|
63
68
|
end
|
69
|
+
if thinking_sphinx
|
70
|
+
after 'deploy:update_code', 'rails:config:thinking_sphinx' # Configure thinking_sphinx
|
71
|
+
end
|
64
72
|
end
|
65
73
|
|
66
74
|
end
|
data/lib/cookbook_helpers.rb
CHANGED
data/lib/recipes/debian.rb
CHANGED
@@ -104,6 +104,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
104
104
|
task :default do
|
105
105
|
debian.install.git
|
106
106
|
debian.install.lighttpd
|
107
|
+
debian.install.mysecureshell
|
107
108
|
debian.install.mysql
|
108
109
|
debian.install.nginx
|
109
110
|
debian.install.php
|
@@ -118,7 +119,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
118
119
|
install_source(:git) do |path|
|
119
120
|
sudo_puts [
|
120
121
|
"aptitude install tcl8.4 tk8.4 gettext -q -y",
|
121
|
-
"cd #{path} && ./configure && make && sudo make install"
|
122
|
+
";cd #{path} && ./configure && make && sudo make install"
|
122
123
|
]
|
123
124
|
end
|
124
125
|
end
|
@@ -127,27 +128,36 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
127
128
|
task :lighttpd, :roles => :app do
|
128
129
|
sudo_puts 'aptitude install libpcre3-dev libbz2-dev -q -y'
|
129
130
|
install_source(:lighttpd) do |path|
|
130
|
-
sudo_puts "cd #{path} && ./configure && make && sudo make install"
|
131
|
+
sudo_puts ";cd #{path} && ./configure && make && sudo make install"
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
134
135
|
desc 'Install Monit'
|
135
136
|
task :monit, :roles => :db do
|
136
137
|
sudo_puts 'aptitude install monit -q -y'
|
137
|
-
monit.config.default
|
138
|
+
ROOT.monit.config.default
|
139
|
+
end
|
140
|
+
|
141
|
+
desc "Install MySecureShell"
|
142
|
+
task :mysecureshell, :roles => :app do
|
143
|
+
# http://www.howtoforge.com/mysecureshell_sftp_debian_etch
|
144
|
+
sudo_puts 'aptitude install libssl0.9.7 ssh openssh-server -q -y'
|
145
|
+
install_source(:mysecureshell) do |path|
|
146
|
+
sudo_puts ";cd ~/sources/mysecureshell* && ./configure && make && sudo make install"
|
147
|
+
end
|
138
148
|
end
|
139
149
|
|
140
150
|
desc 'Install MySQL'
|
141
151
|
task :mysql, :roles => :db do
|
142
152
|
sudo_puts 'aptitude install mysql-server mysql-client libmysqlclient15-dev libmysql-ruby -q -y'
|
143
153
|
ROOT.mysql.config
|
154
|
+
ROOT.mysql.create.user
|
144
155
|
puts [
|
145
156
|
'',
|
146
157
|
"It is highly recommended you run mysql_secure_installation manually.",
|
147
158
|
"See http://dev.mysql.com/doc/refman/5.1/en/mysql-secure-installation.html",
|
148
159
|
''
|
149
160
|
].join("\n")
|
150
|
-
ROOT.mysql.create.user
|
151
161
|
end
|
152
162
|
|
153
163
|
desc 'Install Nginx'
|
@@ -155,7 +165,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
155
165
|
# apache2-utils for htpasswd, rest for nginx build
|
156
166
|
sudo_puts 'aptitude install apache2-utils libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev -q -y'
|
157
167
|
install_source(:nginx) do |path|
|
158
|
-
sudo_puts "cd #{path} && ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module && make && sudo make install"
|
168
|
+
sudo_puts ";cd #{path} && ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module && make && sudo make install"
|
159
169
|
end
|
160
170
|
upload_from_erb '/etc/init.d/nginx', binding, :chown => 'root', :chmod => '+x', :folder => 'nginx'
|
161
171
|
sudo '/usr/sbin/update-rc.d -f nginx defaults'
|
@@ -164,7 +174,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
164
174
|
|
165
175
|
desc "Install PHP"
|
166
176
|
task :php, :roles => :app do
|
167
|
-
sudo_puts 'aptitude install php5-cli php5-cgi php5-mysql php5-xcache -q -y'
|
177
|
+
sudo_puts 'aptitude install php5-cli php5-cgi php5-mysql php5-xcache php-pear php-mail php-net-smtp -q -y'
|
168
178
|
upload_from_erb [
|
169
179
|
'/usr/local/bin/php-fastcgi',
|
170
180
|
'/etc/init.d/init-fastcgi'
|
@@ -175,14 +185,14 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
175
185
|
desc 'Install Ruby'
|
176
186
|
task :ruby, :roles => :app do
|
177
187
|
install_source(:ruby) do |path|
|
178
|
-
sudo_puts "cd #{path} && ./configure && make && sudo make install"
|
188
|
+
sudo_puts ";cd #{path} && ./configure && make && sudo make install"
|
179
189
|
end
|
180
190
|
end
|
181
191
|
|
182
192
|
desc 'Install RubyGems'
|
183
193
|
task :rubygems, :roles => :app do
|
184
194
|
install_source(:rubygems) do |path|
|
185
|
-
|
195
|
+
run_puts "cd #{path} && sudo ruby setup.rb"
|
186
196
|
end
|
187
197
|
gems.update
|
188
198
|
gems.install
|
@@ -191,7 +201,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
191
201
|
desc 'Install Sphinx'
|
192
202
|
task :sphinx, :roles => :app do
|
193
203
|
install_source(:sphinx) do |path|
|
194
|
-
sudo_puts "cd #{path} && ./configure && make && sudo make install"
|
204
|
+
sudo_puts ";cd #{path} && ./configure && make && sudo make install"
|
195
205
|
end
|
196
206
|
end
|
197
207
|
end
|
data/lib/recipes/gems.rb
CHANGED
@@ -22,6 +22,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
22
22
|
gems.install.mime_types
|
23
23
|
gems.install.mongrel
|
24
24
|
gems.install.rails
|
25
|
+
gems.install.redcloth
|
25
26
|
end
|
26
27
|
|
27
28
|
desc 'Install Chronic'
|
@@ -58,13 +59,18 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
58
59
|
task :mongrel, :roles => :app do
|
59
60
|
gem_install :mongrel
|
60
61
|
gem_install :mongrel_cluster
|
61
|
-
mongrel.config.survive_reboot
|
62
|
+
ROOT.mongrel.config.survive_reboot
|
62
63
|
end
|
63
64
|
|
64
65
|
desc 'Install Rails'
|
65
66
|
task :rails, :roles => :app do
|
66
67
|
gem_install :rails
|
67
68
|
end
|
69
|
+
|
70
|
+
desc 'Install RedCloth'
|
71
|
+
task :redcloth, :roles => :app do
|
72
|
+
gem_install 'RedCloth'
|
73
|
+
end
|
68
74
|
end
|
69
75
|
|
70
76
|
desc "Uninstall a remote gem"
|
data/lib/recipes/rails.rb
CHANGED
@@ -5,7 +5,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
5
5
|
desc "Copies all files in cookbook/rails to shared config"
|
6
6
|
task :default, :roles => :app do
|
7
7
|
run "mkdir -p #{shared_path}/config"
|
8
|
-
Dir[File.expand_path('../
|
8
|
+
Dir[File.expand_path('../templates/rails/*', File.dirname(__FILE__))].each do |f|
|
9
9
|
upload_from_erb "#{shared_path}/config/#{File.basename(f, '.erb')}", binding, :folder => 'rails'
|
10
10
|
end
|
11
11
|
end
|
@@ -15,6 +15,12 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
15
15
|
run "cp -Rf #{shared_path}/config/* #{release_path}/config"
|
16
16
|
end
|
17
17
|
|
18
|
+
desc "Set up app with app_helpers"
|
19
|
+
task :app_helpers do
|
20
|
+
run "cd #{release_path} && script/plugin install git://github.com/winton/app_helpers.git"
|
21
|
+
run "cd #{release_path} && rake RAILS_ENV=production quiet=true app_helpers"
|
22
|
+
end
|
23
|
+
|
18
24
|
desc "Configure asset_packager"
|
19
25
|
task :asset_packager do
|
20
26
|
run "source ~/.bash_profile && cd #{release_path} && rake RAILS_ENV=production asset:packager:build_all"
|
@@ -32,20 +38,43 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
32
38
|
]
|
33
39
|
end
|
34
40
|
|
41
|
+
namespace :thinking_sphinx do
|
42
|
+
desc "Configures thinking_sphinx"
|
43
|
+
task :default, :roles => :app do
|
44
|
+
sudo ";cd #{release_path} && rake RAILS_ENV=production ts:config"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Stop thinking_sphinx"
|
48
|
+
task :stop, :roles => :app do
|
49
|
+
sudo ";cd #{release_path} && rake RAILS_ENV=production ts:stop"
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Start thinking_sphinx"
|
53
|
+
task :start, :roles => :app do
|
54
|
+
sudo ";cd #{release_path} && rake RAILS_ENV=production ts:start"
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Restart thinking_sphinx"
|
58
|
+
task :restart, :roles => :app do
|
59
|
+
rails.config.thinking_sphinx.stop
|
60
|
+
rails.config.thinking_sphinx.start
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
35
64
|
namespace :ultrasphinx do
|
36
65
|
desc "Configures ultrasphinx"
|
37
66
|
task :default, :roles => :app do
|
38
|
-
sudo "cd #{release_path} && rake RAILS_ENV=production ultrasphinx:configure"
|
67
|
+
sudo ";cd #{release_path} && rake RAILS_ENV=production ultrasphinx:configure"
|
39
68
|
end
|
40
69
|
|
41
70
|
desc "Stop ultrasphinx"
|
42
71
|
task :stop, :roles => :app do
|
43
|
-
sudo "cd #{release_path} && rake RAILS_ENV=production ultrasphinx:daemon:stop"
|
72
|
+
sudo ";cd #{release_path} && rake RAILS_ENV=production ultrasphinx:daemon:stop"
|
44
73
|
end
|
45
74
|
|
46
75
|
desc "Start ultrasphinx"
|
47
76
|
task :start, :roles => :app do
|
48
|
-
sudo "cd #{release_path} && rake RAILS_ENV=production ultrasphinx:daemon:start"
|
77
|
+
sudo ";cd #{release_path} && rake RAILS_ENV=production ultrasphinx:daemon:start"
|
49
78
|
end
|
50
79
|
|
51
80
|
desc "Restart ultrasphinx"
|
data/lib/recipes/ssh.rb
CHANGED
@@ -45,13 +45,13 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
45
45
|
usr = ask "Upload ssh public keys to which user? (default: #{user})", user
|
46
46
|
keys = ask "Press enter to copy all public keys (~/.ssh/*.pub), or paste a key: ", get_ssh_keys
|
47
47
|
|
48
|
-
if
|
48
|
+
if keys.empty?
|
49
49
|
ssh.setup if yes("No keys found. Generate ssh keys now?")
|
50
50
|
else
|
51
51
|
sudo_each [
|
52
|
-
"mkdir /home/#{usr}/.ssh",
|
52
|
+
"mkdir -p /home/#{usr}/.ssh",
|
53
53
|
"touch /home/#{usr}/.ssh/authorized_keys",
|
54
|
-
"echo \"#{keys}\"
|
54
|
+
"echo \"#{keys.strip}\" | sudo tee /home/#{usr}/.ssh/authorized_keys",
|
55
55
|
"chmod 0700 /home/#{usr}/.ssh",
|
56
56
|
"chmod 0600 /home/#{usr}/.ssh/authorized_keys",
|
57
57
|
"chown -R #{usr} /home/#{usr}/.ssh",
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<% mongrels.times do |x| %>
|
2
2
|
check process mongrel_<%= application %>_<%= mongrel_port + x %> with pidfile <%= deploy_to %>/shared/pids/mongrel.<%= mongrel_port + x %>.pid
|
3
3
|
group mongrel
|
4
|
-
start program = "mongrel_rails cluster::start -C <%= "#{mongrel_etc_dir}/#{application}_#{stage}.yml" %> --clean --only <%= mongrel_port + x %>"
|
5
|
-
stop program = "mongrel_rails cluster::stop -C <%= "#{mongrel_etc_dir}/#{application}_#{stage}.yml" %> --clean --only <%= mongrel_port + x %>"
|
4
|
+
start program = "/usr/local/bin/mongrel_rails cluster::start -C <%= "#{mongrel_etc_dir}/#{application}_#{stage}.yml" %> --clean --only <%= mongrel_port + x %>"
|
5
|
+
stop program = "/usr/local/bin/mongrel_rails cluster::stop -C <%= "#{mongrel_etc_dir}/#{application}_#{stage}.yml" %> --clean --only <%= mongrel_port + x %>"
|
6
6
|
if failed host 127.0.0.1 port <%= mongrel_port + x %> protocol http with timeout 10 seconds then restart
|
7
7
|
if totalmem is greater than 110.0 MB for 4 cycles then restart # eating up memory?
|
8
8
|
if cpu is greater than 50% for 2 cycles then alert # send an email to admin
|