deprec 1.6.0 → 1.7.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.
@@ -0,0 +1,15 @@
1
+ == Slicehost extras
2
+
3
+ # A freshly built slice gives you the root account
4
+ # This creates a user account with sudo access
5
+ # The '_as_root' means 'log in as root to do this'
6
+ #
7
+ export HOSTS=deptest.deprecated.org
8
+ cap setup_admin_account_as_root
9
+ cap setup_ssh_keys
10
+ cap install_rails_stack
11
+ cap setup
12
+ cap deploy_with_migrations
13
+ cap restart_apache
14
+
15
+
@@ -0,0 +1,172 @@
1
+ <pre>
2
+ ---------------------------
3
+ deprec - Deployment Recipes
4
+ ---------------------------
5
+
6
+ QUICKSTART
7
+
8
+ To get your rails app running on a stock standard Ubuntu 6.06 server:
9
+
10
+ cd /path/to/railsapp
11
+ deprec --apply-to . --name projectname --domain www.projectname.com
12
+ # edit config/deploy.rb to put in details of your subversion repository
13
+ cap install_rails_stack
14
+ cap setup
15
+ cap deploy_with_migrations
16
+ cap restart_apache
17
+
18
+ Read on for installation and usage instructions.
19
+
20
+
21
+ WHAT DEPREC IS
22
+
23
+ Deprec is a collection of automated recipes, written in ruby, for setting
24
+ up production ready rails servers. The idea is, even if it takes longer to
25
+ write a general recipe for your situation, rather than just doing it by hand,
26
+ it's well worth the effort because you get a reliable and reproducible
27
+ deployment that will work just as well even if it's 3am and a human would be
28
+ liable to make mistakes with live webservers.
29
+
30
+ You also get the advantage of a further set of conventions, which means that
31
+ other tools that you write can build on these conventions, in the same way
32
+ that the conventions that we already have amongst rails and capistrano users
33
+ benefit us when writing plugins and gems.
34
+
35
+ Deprec is designed to take a raw server, and set it up with current best
36
+ practices for a production web server. This currently means Apache 2.2 for
37
+ load balancing and static content, and Mongrel for serving rails. Other
38
+ alternatives can be added later, providing a convention over configuration
39
+ approach is followed. Version 1.0 of deprec contains recipes specifically
40
+ for default installations of Ubuntu 6.06 (server), although it also contains
41
+ tasks which will allow it to be used on slightly non-standard ubuntu
42
+ installations, such as those provided by slicehost.com.
43
+
44
+ Deprec has been tested on live VPS hosts with real production sites. It works
45
+ for me, if it doesn't work for you, then it's easy to extend.
46
+
47
+
48
+ WHAT DEPREC ISN'T
49
+
50
+ Deprec isn't an attempt to solve all problems on all servers. I am solving
51
+ my own deployment problems, and providing a general framework to help you
52
+ solve yours. Submissions of recipes for other linux distributions, and maybe
53
+ even other operating systems, will be accepted and included. If this is
54
+ popular, some work may be done to allow your own recipes to be managed as individual gems, dependent on the deprec gem.
55
+
56
+
57
+ CREDITS
58
+
59
+ Deprec is written and maintained by Mike Bailey <mike@bailey.net.au>.
60
+ More about me here: http://codemode.blogspot.com/
61
+
62
+ Deprec was inspired and uses the brilliantly executed Capistrano. Thanks Jamis!
63
+
64
+ After starting on this project I found myself reading and utilizing a lot of
65
+ code by Bradley Taylor, in particular the RailsMachine and VMbuilder gems.
66
+
67
+ Neil Wilson wrote three capistrano plugins that are used in this project.
68
+
69
+ I'd like to say a huge thanks to these guys for helping make my work easier!
70
+
71
+ For the first cut I have included all third party code in a directory within
72
+ the deprec gem, rather than link to the gems themselves. I made this decision
73
+ to prevent deprec from breaking due to a change in one of the other libraries.
74
+
75
+ Thanks to Craig Ambrose for help with testing, documentation and beer.
76
+
77
+
78
+ LICENCE
79
+
80
+ Deprec is licenced under the LGPL. This means that you can use it in commercial
81
+ or open source applications. More details found here:
82
+ http://www.gnu.org/licenses/lgpl.html
83
+
84
+ deprec - deployment recipes for capistrano
85
+ Copyright (C) 2006 Mike Bailey
86
+
87
+ This library is free software; you can redistribute it and/or
88
+ modify it under the terms of the GNU Lesser General Public
89
+ License as published by the Free Software Foundation; either
90
+ version 2.1 of the License, or (at your option) any later version.
91
+
92
+ This library is distributed in the hope that it will be useful,
93
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
94
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95
+ Lesser General Public License for more details.
96
+
97
+ You should have received a copy of the GNU Lesser General Public
98
+ License along with this library; if not, write to the Free Software
99
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
100
+
101
+
102
+ USAGE
103
+
104
+ The following instructions describe how to use deprec. Please note that the
105
+ initial step, installing deprec on your workstation, will patch your copy of
106
+ capistrano to allow capistrano directives to be placed in a local configuration
107
+ file ~/.caprc. This patch has been accepted into capistrano and will be
108
+ available in a later release. The deprec_dotfiles command will not harm future
109
+ versions of capistrano that already contain this functionality.
110
+
111
+ Most of the magic of deprec occurs in the install_rails_stack section. This
112
+ builds the server, which developers previously had to do by hand, or find a
113
+ hosting company that did it for them. Once that is done, deprec also adds
114
+ application specific helper tasks, which are shown below in the "deploy a
115
+ rails app to hosts" section.
116
+
117
+ Please note that the "deprec --apply-to" command is much like the
118
+ "cap --apply-to" command, except that it creates a deploy.rb file in your
119
+ application's config directory with more available settings than capistrano
120
+ uses, because these settings can be used to configure the application specific
121
+ aspects of apache and mongrel.
122
+
123
+ Important Note:
124
+ Running "deprec --apply-to" currently overwrites your existing deploy.rb file.
125
+ If you have deployed the app elsewhere before, you may want to backup this file
126
+ so that you can refer to it when setting up your deprec generated deploy.rb.
127
+ Because deprec sets up the server, it can fill in more sensible defaults than
128
+ capistrano normally does, but there are still a few settings that you need to
129
+ set yourself. Future versions of deprec will not overwrite this file
130
+ automatically, but will move it out of the way first.
131
+
132
+ ## install deprec on workstation
133
+ #
134
+ sudo gem install deprec -y # installs what you need
135
+ deprec_dotfiles # patches capistrano + creates your ~/.caprc
136
+ cap show_tasks # now you have deprec tasks included
137
+
138
+
139
+ ## install rails stack
140
+ #
141
+ # this currently only works with ubuntu 6.06.1 server installed
142
+ # you need to have an account on this machine and sudo access
143
+ #
144
+ export HOSTS=r01,r02,r03 # define some hosts to mess with
145
+ cap setup_ssh_keys # copy out your public keys
146
+ cap install_rails_stack # install apache, rubygems, mongrel, rails, etc.
147
+ unset HOSTS # stop overriding cap's hosts list
148
+
149
+
150
+ ## deploy a rails app to hosts
151
+ #
152
+ # setup dns for your domain or put an entry in /etc/hosts
153
+ cd /path/to/app
154
+ deprec --apply-to . --name bailey --domain bailey.net.au
155
+ cap setup
156
+ # put svn details in config/deploy.rb
157
+ # or run 'cap setup_scm' to import project
158
+ cap deploy_with_migrations
159
+ cap restart_apache
160
+
161
+ # update rails app on hosts
162
+ cap deploy
163
+ cap deploy_with_migrations
164
+
165
+
166
+ ## some handy tools
167
+ #
168
+ cap show_tasks
169
+ cap disable_web, enable_web # puts up maintenance page
170
+ cap restart_mongrel_cluster # does what it says
171
+
172
+ </pre>
@@ -54,7 +54,9 @@ module Deprec
54
54
 
