dstrelau (owner)

Revisions

gist: 21980 Download_button fork
public
Public Clone URL: git://gist.github.com/21980.git
Embed All Files: show embed
Swizzle-recipes-organization.patch #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
From 1cff7685f5a2013d3e3b13a7407ea64e21aae4de Mon Sep 17 00:00:00 2001
From: dean <dean@26634371-c258-0410-a0b0-f38a24f56ed3>
Date: Fri, 31 Oct 2008 21:50:16 +0000
Subject: [PATCH] Swizzle recipes organization
 
git-svn-id: svn+ssh://development.mintdigital.com/mint/svn/briarpatch/branches/caplets@73 26634371-c258-0410-a0b0-f38a24f56ed3
---
 lib/caplets/plugins/apt.rb | 18 +++++++++++
 lib/caplets/plugins/aptitude.rb | 18 -----------
 lib/recipes/deploy.rb | 23 ++++++++++++++
 lib/recipes/deploy/db.rb | 42 +++++++++++++++++++++++++
 lib/recipes/deploy/gems.rb | 11 +++++++
 lib/recipes/deploy/mongrel.rb | 5 +++
 lib/recipes/deploy/monit.rb | 5 +++
 lib/recipes/deploy/nginx.rb | 32 +++++++++++++++++++
 lib/recipes/memcached.rb | 9 -----
 lib/recipes/mongrel.rb | 4 --
 lib/recipes/monit.rb | 11 -------
 lib/recipes/mysql.rb | 7 ----
 lib/recipes/nginx.rb | 39 -----------------------
 lib/recipes/rails.rb | 34 --------------------
 lib/recipes/rails/db.rb | 50 ------------------------------
 lib/recipes/ruby.rb | 9 -----
 lib/recipes/rubygems.rb | 8 -----
 lib/recipes/slice/install.rb | 64 +++++++++++++++++++++++++++++++++++++++
 lib/recipes/slice/setup.rb | 17 ++++++++++
 lib/recipes/sphinx.rb | 9 -----
 20 files changed, 217 insertions(+), 198 deletions(-)
 create mode 100644 lib/caplets/plugins/apt.rb
 delete mode 100644 lib/caplets/plugins/aptitude.rb
 create mode 100644 lib/recipes/deploy.rb
 create mode 100644 lib/recipes/deploy/db.rb
 create mode 100644 lib/recipes/deploy/gems.rb
 create mode 100644 lib/recipes/deploy/mongrel.rb
 create mode 100644 lib/recipes/deploy/monit.rb
 create mode 100644 lib/recipes/deploy/nginx.rb
 delete mode 100644 lib/recipes/memcached.rb
 delete mode 100644 lib/recipes/mongrel.rb
 delete mode 100644 lib/recipes/monit.rb
 delete mode 100644 lib/recipes/mysql.rb
 delete mode 100644 lib/recipes/nginx.rb
 delete mode 100644 lib/recipes/rails.rb
 delete mode 100644 lib/recipes/rails/db.rb
 delete mode 100644 lib/recipes/ruby.rb
 delete mode 100644 lib/recipes/rubygems.rb
 create mode 100644 lib/recipes/slice/install.rb
 create mode 100644 lib/recipes/slice/setup.rb
 delete mode 100644 lib/recipes/sphinx.rb
 
