cap-recipes 0.3.25 → 0.3.26
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.textile +57 -0
- data/VERSION.yml +1 -1
- data/cap-recipes.gemspec +4 -1
- data/lib/cap_recipes/tasks/passenger/install.rb +6 -0
- data/lib/cap_recipes/tasks/ruby.rb +1 -0
- data/lib/cap_recipes/tasks/ruby/install.rb +15 -0
- data/lib/cap_recipes/tasks/rubygems/install.rb +23 -0
- data/lib/cap_recipes/tasks/rubygems/manage.rb +2 -4
- data/lib/cap_recipes/tasks/utilities.rb +33 -1
- metadata +4 -1
data/README.textile
CHANGED
@@ -11,6 +11,7 @@ for common issues which can then be used by the community.
|
|
11
11
|
|
12
12
|
Currently included:
|
13
13
|
|
14
|
+
* Ruby Setup
|
14
15
|
* Rubygems Management
|
15
16
|
* Apache Server
|
16
17
|
* Phusion Passenger
|
@@ -77,12 +78,25 @@ h5. manage.rb
|
|
77
78
|
h5. install.rb
|
78
79
|
|
79
80
|
* apache:install - installs apache and dependencies onto a debian system
|
81
|
+
|
82
|
+
h3. Ruby
|
83
|
+
|
84
|
+
h4. Configuration
|
85
|
+
|
86
|
+
* None required
|
80
87
|
|
88
|
+
h4. Tasks
|
89
|
+
|
90
|
+
h5. install.rb
|
91
|
+
|
92
|
+
* ruby:setup - Installs ruby 1.8 using standard aptitude packages
|
93
|
+
|
81
94
|
h3. Rubygems
|
82
95
|
|
83
96
|
h4. Configuration
|
84
97
|
|
85
98
|
* rubygem_paths - a path or array of paths to your gem binaries [default '/usr/bin/gem' ]
|
99
|
+
* rubygems_version - which version of rubygems to install [default '1.3.5']
|
86
100
|
|
87
101
|
h4. Tasks
|
88
102
|
|
@@ -94,6 +108,10 @@ h5. manage.rb
|
|
94
108
|
* rubygems:cleanup - Performs a cleanup for all outdated rubygems
|
95
109
|
* rubygems:install - Installs a specifed gem from name inputted on console
|
96
110
|
* rubygems:uninstall - Removes a specified rubygem from name inputted on console
|
111
|
+
|
112
|
+
h5. install.rb
|
113
|
+
|
114
|
+
* rubygems:install - Installs rubygems by downloading package and running setup.rb
|
97
115
|
|
98
116
|
h3. Passenger
|
99
117
|
|
@@ -348,6 +366,45 @@ set :memcache_init_path, "/etc/init.d/memcache" # defaults to "/etc/init.d/memca
|
|
348
366
|
</code>
|
349
367
|
</pre>
|
350
368
|
|
369
|
+
You can find more examples of what your @deploy.rb@ file should look like in the @examples@ folder.
|
370
|
+
|
371
|
+
h2. UTILITIES
|
372
|
+
|
373
|
+
In addition to the recipes themselves, this gem provides a bunch of useful utility methods
|
374
|
+
which make writing your own recipes or extending existing ones much easier by creating reusable
|
375
|
+
commands for common subtasks in a recipe.
|
376
|
+
|
377
|
+
There are too many to mention all of them directly, but check out @lib/cap_recipes/tasks/utilities.rb@
|
378
|
+
to browse all available utility methods. A few are listed below:
|
379
|
+
|
380
|
+
* utilities.config_gsub(file, findPattern, replaceString)
|
381
|
+
** Replaces the @findPattern@ with @replaceString@ within specified file on server
|
382
|
+
** # utilities.config_gsub('/etc/example', /\#(option:.*?\n)/im, "\\1")
|
383
|
+
|
384
|
+
* utilities.ask(question, default)
|
385
|
+
** Asks the user a question on the command-line and returns the response
|
386
|
+
** utilities.ask('What is your name?', 'John')
|
387
|
+
|
388
|
+
* utilities.yes?(question)
|
389
|
+
** Asks the user a yes or no question on the command-line and returns boolean result
|
390
|
+
** utilities.yes?('Proceed with installation?')
|
391
|
+
|
392
|
+
* utilities.apt_install(packages)
|
393
|
+
** Installs all specified aptitude packages silently without user intervention
|
394
|
+
** utilities.apt_install %w[package1 package2]
|
395
|
+
|
396
|
+
* utilities.sudo_upload(local_path, remote_dest, options)
|
397
|
+
** Uploads a file to a temporary location and then sudo moves it to specified remote destination
|
398
|
+
** utilities.sudo_upload('/local/path/to/file', '/remote/path/to/destination', :mode => 'u+rwx')
|
399
|
+
|
400
|
+
* utilities.with_role(role) { ... }
|
401
|
+
** Forces tasks in block to execute only within specific role(s)
|
402
|
+
** This is useful because of certain limitations in the role declaration in capistrano
|
403
|
+
|
404
|
+
* utilities.with_credentials { ... }
|
405
|
+
** Forces tasks in block to execute using the given user/password credentials
|
406
|
+
** This is useful because of certain limitations in capistrano
|
407
|
+
|
351
408
|
h2. LICENSE:
|
352
409
|
|
353
410
|
(The MIT License)
|
data/VERSION.yml
CHANGED
data/cap-recipes.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cap-recipes}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.26"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Esquenazi"]
|
@@ -52,7 +52,10 @@ Gem::Specification.new do |s|
|
|
52
52
|
"lib/cap_recipes/tasks/rails.rb",
|
53
53
|
"lib/cap_recipes/tasks/rails/hooks.rb",
|
54
54
|
"lib/cap_recipes/tasks/rails/manage.rb",
|
55
|
+
"lib/cap_recipes/tasks/ruby.rb",
|
56
|
+
"lib/cap_recipes/tasks/ruby/install.rb",
|
55
57
|
"lib/cap_recipes/tasks/rubygems.rb",
|
58
|
+
"lib/cap_recipes/tasks/rubygems/install.rb",
|
56
59
|
"lib/cap_recipes/tasks/rubygems/manage.rb",
|
57
60
|
"lib/cap_recipes/tasks/utilities.rb",
|
58
61
|
"lib/cap_recipes/tasks/whenever.rb",
|
@@ -12,6 +12,12 @@ Capistrano::Configuration.instance(true).load do
|
|
12
12
|
enable_apache_module
|
13
13
|
update_config
|
14
14
|
end
|
15
|
+
|
16
|
+
desc "install build-essentials package"
|
17
|
+
task :install_build_essential do
|
18
|
+
utilities.apt_install 'build-essential'
|
19
|
+
end
|
20
|
+
before "passenger:install", "passenger:install_build_essential"
|
15
21
|
|
16
22
|
desc "Setup Passenger Module"
|
17
23
|
task :enable_apache_module, :roles => :web do
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'ruby/*.rb')].sort.each { |lib| require lib }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'cap_recipes/tasks/utilities.rb'
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
4
|
+
|
5
|
+
namespace :ruby do
|
6
|
+
|
7
|
+
desc "install ruby"
|
8
|
+
task :setup, :roles => :app do
|
9
|
+
utilities.apt_install %w[ruby ri rdoc ruby1.8-dev irb1.8 libreadline-ruby1.8
|
10
|
+
libruby1.8 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8]
|
11
|
+
end
|
12
|
+
before "ruby:setup", "aptitude:updates"
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Capistrano::Configuration.instance(true).load do
|
2
|
+
set :rubygems_version, "1.3.5"
|
3
|
+
|
4
|
+
namespace :rubygems do
|
5
|
+
before "rubygems:setup", "ruby:setup"
|
6
|
+
|
7
|
+
desc "install rubygems"
|
8
|
+
task :setup, :roles => :app do
|
9
|
+
run "wget http://rubyforge.org/frs/download.php/60718/rubygems-#{rubygems_version}.tgz"
|
10
|
+
run "tar xvzf rubygems-#{rubygems_version}.tgz"
|
11
|
+
run "cd rubygems-#{rubygems_version}; sudo ruby setup.rb"
|
12
|
+
run "#{sudo} rm /usr/bin/gem; #{sudo} ln -s /usr/bin/gem1.8 /usr/bin/gem"
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "cleanup the files"
|
16
|
+
task :cleanup do
|
17
|
+
run "cd; rm -rf rubygems-#{rubygems_version}; rm -rf rubygems-#{rubygems_version}.*"
|
18
|
+
end
|
19
|
+
before "rubygems:setup", "rubygems:cleanup"
|
20
|
+
after "rubygems:setup", "rubygems:cleanup"
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -26,16 +26,14 @@ Capistrano::Configuration.instance(true).load do
|
|
26
26
|
|
27
27
|
desc "Install a gem on the app servers"
|
28
28
|
task :install, :roles => :app do
|
29
|
-
|
30
|
-
gem_name = $stdin.gets.chomp
|
29
|
+
gem_name = utilities.ask "Enter the name of the gem you'd like to install:"
|
31
30
|
logger.info "trying to install '#{gem_name}'"
|
32
31
|
Array(rubygem_paths).each {|path| sudo "#{path} install #{gem_name} --no-ri --no-rdoc" }
|
33
32
|
end
|
34
33
|
|
35
34
|
desc "Uninstall a gem from app servers"
|
36
35
|
task :uninstall, :roles => :app do
|
37
|
-
|
38
|
-
gem_name = $stdin.gets.chomp
|
36
|
+
gem_name = utilities.ask "Enter the name of the gem you'd like to remove:"
|
39
37
|
logger.info "trying to remove '#{gem_name}'"
|
40
38
|
Array(rubygem_paths).each { |path| sudo "#{path} uninstall #{gem_name} -x" }
|
41
39
|
end
|
@@ -10,7 +10,38 @@ module Utilities
|
|
10
10
|
put content, tmp
|
11
11
|
sudo "mv #{tmp} #{file}"
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
# utilities.ask('What is your name?', 'John')
|
15
|
+
def ask(question, default='')
|
16
|
+
question = "\n" + question.join("\n") if question.respond_to?(:uniq)
|
17
|
+
answer = Capistrano::CLI.ui.ask(space(question)).strip
|
18
|
+
answer.empty? ? default : answer
|
19
|
+
end
|
20
|
+
|
21
|
+
# utilities.yes?('Proceed with install?')
|
22
|
+
def yes?(question)
|
23
|
+
question = "\n" + question.join("\n") if question.respond_to?(:uniq)
|
24
|
+
question += ' (y/n)'
|
25
|
+
ask(question).downcase.include? 'y'
|
26
|
+
end
|
27
|
+
|
28
|
+
def space(str)
|
29
|
+
"\n#{'=' * 80}\n#{str}"
|
30
|
+
end
|
31
|
+
|
32
|
+
# utilities.apt_install %w[package1 package2]
|
33
|
+
def apt_install(packages)
|
34
|
+
packages = Array(packages)
|
35
|
+
apt_get="DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get"
|
36
|
+
sudo "#{apt_get} -qyu --force-yes install #{packages.join(" ")}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def apt_upgrade
|
40
|
+
apt_get="DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get"
|
41
|
+
sudo "#{apt_get} -qyu --force-yes upgrade"
|
42
|
+
end
|
43
|
+
|
44
|
+
# utilities.sudo_upload('/local/path/to/file', '/remote/path/to/destination', options)
|
14
45
|
def sudo_upload(from, to, options={}, &block)
|
15
46
|
top.upload from, "/tmp/#{File.basename(to)}", options, &block
|
16
47
|
sudo "mv /tmp/#{File.basename(to)} #{to}"
|
@@ -18,6 +49,7 @@ module Utilities
|
|
18
49
|
sudo "chown #{options[:owner]} #{to}" if options[:owner]
|
19
50
|
end
|
20
51
|
|
52
|
+
# utilities.adduser('deploy')
|
21
53
|
def adduser(user, options={})
|
22
54
|
options[:shell] ||= '/bin/bash' # new accounts on ubuntu 6.06.1 have been getting /bin/sh
|
23
55
|
switches = '--disabled-password --gecos ""'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cap-recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Esquenazi
|
@@ -58,7 +58,10 @@ files:
|
|
58
58
|
- lib/cap_recipes/tasks/rails.rb
|
59
59
|
- lib/cap_recipes/tasks/rails/hooks.rb
|
60
60
|
- lib/cap_recipes/tasks/rails/manage.rb
|
61
|
+
- lib/cap_recipes/tasks/ruby.rb
|
62
|
+
- lib/cap_recipes/tasks/ruby/install.rb
|
61
63
|
- lib/cap_recipes/tasks/rubygems.rb
|
64
|
+
- lib/cap_recipes/tasks/rubygems/install.rb
|
62
65
|
- lib/cap_recipes/tasks/rubygems/manage.rb
|
63
66
|
- lib/cap_recipes/tasks/utilities.rb
|
64
67
|
- lib/cap_recipes/tasks/whenever.rb
|