55
55
  # create new user account on target system
56
56
  def useradd(user, options={})
57
+ options[:shell] ||= '/bin/bash' # new accounts on ubuntu 6.06.1 have been getting /bin/sh
57
58
  switches = ''
59
+ switches += " --shell=#{options[:shell]} " if options[:shell]
58
60
  switches += ' --create-home ' unless options[:homedir] == false
59
61
  switches += " --gid #{options[:group]} " unless options[:group].nil?
60
62
  send(run_method, "grep '^#{user}:' /etc/passwd || sudo /usr/sbin/useradd #{switches} #{user}")
@@ -59,8 +59,10 @@ set :apache_server_name, domain
59
59
  set :mongrel_address, apache_proxy_address
60
60
  # set :mongrel_environment, "production"
61
61
  # set :mongrel_config, "/etc/mongrel_cluster/#{application}.conf"
62
- set :mongrel_user, "mongrel_#{application}"
63
- set :mongrel_group, "app_#{application}"
62
+ # set :mongrel_user_prefix, 'mongrel_'
63
+ # set :mongrel_user, mongrel_user_prefix + application
64
+ # set :mongrel_group_prefix, 'app_'
65
+ # set :mongrel_group, mongrel_group_prefix + application
64
66
 
65
67
  # =============================================================================
