bcalloway-slicehost 0.6.1 → 0.7.5
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 → README.textile} +161 -34
- data/lib/capistrano/ext/slicehost/apache.rb +11 -0
- data/lib/capistrano/ext/slicehost/gems.rb +1 -1
- data/lib/capistrano/ext/slicehost/iptables.rb +8 -3
- data/lib/capistrano/ext/slicehost/ruby.rb +13 -12
- data/lib/capistrano/ext/slicehost/slice.rb +9 -0
- data/lib/capistrano/ext/slicehost/ssh.rb +1 -1
- data/lib/capistrano/ext/slicehost/templates/iptables_reboot.erb +2 -0
- data/lib/capistrano/ext/slicehost/templates/passenger.conf.erb +2 -2
- data/lib/capistrano/ext/slicehost/templates/passenger.load.erb +1 -1
- data/lib/capistrano/ext/slicehost/templates/vhost.erb +6 -3
- metadata +7 -6
data/{README → README.textile}
RENAMED
@@ -1,95 +1,225 @@
|
|
1
|
-
Slicehost Recipes
|
2
|
-
=================
|
1
|
+
h1. Slicehost Recipes
|
3
2
|
|
4
3
|
Note: This is a fork of the original slicehost Capistrano recipies by Joshua Peek
|
5
4
|
|
6
|
-
Slicehost Capistrano recipes for configuring and managing your slice. Require Capistrano >2.5.0
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
5
|
+
Slicehost Capistrano recipes for configuring and managing your slice. Require Capistrano >2.5.0.
|
6
|
+
|
7
|
+
*Requirements*
|
8
|
+
* Ubuntu 9.10 or newer
|
9
|
+
* Root access
|
10
|
+
* Capistrano
|
11
|
+
|
12
|
+
h3. Sample Capitrano Deploy Recipe
|
13
|
+
|
14
|
+
The following is a sample portion of a Capistrano deploy recipe. All the following options need to be set, although you might have some additions depending on your specific setup.
|
15
|
+
|
16
|
+
<pre><code>
|
17
|
+
set :project, 'myproject' # The name of the project in your GitHub repo
|
18
|
+
|
19
|
+
set :github_user, "username" # Your GitHub username
|
20
|
+
set :domain_name, "mydomain.com" # should be something like mydomain.com
|
21
|
+
set :user, 'username' # server username
|
22
|
+
set :domain, 'XXX.XXX.XX.XX' # server IP address
|
23
|
+
set :domain_prefix, "mydomain" # the production domain name prefix (no www. or .com)
|
24
|
+
set :domain_suffix, "com" # Is this a .com, .net, or .org? (just use the 2 letters, no dot)
|
25
|
+
set :passenger_version, "2.2.14"
|
26
|
+
|
27
|
+
default_run_options[:pty] = true
|
28
|
+
ssh_options[:forward_agent] = true
|
29
|
+
ssh_options[:port] = 22 # or change this to an alternate port if you want
|
30
|
+
|
31
|
+
set :repository, "git@github.com:#{github_user}/#{project}.git" #GitHub clone URL
|
32
|
+
set :scm, "git"
|
33
|
+
set :scm_passphrase, "" # This is the passphrase (if any) for the ssh key on the server deployed to
|
34
|
+
set :branch, "master" # or whatever branch you deploy from
|
35
|
+
set :scm_verbose, true
|
36
|
+
set :subdomain, "#{project}.#{domain_name}"
|
37
|
+
set :application, project
|
38
|
+
set :applicationdir, "/home/#{project}" # or whatever directory you want to deploy to
|
39
|
+
|
40
|
+
# Don't change this stuff, but you may want to set shared files at the end of the file ##################
|
41
|
+
# deploy config
|
42
|
+
set :deploy_to, applicationdir
|
43
|
+
set :deploy_via, :remote_cache
|
44
|
+
|
45
|
+
# roles (servers)
|
46
|
+
role :app, domain
|
47
|
+
role :web, domain
|
48
|
+
role :files, domain
|
49
|
+
role :gateway, domain
|
50
|
+
role :gateway_as_root, domain
|
51
|
+
role :db, domain, :primary => true
|
52
|
+
|
53
|
+
#################################
|
54
|
+
# All your other deploy settings below here.
|
55
|
+
</code></pre>
|
56
|
+
|
57
|
+
h3. Setup
|
58
|
+
|
59
|
+
In config/deploy.rb:
|
60
|
+
<pre><code>
|
61
|
+
require 'capistrano/ext/slicehost'
|
62
|
+
</code></pre>
|
63
|
+
|
64
|
+
In your project root, type the following to see a full list of commands:
|
65
|
+
<pre><code>
|
66
|
+
cap -T
|
67
|
+
</code></pre>
|
68
|
+
|
69
|
+
h3. Usage
|
70
|
+
|
71
|
+
First, setup a normal user. Be sure your capistrano deploy recipe is set to use the root user.
|
72
|
+
<pre><code>
|
73
|
+
cap useradd:setup
|
74
|
+
</code><pre>
|
75
|
+
|
76
|
+
Now, change your capistrano deploy recipe to use the user you just created, and continue.
|
77
|
+
|
78
|
+
<pre><code>
|
79
|
+
cap slice:configure
|
80
|
+
</code><pre>
|
81
|
+
|
82
|
+
This task performs the following:
|
83
|
+
* Sets-up and secures ssh
|
84
|
+
* Creates a .bash_profile with helpful shortcuts and colors and creates a nano editor profile
|
85
|
+
* Sets-up and secures the system with iptables
|
86
|
+
* Installs and updates aptitude, and provisions the server with essential services
|
87
|
+
* Sets-up and installs vim
|
88
|
+
* Sets-up and installs imagemagick
|
89
|
+
|
90
|
+
Next, we install a full Ruby stack:<br />
|
91
|
+
* Apache
|
92
|
+
* Ruby1.8
|
93
|
+
* RubyGems
|
94
|
+
* Passenger
|
95
|
+
* Git
|
96
|
+
<pre><code>
|
97
|
+
cap slice:provision
|
98
|
+
</code><pre>
|
99
|
+
|
100
|
+
_Note: if you choose to go back and install a Ruby verison other than 1.8.x, you will need to reinstall Passenger_
|
101
|
+
|
102
|
+
Now install Rails (it will prompt for what gem you want to install, in this case, type "rails")
|
103
|
+
<pre><code>
|
104
|
+
cap gems:install
|
105
|
+
</code><pre>
|
106
|
+
|
107
|
+
You will need to ssh into the server in order to setup mysql and postfix:
|
108
|
+
<pre><code>
|
109
|
+
sudo aptitude install -y mysql-server mysql-client libmysqlclient15-dev libmysql-ruby1.8
|
110
|
+
sudo aptitude install postfix telnet heirloom-mailx
|
111
|
+
</code></pre>
|
112
|
+
|
113
|
+
For more information on installing Postfix, see this: "http://articles.slicehost.com/2008/7/29/postfix-installation":http://articles.slicehost.com/2008/7/29/postfix-installation
|
114
|
+
|
115
|
+
That should be it for a basic, Rails server.
|
116
|
+
|
117
|
+
h3. Slice setup recipes
|
118
|
+
|
119
|
+
Commonly used setup recipes. Check the source for more.
|
25
120
|
|
26
121
|
Setup ssh, iptables and aptitude
|
122
|
+
<pre><code>
|
27
123
|
cap slice:configure
|
28
|
-
|
29
|
-
Setup mysql
|
30
|
-
cap mysql:install
|
124
|
+
</code></pre>
|
31
125
|
|
32
126
|
Install Apache
|
127
|
+
<pre><code>
|
33
128
|
cap apache:install
|
129
|
+
</code></pre>
|
34
130
|
|
35
131
|
Install ruby 1.8
|
132
|
+
<pre><code>
|
36
133
|
cap ruby:setup_18
|
134
|
+
</code></pre>
|
37
135
|
|
38
136
|
Install ruby enterprise
|
137
|
+
<pre><code>
|
39
138
|
cap ruby:install_enterprise
|
139
|
+
</code></pre>
|
40
140
|
|
41
141
|
Install ruby gems
|
142
|
+
<pre><code>
|
42
143
|
cap gems:install_rubygems
|
144
|
+
</code></pre>
|
43
145
|
|
44
146
|
Install passenger
|
147
|
+
<pre><code>
|
45
148
|
cap ruby:install_passenger
|
149
|
+
</code></pre>
|
46
150
|
|
47
151
|
Upload vhost template
|
152
|
+
<pre><code>
|
48
153
|
cap apache:upload_vhost
|
154
|
+
</code></pre>
|
49
155
|
|
50
156
|
Install git
|
157
|
+
<pre><code>
|
51
158
|
cap git:install
|
159
|
+
</code></pre>
|
52
160
|
|
53
|
-
Maintenance
|
54
|
-
====================
|
161
|
+
h3. Maintenance recipes
|
55
162
|
|
56
|
-
Commonly used
|
163
|
+
Commonly used maintenance recipes. Check the source for more.
|
57
164
|
|
58
165
|
Show disk space
|
166
|
+
<pre><code>
|
59
167
|
cap disk:free
|
168
|
+
</code></pre>
|
60
169
|
|
61
170
|
Show free memory
|
171
|
+
<pre><code>
|
62
172
|
cap disk:memory
|
173
|
+
</code></pre>
|
63
174
|
|
64
175
|
Update aptitude
|
176
|
+
<pre><code>
|
65
177
|
cap aptitude:update
|
178
|
+
</code></pre>
|
66
179
|
|
67
180
|
Upgrade aptitude
|
181
|
+
<pre><code>
|
68
182
|
cap aptitude:upgrade
|
183
|
+
</code></pre>
|
69
184
|
|
70
185
|
Install package (it will ask you which)
|
186
|
+
<pre><code>
|
71
187
|
cap aptitude:install
|
188
|
+
</code></pre>
|
72
189
|
|
73
190
|
Reload SSH
|
191
|
+
<pre><code>
|
74
192
|
cap ssh:reload
|
193
|
+
</code></pre>
|
75
194
|
|
76
195
|
Install a gem (it will ask you which)
|
196
|
+
<pre><code>
|
77
197
|
cap gems:intall
|
198
|
+
</code></pre>
|
78
199
|
|
79
200
|
List gems
|
201
|
+
<pre><code>
|
80
202
|
cap gems:list
|
203
|
+
</code></pre>
|
81
204
|
|
82
205
|
Restart apache
|
206
|
+
<pre><code>
|
83
207
|
cap apache:restart
|
208
|
+
</code></pre>
|
84
209
|
|
85
210
|
Reload apache
|
211
|
+
<pre><code>
|
86
212
|
cap apache:reload
|
213
|
+
</code></pre>
|
87
214
|
|
88
215
|
Force reload apache
|
216
|
+
<pre><code>
|
89
217
|
cap apache:force_reload
|
218
|
+
</code></pre>
|
219
|
+
|
220
|
+
h3. All Recipes
|
90
221
|
|
91
|
-
|
92
|
-
===================
|
222
|
+
<pre><code>
|
93
223
|
cap apache:available_modules # List available Apache modules
|
94
224
|
cap apache:available_sites # List available Apache sites
|
95
225
|
cap apache:disable_module # Disable Apache module
|
@@ -164,12 +294,9 @@ cap useradd:setup # Interactive adduser
|
|
164
294
|
cap vim:install # install vim from aptitude
|
165
295
|
cap vim:load_vimrc # load up a simple .vimrc
|
166
296
|
cap vim:setup # setup vim on slicehost
|
297
|
+
</code></pre>
|
167
298
|
|
168
|
-
|
169
|
-
|
170
|
-
Contributors
|
171
|
-
============
|
172
|
-
|
299
|
+
*Contributors*
|
173
300
|
* Oleg Zhurbiy
|
174
301
|
* Thomas Balthazar
|
175
302
|
* Fran Diéguez
|
@@ -3,6 +3,16 @@ set(:domain) do
|
|
3
3
|
end
|
4
4
|
|
5
5
|
namespace :apache do
|
6
|
+
desc "Install and setup Apache, create vhost container, and enable site"
|
7
|
+
task :setup do
|
8
|
+
install
|
9
|
+
sudo "sudo a2enmod rewrite"
|
10
|
+
upload_vhost
|
11
|
+
sudo "sudo a2ensite #{application}"
|
12
|
+
reload
|
13
|
+
restart
|
14
|
+
end
|
15
|
+
|
6
16
|
desc "Restarts Apache webserver"
|
7
17
|
task :restart, :roles => :web do
|
8
18
|
sudo "/etc/init.d/apache2 restart"
|
@@ -80,6 +90,7 @@ namespace :apache do
|
|
80
90
|
task :upload_vhost, :roles => :web do
|
81
91
|
put render("vhost", binding), application
|
82
92
|
sudo "mv #{application} /etc/apache2/sites-available/#{application}"
|
93
|
+
sudo "chown root:root /etc/apache2/sites-available/#{application}"
|
83
94
|
end
|
84
95
|
|
85
96
|
desc "Install Apache"
|
@@ -3,7 +3,7 @@ namespace :gems do
|
|
3
3
|
task :install_rubygems, :roles => :app do
|
4
4
|
rubygems_url = "http://rubyforge.org/" + Net::HTTP.get( URI.parse('http://rubyforge.org/frs/?group_id=126') ).scan(/frs\/.*\.tgz/).first.split('"')[0]
|
5
5
|
rubygems_version = rubygems_url[/(rubygems.*)(.tgz)/, 1]
|
6
|
-
run "test ! -f /usr/bin/gem"
|
6
|
+
#run "test ! -f /usr/bin/gem"
|
7
7
|
run "wget -q #{rubygems_url}"
|
8
8
|
run "tar xzvf #{rubygems_version}.tgz"
|
9
9
|
run "rm #{rubygems_version}.tgz"
|
@@ -6,8 +6,8 @@ namespace :iptables do
|
|
6
6
|
http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-page-1
|
7
7
|
DESC
|
8
8
|
task :configure, :roles => :gateway do
|
9
|
-
put render("iptables", binding), "iptables.
|
10
|
-
sudo "mv iptables.
|
9
|
+
put render("iptables", binding), "iptables.up.rules"
|
10
|
+
sudo "mv iptables.up.rules /etc/iptables.up.rules"
|
11
11
|
|
12
12
|
if capture("cat /etc/network/interfaces").grep(/iptables/).empty?
|
13
13
|
run %(cat /etc/network/interfaces |
|
@@ -18,7 +18,12 @@ namespace :iptables do
|
|
18
18
|
sudo "mv interfaces /etc/network/interfaces"
|
19
19
|
end
|
20
20
|
|
21
|
-
sudo "iptables-restore < /etc/iptables.
|
21
|
+
sudo "iptables-restore < /etc/iptables.up.rules"
|
22
22
|
sudo "iptables-save > /etc/iptables.up.rules"
|
23
|
+
|
24
|
+
put render("iptables_reboot", binding), "iptables_reboot"
|
25
|
+
sudo "mv iptables_reboot /etc/network/if-pre-up.d/iptables_reboot"
|
26
|
+
sudo "chmod +x /etc/network/if-pre-up.d/iptables_reboot"
|
27
|
+
|
23
28
|
end
|
24
29
|
end
|
@@ -8,24 +8,25 @@ set :ruby_enterprise_version do
|
|
8
8
|
"#{ruby_enterprise_url[/(ruby-enterprise.*)(.tar.gz)/, 1]}"
|
9
9
|
end
|
10
10
|
|
11
|
-
set :passenger_version do
|
12
|
-
capture("gem list passenger$ -r").gsub(/[\n|\s|passenger|(|)]/,"")
|
13
|
-
end
|
14
|
-
|
15
11
|
namespace :ruby do
|
16
12
|
desc "Install Ruby 1.8"
|
17
13
|
task :setup_18, :roles => :app do
|
18
14
|
sudo "aptitude install -y ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8"
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# sudo "ln -s /usr/bin/irb1.8 /usr/bin/irb"
|
15
|
+
sudo "ln -s /usr/bin/ruby1.8 /usr/bin/ruby"
|
16
|
+
sudo "ln -s /usr/bin/ri1.8 /usr/bin/ri"
|
17
|
+
sudo "ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc"
|
18
|
+
sudo "ln -s /usr/bin/irb1.8 /usr/bin/irb"
|
24
19
|
end
|
25
20
|
|
26
21
|
desc "Install Ruby 1.9"
|
27
22
|
task :setup_19, :roles => :app do
|
28
|
-
sudo "aptitude
|
23
|
+
sudo "aptitude -q -y install libc6-dev libssl-dev libmysql++-dev libsqlite3-dev make build-essential libssl-dev libreadline5-dev zlib1g-dev"
|
24
|
+
run "wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz"
|
25
|
+
run "tar zxvf ruby-1.9.1-p243.tar.gz"
|
26
|
+
run "cd ruby-1.9.1-p243"
|
27
|
+
run "./configure"
|
28
|
+
run "make"
|
29
|
+
sudo "make install"
|
29
30
|
end
|
30
31
|
|
31
32
|
desc "Install Ruby Enterpise Edition"
|
@@ -44,8 +45,8 @@ namespace :ruby do
|
|
44
45
|
task :install_passenger_apache, :roles => :app do
|
45
46
|
sudo "apt-get install apache2-mpm-prefork"
|
46
47
|
sudo "aptitude install -y apache2-prefork-dev"
|
47
|
-
sudo "
|
48
|
-
sudo "
|
48
|
+
sudo "gem install passenger -v #{passenger_version}"
|
49
|
+
sudo "passenger-install-apache2-module --auto"
|
49
50
|
|
50
51
|
put render("passenger.load", binding), "/home/#{user}/passenger.load"
|
51
52
|
put render("passenger.conf", binding), "/home/#{user}/passenger.conf"
|
@@ -8,6 +8,15 @@ namespace :slice do
|
|
8
8
|
vim.setup
|
9
9
|
imagemagick.install
|
10
10
|
end
|
11
|
+
|
12
|
+
desc "Provision the server with a full Rails stack"
|
13
|
+
task :provision do
|
14
|
+
apache.setup
|
15
|
+
ruby.setup_18
|
16
|
+
gems.install_rubygems
|
17
|
+
ruby.install_passenger_apache
|
18
|
+
git.install
|
19
|
+
end
|
11
20
|
end
|
12
21
|
|
13
22
|
namespace :imagemagick do
|
@@ -1,2 +1,2 @@
|
|
1
|
-
PassengerRoot /
|
2
|
-
PassengerRuby /
|
1
|
+
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-<%= passenger_version %>
|
2
|
+
PassengerRuby /usr/bin/ruby1.8
|
@@ -1 +1 @@
|
|
1
|
-
LoadModule passenger_module /
|
1
|
+
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-<%= passenger_version %>/ext/apache2/mod_passenger.so
|
@@ -1,8 +1,11 @@
|
|
1
1
|
<VirtualHost *:80>
|
2
2
|
|
3
|
-
ServerName <%=
|
4
|
-
ServerAlias www.<%=
|
3
|
+
ServerName <%= domain_name %>
|
4
|
+
ServerAlias www.<%= domain_name %>
|
5
5
|
|
6
6
|
DocumentRoot <%= current_path %>/public
|
7
|
-
|
7
|
+
|
8
|
+
RewriteEngine on
|
9
|
+
RewriteCond %{HTTP_HOST} ^www\.<%= domain_prefix %>\.<%= domain_suffix %>$ [NC]
|
10
|
+
RewriteRule ^(.*)$ http://<%= domain_prefix %>.<%= domain_suffix %>$1 [L,R=301]
|
8
11
|
</VirtualHost>
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 7
|
8
|
+
- 5
|
9
|
+
version: 0.7.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joshua Peek, Brandon Calloway
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-04 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -38,10 +38,9 @@ executables: []
|
|
38
38
|
extensions: []
|
39
39
|
|
40
40
|
extra_rdoc_files:
|
41
|
-
- README
|
41
|
+
- README.textile
|
42
42
|
files:
|
43
43
|
- MIT-LICENSE
|
44
|
-
- README
|
45
44
|
- lib/capistrano/ext/slicehost.rb
|
46
45
|
- lib/capistrano/ext/slicehost/apache.rb
|
47
46
|
- lib/capistrano/ext/slicehost/aptitude.rb
|
@@ -60,6 +59,7 @@ files:
|
|
60
59
|
- lib/capistrano/ext/slicehost/ssh.rb
|
61
60
|
- lib/capistrano/ext/slicehost/templates/bashrc.erb
|
62
61
|
- lib/capistrano/ext/slicehost/templates/iptables.erb
|
62
|
+
- lib/capistrano/ext/slicehost/templates/iptables_reboot.erb
|
63
63
|
- lib/capistrano/ext/slicehost/templates/istatdlauncher.erb
|
64
64
|
- lib/capistrano/ext/slicehost/templates/mydircolors.erb
|
65
65
|
- lib/capistrano/ext/slicehost/templates/nanorc.erb
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/capistrano/ext/slicehost/templates/vimrc.erb
|
72
72
|
- lib/capistrano/ext/slicehost/useradd.rb
|
73
73
|
- lib/capistrano/ext/slicehost/vim.rb
|
74
|
+
- README.textile
|
74
75
|
has_rdoc: true
|
75
76
|
homepage: http://github.com/bcalloway/slicehost
|
76
77
|
licenses: []
|