diff --git a/lib/caplets/plugins/apt.rb b/lib/caplets/plugins/apt.rb
new file mode 100644
index 0000000..0730d5d
--- /dev/null
+++ b/lib/caplets/plugins/apt.rb
@@ -0,0 +1,18 @@
+module Caplets::Plugins::Apt
+
+ # Install a package through apt.
+ #
+ # ==== Arguments
+ # +pkg+:: List of package names, or a single package. Strings or symbols.
+ #
+ # ==== Examples
+ # apt.install 'nginx'
+ # apt.install 'ruby1.8', 'ruby1.8-dev', 'libruby1.8'
+ #
+ def install(*pkgs)
+ sudo "apt-get install -y -q #{pkgs.flatten.join(' ')}"
+ end
+
+end
+
+Capistrano.plugin :apt, Caplets::Plugins::Apt
\ No newline at end of file
diff --git a/lib/caplets/plugins/aptitude.rb b/lib/caplets/plugins/aptitude.rb
deleted file mode 100644
index 2330094..0000000
--- a/lib/caplets/plugins/aptitude.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-module Caplets::Plugins::Aptitude
-
- # Install a package through aptitude.
- #
- # ==== Arguments
- # +pkg+:: List of package names, or a single package. Strings or symbols.
- #
- # ==== Examples
- # aptitude.install 'nginx'
- # aptitude.install 'ruby1.8', 'ruby1.8-dev', 'libruby1.8'
- #
- def install(*pkgs)
- run_via "aptitude install -y -q #{pkgs.flatten.join(' ')}"
- end
-
-end
-
-Capistrano.plugin :aptitude, Caplets::Plugins::Aptitude
\ No newline at end of file
diff --git a/lib/recipes/deploy.rb b/lib/recipes/deploy.rb
new file mode 100644
index 0000000..58d5d86
--- /dev/null
+++ b/lib/recipes/deploy.rb
@@ -0,0 +1,23 @@
+set :user, 'mint'
+set :group, 'mint'
+set :password, 'mintyfr3sh'
+set :use_sudo, false
+set :scm, 'git'
+set :branch, 'master'
+set :deploy_via, 'remote_cache'
+set :deploy_to, "/mint/#{application}"
+
+set :mongrel_pid_file, "#{shared_path}/pids/mongrel.pid"
+set :mongrel_address, '0.0.0.0'
+set :mongrel_conf, "#{shared_path}/mongrel_cluster.yml"
+set :mongrel_port, 8000
+set :mongrel_servers, 2
+
+default_run_options[:pty] = true
+ssh_options[:forward_agent] = true
+
+def rake(cmd)
+ run "cd #{current_path} && RAILS_ENV=production rake #{cmd}"
+end
+
+# bunch of requires here
\ No newline at end of file
diff --git a/lib/recipes/deploy/db.rb b/lib/recipes/deploy/db.rb
new file mode 100644
index 0000000..0cb1bf7
--- /dev/null
+++ b/lib/recipes/deploy/db.rb
@@ -0,0 +1,42 @@
+namespace :deploy do
+ namespace :db do
+ desc "create the production database"
+ task :create, :roles => :app do
+ rake "db:create"
+ end
+
+ desc "load the schema file for initial app setup"
+ task :schema_load, :roles => :app do
+ rake "db:schema:load"
+ end
+
+ desc "run any pending migrations"
+ task :migrate, :roles => :app do
+ rake "db:migrate"
+ end
+
+ desc "write database.yml to the shared directory"
+ task :config, :roles => :app do
+ config = {
+ 'production' => {
+ 'host' => roles[:db].servers.first.to_s,
+ 'adapter' => 'mysql',
+ 'database' => "#{application}_production",
+ 'username' => 'mint',
+ 'password' => ''
+ }
+ }
+ put YAML.dump(config), "#{shared_path}/database.yml"
+ end
+
+ desc "symlink database.yml to the shared copy"
+ task :symlink, :roles => :app do
+ run "ln -nfs #{shared_path}/database.yml #{release_path}/config/database.yml"
+ end
+ end #namespace :db
+end #namespace :deploy
+
+## Hooks ##
+after 'deploy:setup', 'db:config'
+after 'deploy:update_code', 'db:symlink'
+after 'update', 'db:migrate'
diff --git a/lib/recipes/deploy/gems.rb b/lib/recipes/deploy/gems.rb
new file mode 100644
index 0000000..9cb68df
--- /dev/null
+++ b/lib/recipes/deploy/gems.rb
@@ -0,0 +1,11 @@
+namespace :deploy do
+ namespace :gems do
+
+ task :install do
+ # rake gems:install
+ # after deploy:update_code
+ raise NotImplementedError
+ end
+
+ end # namespace :gems
+end # namespace :gems
diff --git a/lib/recipes/deploy/mongrel.rb b/lib/recipes/deploy/mongrel.rb
new file mode 100644
index 0000000..993c789
--- /dev/null
+++ b/lib/recipes/deploy/mongrel.rb
@@ -0,0 +1,5 @@
+namespace :deploy do
+ namespace :mongrel do
+ # Creating/writing config files
+ end # namespace :mongrel
+end # namespace :deploy
\ No newline at end of file
diff --git a/lib/recipes/deploy/monit.rb b/lib/recipes/deploy/monit.rb
new file mode 100644
index 0000000..b4fea0e
--- /dev/null
+++ b/lib/recipes/deploy/monit.rb
@@ -0,0 +1,5 @@
+namespace :deploy do
+ namespace :monit do
+ # Creating/loading config files
+ end # namespace :monit
+end # namespace :deploy
\ No newline at end of file
diff --git a/lib/recipes/deploy/nginx.rb b/lib/recipes/deploy/nginx.rb
new file mode 100644
index 0000000..d484d0b
--- /dev/null
+++ b/lib/recipes/deploy/nginx.rb
@@ -0,0 +1,32 @@
+set :nginx_pid, "/var/run/nginx.pid"
+set :nginx_conf, "/etc/nginx/nginx.conf"
+set :nginx_conf_dir, "/etc/nginx/sites-enabled"
+
+namespace :deploy do
+ namespace :nginx do
+ desc "Generate & push the nginx config file"
+ task :config, :roles => :web do
+ raise NotImplementedError
+ end
+
+ desc "Start up nginx. If it is already running, send it a HUP instead."
+ task :start, :roles => :web do
+ run <<-CMD.gsub(/\n/, "; ")
+ if [ -f #{nginx_pid} ]
+ then #{sudo} kill -HUP $(cat #{nginx_pid})
+ else #{sudo} nginx -t -c #{nginx_conf} && #{sudo} nginx -c #{nginx_conf}
+ fi
+ CMD
+ end
+
+ desc "Stop nginx"
+ task :stop, :roles => :web do
+ sudo "kill -QUIT $(cat #{nginx_pid})"
+ end
+
+ desc "Reload the nginx config by sending a HUP"
+ task :reload, :roles => :web do
+ sudo "#{sudo} nginx -t -c #{nginx_conf} && #{sudo} kill -HUP $(cat #{nginx_pid})"
+ end
+ end # namespace :nginx
+end # namespace :deploy
\ No newline at end of file
diff --git a/lib/recipes/memcached.rb b/lib/recipes/memcached.rb
deleted file mode 100644
index 1beefdf..0000000
--- a/lib/recipes/memcached.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace :memcached do
- desc "Install latest memcached from source"
- task :install do
- # aptitude install libc6, libevent1 first
- # download latest version -- http://www.danga.com/memcached/download.bml
- # config / make / make install
- raise NotImplementedError
- end
-end
\ No newline at end of file
diff --git a/lib/recipes/mongrel.rb b/lib/recipes/mongrel.rb
deleted file mode 100644
index c12fe1e..0000000
--- a/lib/recipes/mongrel.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-namespace :mongrel do
-
- # write config file
-end
\ No newline at end of file
diff --git a/lib/recipes/monit.rb b/lib/recipes/monit.rb
deleted file mode 100644
index 7412f7c..0000000
--- a/lib/recipes/monit.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace :monit do
- desc "Install monit from source"
- task :install do
- # aptitude install libc6, libssl0.9.8 first
- # download latest version -- http://mmonit.com/monit/download/
- # config / make / make install
- raise NotImplementedError
- end
-
- # More for creating/loading config files
-end
\ No newline at end of file
diff --git a/lib/recipes/mysql.rb b/lib/recipes/mysql.rb
deleted file mode 100644
index 817a8af..0000000
--- a/lib/recipes/mysql.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace :mysql do
- desc "Install MySQL 5"
- task :install, :roles => :db do
- # install from source or aptitude?
- raise NotImplementedError
- end
-end
\ No newline at end of file
diff --git a/lib/recipes/nginx.rb b/lib/recipes/nginx.rb
deleted file mode 100644
index 960fa4a..0000000
--- a/lib/recipes/nginx.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-set :nginx_pid, "/var/run/nginx.pid"
-set :nginx_conf, "/etc/nginx/nginx.conf"
-set :nginx_conf_dir, "/etc/nginx/sites-enabled"
-
-namespace :nginx do
- desc "Install Nginx (stable) from source."
- task :install, :roles => :web do
- # aptitude install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev
- # download latest version -- http://sysoev.ru/nginx/download.html
- # include the fair proxy module -- http://wiki.codemongers.com/NginxHttpUpstreamFairModule
- # config / make / make install
- raise NotImplementedError
- end
-
- desc "Generate & push the nginx config file"
- task :config, :roles => :web do
- raise NotImplementedError
- end
-
- desc "Start up nginx. If it is already running, send it a HUP instead."
- task :start, :roles => :web do
- run <<-CMD.gsub(/\n/, "; ")
- if [ -f #{nginx_pid} ]
- then #{sudo} kill -HUP $(cat #{nginx_pid})
- else #{sudo} nginx -t -c #{nginx_conf} && #{sudo} nginx -c #{nginx_conf}
- fi
- CMD
- end
-
- desc "Stop nginx"
- task :stop, :roles => :web do
- sudo "kill -QUIT $(cat #{nginx_pid})"
- end
-
- desc "Reload the nginx config by sending a HUP"
- task :reload, :roles => :web do
- sudo "#{sudo} nginx -t -c #{nginx_conf} && #{sudo} kill -HUP $(cat #{nginx_pid})"
- end
-end # namespace nginx
diff --git a/lib/recipes/rails.rb b/lib/recipes/rails.rb
deleted file mode 100644
index c7dda33..0000000
--- a/lib/recipes/rails.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-set :user, 'mint'
-set :group, 'mint'
-set :password, 'mintyfr3sh'
-set :use_sudo, false
-set :scm, 'git'
-set :branch, 'master'
-set :deploy_via, 'remote_cache'
-set :deploy_to, "/mint/#{application}"
-
-set :mongrel_pid_file, "#{shared_path}/pids/mongrel.pid"
-set :mongrel_address, '0.0.0.0'
-set :mongrel_conf, "#{shared_path}/mongrel_cluster.yml"
-set :mongrel_port, 8000
-set :mongrel_servers, 2
-
-default_run_options[:pty] = true
-ssh_options[:forward_agent] = true
-
-namespace :rails do
- desc 'Install the Rails gem.'
- task :install, :roles => :app do
- raise NotImplementedError
- end
-
- desc 'Install the Rails gem plus additional commonly used gems.'
- task :install_stack, :roles => :app
- # rails, mongrel, ultrasphinx, memcache-client, mislav-will_paginate
- raise NotImplementedError
- end
-end
-
-def rake(cmd)
- run "cd #{current_path} && RAILS_ENV=production rake #{cmd}"
-end
\ No newline at end of file
diff --git a/lib/recipes/rails/db.rb b/lib/recipes/rails/db.rb
deleted file mode 100644
index 068bc92..0000000
--- a/lib/recipes/rails/db.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-namespace :rails do
- namespace :db do
- desc "create the production database"
- task :create, :roles => :app do
- rake "db:create"
- end
-
- desc "load the schema file for initial app setup"
- task :schema_load, :roles => :app do
- rake "db:schema:load"
- end
-
- desc "run any pending migrations"
- task :migrate, :roles => :app do
- rake "db:migrate"
- end
-
- desc "write database.yml to the shared directory"
- task :config, :roles => :app do
- config = {
- 'production' => {
- 'host' => roles[:db].servers.first.to_s,
- 'adapter' => 'mysql',
- 'database' => "#{application}_production",
- 'username' => 'mint',
- 'password' => ''
- }
- }
- put YAML.dump(config), "#{shared_path}/database.yml"
- end
-
- desc "symlink database.yml to the shared copy"
- task :symlink, :roles => :app do
- run "ln -nfs #{shared_path}/database.yml #{release_path}/config/database.yml"
- end
- end #namespace :db
-
- namespace :gems do
- task :install do
- # rake gems:install
- # after deploy:update_code
- raise NotImplementedError
- end
- end
-end #namespace :rails
-
-## Hooks ##
-after 'deploy:setup', 'db:config'
-after 'deploy:update_code', 'db:symlink'
-after 'update', 'db:migrate'
diff --git a/lib/recipes/ruby.rb b/lib/recipes/ruby.rb
deleted file mode 100644
index a0cd979..0000000
--- a/lib/recipes/ruby.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace :ruby do
- desc "Install Ruby 1.8 through aptitude."
- task :install, :roles => :app do
- # for all the packages we need, see the Ruby section of
- # http://articles.slicehost.com/2008/4/30/ubuntu-hardy-ruby-on-rails
- raise NotImplementedError
- end
-end
-
diff --git a/lib/recipes/rubygems.rb b/lib/recipes/rubygems.rb
deleted file mode 100644
index f877047..0000000
--- a/lib/recipes/rubygems.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace :rubygems do
- desc "Install latest rubygems from aptitude then self-update"
- task :install, :roles => :app do
- # aptitude install rubygems
- # gem update --system
- raise NotImplementedError
- end
-end
\ No newline at end of file
diff --git a/lib/recipes/slice/install.rb b/lib/recipes/slice/install.rb
new file mode 100644
index 0000000..b01ddf6
--- /dev/null
+++ b/lib/recipes/slice/install.rb
@@ -0,0 +1,64 @@
+desc "Install monit from source."
+task :monit do
+ # apt install: libc6, libssl0.9.8 first
+ # download latest version -- http://mmonit.com/monit/download/
+ # config / make / make install
+ raise NotImplementedError
+end
+
+desc "Install memcached from source."
+task :memcache do
+ # apt install: libc6, libevent1 first
+ # download latest version -- http://www.danga.com/memcached/download.bml
+ # config / make / make install
+ raise NotImplementedError
+end
+
+desc "Install Nginx (stable) from source."
+task :nginx, :roles => :web do
+ # aptitude install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev
+ # download latest version -- http://sysoev.ru/nginx/download.html
+ # include the fair proxy module -- http://wiki.codemongers.com/NginxHttpUpstreamFairModule
+ # config / make / make install
+ raise NotImplementedError
+end
+
+
+desc "Install Sphinx from source."
+task :sphinx do
+ # depends on mysql5
+ # download latest version -- http://sphinxsearch.com/downloads.html
+ # config / make / make install
+ raise NotImplementedError
+end
+
+desc "Install Ruby 1.8 through apt."
+task :ruby, :roles => :app do
+ # apt install: ruby1.8 ruby1.8-dev libreadline-ruby1.8 irb1.8 ri1.8 rdoc1.8
+ # sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
+ # sudo ln -s /usr/bin/irb1.8 /usr/bin/irb
+ # sudo ln -s /usr/bin/ri1.8 /usr/bin/ri
+ # sudo ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc
+
+ raise NotImplementedError
+end
+
+desc "Install latest rubygems from source. Include rails & mongrel"
+task :rubygems, :roles => :app do
+ # curl -LO http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
+ # tar xzf rubygems-1.3.1.tgz
+ # cd rubygems-1.3.1
+ # sudo ruby setup.rb
+ # cd ..
+ # rm -r rubygems*
+ # gem sources -a http://gems.github.com
+ # echo "gem: --no-ri --no-rdoc" >> .gemrc
+ # sudo gem install rails mongrel mongrel_cluster
+ raise NotImplementedError
+end
+
+desc "Install MySQL 5 through apt."
+task :mysql, :roles => :db do
+ # apt install: mysql-server
+ raise NotImplementedError
+end
diff --git a/lib/recipes/slice/setup.rb b/lib/recipes/slice/setup.rb
new file mode 100644
index 0000000..2ac797c
--- /dev/null
+++ b/lib/recipes/slice/setup.rb
@@ -0,0 +1,17 @@
+namespace :slice do
+ namespace :setup do
+
+ desc 'Fully configure an application slice'
+ task :app do
+ end
+
+ desc 'Fully configure a database slice'
+ task :db do
+ end
+
+ desc 'Fully configure a web slice'
+ task :web do
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/lib/recipes/sphinx.rb b/lib/recipes/sphinx.rb
deleted file mode 100644
index 6d04069..0000000
--- a/lib/recipes/sphinx.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace :sphinx do
- desc "Install Sphinx from source"
- task :install do
- # depends on mysql5
- # download latest version -- http://sphinxsearch.com/downloads.html
- # config / make / make install
- raise NotImplementedError
- end
-end
\ No newline at end of file
--
1.6.0+GitX