66
68
  # MYSQL OPTIONS
@@ -13,8 +13,12 @@ Capistrano.configuration(:must_exist).load do
13
13
  set :user, (defined?(user) ? user : ENV['USER']) # user who is deploying
14
14
  set :group, 'deploy' # deployment group
15
15
  set :src_dir, (defined?(src_dir) ? src_dir : '/usr/local/src') # 3rd party src on servers
16
- set :app_symlinks, nil
17
-
16
+ set :app_symlinks, nil
17
+ set :mongrel_user_prefix, 'mongrel_'
18
+ set :mongrel_user, lambda {mongrel_user_prefix + application}
19
+ set :mongrel_group_prefix, 'app_'
20
+ set :mongrel_group, lambda {mongrel_group_prefix + application}
21
+
18
22
  desc <<-DESC
19
23
  setup_rails_host takes a stock standard ubuntu 'dapper' 6.06.1 server
20
24
  and installs everything needed to be a rails machine
@@ -67,7 +71,7 @@ Capistrano.configuration(:must_exist).load do
67
71
 
68
72
  sudo "chgrp -R #{mongrel_group} #{tmp_dir} #{shared_dir}"
69
73
  sudo "chmod 0775 #{tmp_dir} #{shared_dir}"
70
- # set owner and group of mogrels file (if they exist)
74
+ # set owner and group of mongrels file (if they exist)
71
75
  files.each { |file|
72
76
  sudo "chown #{mongrel_user} #{file} || exit 0"
73
77
  sudo "chgrp #{mongrel_group} #{file} || exit 0"
@@ -180,7 +184,19 @@ Capistrano.configuration(:must_exist).load do
180
184
  :dir => version,
181
185
  :url => "http://www.apache.org/dist/httpd/#{version}.tar.gz",
182
186
  :unpack => "tar zxf #{version}.tar.gz;",
183
- :configure => './configure --enable-so --enable-proxy --enable-proxy-balancer --enable-proxy-http --enable-rewrite --enable-cache --enable-headers --enable-ssl --enable-deflate --with-included-apr;',
187
+ :configure => %w{
188
+ ./configure
189
+ --enable-proxy
190
+ --enable-proxy-balancer
191
+ --enable-proxy-http
192
+ --enable-rewrite
193
+ --enable-cache
194
+ --enable-headers
195
+ --enable-ssl
196
+ --enable-deflate
197
+ --with-included-apr
198
+ ;
199
+ }.reject{|arg| arg.match '#'}.join(' '),
184
200
  :make => 'make;',
185
201
  :install => 'make install;',
186
202
  :post_install => 'install -b support/apachectl /etc/init.d/httpd;'
@@ -200,7 +216,29 @@ Capistrano.configuration(:must_exist).load do
200
216
  :dir => version,
201
217
  :url => "http://www.php.net/distributions/#{version}.tar.gz",
202
218
  :unpack => "tar zxf #{version}.tar.gz;",
203
- :configure => "./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --disable-ipv6 --enable-sockets --enable-soap --with-pcre-regex --with-mysql --with-zlib --with-gettext --with-sqlite --enable-sqlite-utf8 --with-openssl --with-mcrypt --with-ncurses --with-jpeg-dir=/usr --with-gd --with-ctype --enable-mbstring --with-curl==/usr/lib;",
219
+ :configure => %w{
220
+ ./configure
221
+ --prefix=/usr/local/php
222
+ --with-apxs2=/usr/local/apache2/bin/apxs
223
+ --disable-ipv6
224
+ --enable-sockets
225
+ --enable-soap
226
+ --with-pcre-regex
227
+ --with-mysql
228
+ --with-zlib
229
+ --with-gettext
230
+ --with-sqlite
231
+ --enable-sqlite-utf8
232
+ --with-openssl
233
+ --with-mcrypt
234
+ --with-ncurses
235
+ --with-jpeg-dir=/usr
236
+ --with-gd
237
+ --with-ctype
238
+ --enable-mbstring
239
+ --with-curl==/usr/lib
240
+ ;
241
+ }.reject{|arg| arg.match '#'}.join(' '),
204
242
  :make => 'make;',
205
243
  :install => 'make install;',
206
244
  :post_install => ""
@@ -212,6 +250,52 @@ Capistrano.configuration(:must_exist).load do
212
250
  deprec.append_to_file_if_missing('/usr/local/apache2/conf/httpd.conf', 'AddType application/x-httpd-php .php')
213
251
  end
214
252
 
253
+
254
+
255
+ # move all memcache stuff to separate file
256
+ set :memcache_ip, '127.0.0.1'
257
+ set :memcache_port, 11211
258
+ set :memcache_memory, 256
259
+
260
+ # XXX needs thought/work
261
+ task :memcached_start do
262
+ run "memcached -d -m #{memcache_memory} -l #{memcache_ip} -p #{memcache_port}"
263
+ end
264
+
265
+ # XXX needs thought/work
266
+ task :memcached_stop do
267
+ run "killall memcached"
268
+ end
269
+
270
+ # XXX needs thought/work
271
+ task :memcached_restart do
272
+ memcached_stop
273
+ memcached_start
274
+ end
275
+
276
+ task :install_memcached do
277
+ version = 'memcached-1.2.2'
278
+ set :src_package, {
279
+ :file => version + '.tar.gz',
280
+ :md5sum => 'a08851f7fa7b15e92ee6320b7a79c321 memcached-1.2.2.tar.gz',
281
+ :dir => version,
282
+ :url => "http://www.danga.com/memcached/dist/#{version}.tar.gz",
283
+ :unpack => "tar zxf #{version}.tar.gz;",
284
+ :configure => %w{
285
+ ./configure
286
+ --prefix=/usr/local
287
+ ;
288
+ }.reject{|arg| arg.match '#'}.join(' '),
289
+ :make => 'make;',
290
+ :install => 'make install;',
291
+ :post_install => 'install -b support/apachectl /etc/init.d/httpd;'
292
+ }
293
+ apt.install( {:base => %w(libevent-dev)}, :stable )
294
+ deprec.download_src(src_package, src_dir)
295
+ deprec.install_from_src(src_package, src_dir)
296
+ end
297
+
298
+
215
299
  desc "Setup public symlink directories"
216
300
  task :setup_symlinks, :roles => [:app, :web] do
217
301
  if app_symlinks
@@ -243,7 +327,7 @@ Capistrano.configuration(:must_exist).load do
243
327
 
244
328
  task :setup_admin_account do
245
329
  user = Capistrano::CLI.password_prompt "Enter userid for new user:"
246
- deprec.useradd(user)
330
+ deprec.useradd(user, :shell => '/bin/bash')
247
331
  puts "Setting pasword for new account"
248
332
  sudo_with_input("passwd #{user}", /UNIX password/) # ??? how many versions of the prompt are there?
249
333
  deprec.groupadd('admin')
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: deprec
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.6.0
7
- date: 2007-05-07 00:00:00 +10:00
6
+ version: 1.7.0
7
+ date: 2007-05-08 00:00:00 +10:00
8
8
  summary: deployment recipes for capistrano
9
9
  require_paths:
10
10
  - lib
@@ -30,8 +30,9 @@ authors: []
30
30
 
31
31
  files:
32
32
  - bin/deprec
33
- - docs/apache_config_options.txt
34
33
  - docs/building_edge_capistrano.txt
34
+ - docs/old_homepage.txt
35
+ - docs/README.slicehost
35
36
  - lib/deprec
36
37
  - lib/deprec/capistrano_extensions
37
38
  - lib/deprec/generators
@@ -1,101 +0,0 @@
1
-
2
-
3
- deprec
4
- --enable-proxy
5
- --enable-proxy-balancer
6
- --enable-proxy-http
7
-
8
- --enable-rewrite
9
- --enable-cache
10
- --enable-headers
11
-
12
- --enable-ssl
13
- --enable-deflate
14
- --with-included-apr
15
-
16
- new
17
- --enable-proxy=shared
18
- --enable-proxy-balancer=shared
19
- --enable-proxy-http=shared
20
- --enable-proxy-html=shared
21
-
22
- --enable-rewrite
23
- --enable-cache
24
- --enable-headers
25
-
26
- --enable-ssl=shared
27
- --enable-deflate
28
- --with-included-apr
29
-
30
- --enable-so
31
- --enable-cgi
32
- --enable-info
33
- --enable-mime-magic
34
- --enable-usertrack
35
- --enable-mem-cache
36
- --enable-modules=all
37
- --enable-mods-shared=all
38
- --with-mpm=worker
39
-
40
-
41
-
42
-
43
-
44
-
45
- Capistrano.configuration(:must_exist).load do
46
-
47
- desc "Install full apache with mod_php and extras"
48
- task :install_full_apache do
49
- version = 'httpd-2.2.4'
50
- set :src_package, {
51
- :file => version + '.tar.gz',
52
- :md5sum => '3add41e0b924d4bb53c2dee55a38c09e httpd-2.2.4.tar.gz',
53
- :dir => version,
54
- :url => "http://www.apache.org/dist/httpd/#{version}.tar.gz",
55
- :unpack => "tar zxf #{version}.tar.gz;",
56
- :configure => './configure --enable-so --enable-cgi --enable-info --enable-mime-magic --enable-usertrack --enable-deflate --enable-proxy=shared --enable-proxy-html=shared --enable-proxy-http=shared --enable-proxy-balancer=shared --enable-rewrite --enable-cache --enable-mem-cache --enable-ssl=shared --enable-headers --enable-modules=all --enable-mods-shared=all --with-included-apr --with-mpm=worker;',
57
- :make => 'make;',
58
- :install => 'make install;',
59
- :post_install => 'install -b support/apachectl /etc/init.d/httpd;'
60
- }
61
- run "export CFLAGS=-O2;"
62
- deprec.download_src(src_package, src_dir)
63
- deprec.install_from_src(src_package, src_dir)
64
- # ubuntu specific - should instead call generic name which can be picked up by different distros
65
- send(run_method, "update-rc.d httpd defaults")
66
- end
67
-
68
- desc "Install PHP from source"
69
- task :install_php_from_source do
70
- version = 'php-5.2.1'
71
- set :src_package, {
72
- :file => version + '.tar.gz',
73
- :dir => version,
74
- :url => "http://ca.php.net/distributions/#{version}.tar.gz",
75
- :unpack => "tar zxf #{version}.tar.gz;",
76
- :configure => "./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --disable-ipv6 --enable-sockets --enable-soap --with-pcre-regex --with-mysql --with-zlib --with-gettext --with-sqlite --enable-sqlite-utf8 --with-openssl --with-mcrypt --with-ncurses --with-jpeg-dir=/usr --with-gd --with-ctype --enable-mbstring --with-curl==/usr/lib;",
77
- :make => 'make;',
78
- :install => 'make install;',
79
- :post_install => ""
80
- }
81
- apt.install( {:base => %w(flex libcurl3 libcurl3-dev libmcrypt-dev libmysqlclient15-dev libncurses5-dev)}, :stable )
82
- run "export CFLAGS=-O2;"
83
- deprec.download_src(src_package, src_dir)
84
- deprec.install_from_src(src_package, src_dir)
85
- end
86
-
87
- desc "Install apache, ruby, php, and server extras"
88
- task :install_full_rails_stack do
89
- setup_user_perms
90
- enable_universe # we'll need some packages from the 'universe' repository
91
- disable_cdrom_install # we don't want to have to insert cdrom
92
- install_packages_for_rails # install packages that come with distribution
93
- install_rubygems
94
- install_gems
95
- install_rmagick
96
- install_postfix
97
- install_full_apache
98
- install_php_from_source # php must be installed after apache, needs 'apxs' in apache2/bin
99
- end
100
-
101
- end