capitate 0.1.7
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/Capfile +24 -0
- data/History.txt +22 -0
- data/License.txt +20 -0
- data/Manifest.txt +100 -0
- data/README.txt +1 -0
- data/Rakefile +4 -0
- data/bin/capitate +46 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/lib/capitate/cap_ext/connections.rb +95 -0
- data/lib/capitate/cap_ext/extension_proxy.rb +15 -0
- data/lib/capitate/cap_ext/variables.rb +59 -0
- data/lib/capitate/config.rb +106 -0
- data/lib/capitate/plugins/base.rb +85 -0
- data/lib/capitate/plugins/gem.rb +25 -0
- data/lib/capitate/plugins/package.rb +30 -0
- data/lib/capitate/plugins/profiles.rb +33 -0
- data/lib/capitate/plugins/script.rb +118 -0
- data/lib/capitate/plugins/templates.rb +98 -0
- data/lib/capitate/plugins/wget.rb +23 -0
- data/lib/capitate/plugins/yum.rb +87 -0
- data/lib/capitate/recipes.rb +9 -0
- data/lib/capitate/version.rb +9 -0
- data/lib/capitate.rb +32 -0
- data/lib/doc/centos/memcached.yml +18 -0
- data/lib/doc/centos/mongrel_cluster.yml +11 -0
- data/lib/doc/centos/monit.yml +12 -0
- data/lib/doc/centos/mysql.yml +6 -0
- data/lib/doc/centos/nginx.yml +25 -0
- data/lib/doc/centos/sphinx.yml +14 -0
- data/lib/doc/gems.yml +7 -0
- data/lib/doc/install.yml +11 -0
- data/lib/doc/memcached.yml +13 -0
- data/lib/doc/mongrel_cluster.yml +12 -0
- data/lib/doc/mysql.yml +46 -0
- data/lib/doc/nginx.yml +23 -0
- data/lib/doc/packages.yml +17 -0
- data/lib/doc/rails.yml +15 -0
- data/lib/profiles/centos-sick.rb +114 -0
- data/lib/recipes/README +5 -0
- data/lib/recipes/centos/README +3 -0
- data/lib/recipes/centos/centos.rb +44 -0
- data/lib/recipes/centos/imagemagick.rb +19 -0
- data/lib/recipes/centos/memcached.rb +31 -0
- data/lib/recipes/centos/mongrel_cluster.rb +34 -0
- data/lib/recipes/centos/monit.rb +42 -0
- data/lib/recipes/centos/mysql.rb +25 -0
- data/lib/recipes/centos/nginx.rb +45 -0
- data/lib/recipes/centos/ruby.rb +37 -0
- data/lib/recipes/centos/sphinx.rb +49 -0
- data/lib/recipes/deploy.rb +18 -0
- data/lib/recipes/gems.rb +11 -0
- data/lib/recipes/install.rb +18 -0
- data/lib/recipes/memcached.rb +14 -0
- data/lib/recipes/mongrel_cluster.rb +33 -0
- data/lib/recipes/mysql.rb +33 -0
- data/lib/recipes/nginx.rb +40 -0
- data/lib/recipes/packages.rb +24 -0
- data/lib/recipes/rails.rb +20 -0
- data/lib/recipes/sphinx.rb +38 -0
- data/lib/templates/capistrano/Capfile +26 -0
- data/lib/templates/centos/setup_for_web.sh +17 -0
- data/lib/templates/centos/sudoers +95 -0
- data/lib/templates/memcached/memcached.initd.centos.erb +70 -0
- data/lib/templates/memcached/memcached.monitrc.erb +4 -0
- data/lib/templates/mongrel/mongrel_cluster.initd.erb +61 -0
- data/lib/templates/mongrel/mongrel_cluster.monitrc.erb +15 -0
- data/lib/templates/mongrel/mongrel_cluster.yml.erb +10 -0
- data/lib/templates/monit/cert.sh +14 -0
- data/lib/templates/monit/monit.cnf +34 -0
- data/lib/templates/monit/monit.initd.centos.erb +68 -0
- data/lib/templates/monit/monitrc.erb +28 -0
- data/lib/templates/monit/patch_inittab.sh +15 -0
- data/lib/templates/mysql/install_db.sql.erb +7 -0
- data/lib/templates/mysql/mysql.monitrc.erb +6 -0
- data/lib/templates/nginx/nginx.conf.erb +88 -0
- data/lib/templates/nginx/nginx.initd.erb +62 -0
- data/lib/templates/nginx/nginx.monitrc.erb +4 -0
- data/lib/templates/nginx/nginx_vhost.conf.erb +95 -0
- data/lib/templates/rails/database.yml.erb +42 -0
- data/lib/templates/ruby/fix_openssl.sh +12 -0
- data/lib/templates/sphinx/sphinx.conf.erb +498 -0
- data/lib/templates/sphinx/sphinx.monitrc.erb +4 -0
- data/lib/templates/sphinx/sphinx_app.initd.centos.erb +67 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/capitate.rake +10 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_recipes.rb +11 -0
- data/test/test_templates.rb +29 -0
- data/website/index.html +161 -0
- data/website/index.txt +86 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +160 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Capitate::Plugins::Gem
|
|
2
|
+
|
|
3
|
+
# Install a gem.
|
|
4
|
+
#
|
|
5
|
+
# ==== Options
|
|
6
|
+
# +gems+:: List of gem names, or a single gem
|
|
7
|
+
#
|
|
8
|
+
# ==== Examples (in capistrano task)
|
|
9
|
+
# gemc.install("raspell")
|
|
10
|
+
# gemc.install([ "raspell", "foo" ])
|
|
11
|
+
#
|
|
12
|
+
def install(gems)
|
|
13
|
+
# If a single object, wrap in array
|
|
14
|
+
gems = [ gems ] unless gems.is_a?(Array)
|
|
15
|
+
|
|
16
|
+
# Install one at a time because we may need to pass install args (e.g. mysql)
|
|
17
|
+
# TODO: Fix this
|
|
18
|
+
gems.each do |gem|
|
|
19
|
+
sudo "gem install --no-rdoc --no-ri --no-verbose #{gem}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Capistrano.plugin :gemc, Capitate::Plugins::Gem
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Package plugin.
|
|
2
|
+
#
|
|
3
|
+
# TODO: If type not set silently fails. NOT GOOD :(
|
|
4
|
+
#
|
|
5
|
+
module Capitate::Plugins::Package
|
|
6
|
+
|
|
7
|
+
# Setup packager.
|
|
8
|
+
#
|
|
9
|
+
# ==== Options
|
|
10
|
+
# +packager_type+:: Packager type (:yum)
|
|
11
|
+
#
|
|
12
|
+
# ==== Examples (in capistrano task)
|
|
13
|
+
# package.type = :yum
|
|
14
|
+
# package.install [ "aspell", "foo" ]
|
|
15
|
+
# package.remove [ "aspell", "foo" ]
|
|
16
|
+
# package.update [ "aspell", "foo" ]
|
|
17
|
+
# package.clean
|
|
18
|
+
#
|
|
19
|
+
def type=(packager_type)
|
|
20
|
+
case packager_type.to_sym
|
|
21
|
+
when :yum
|
|
22
|
+
include Capitate::Plugins::Yum
|
|
23
|
+
else
|
|
24
|
+
raise "Invalid packager type: #{packager_type}"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Capistrano.plugin :package, Capitate::Plugins::Package
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# == Profiles
|
|
2
|
+
# Useful for starting a profile, but your mileage may vary.
|
|
3
|
+
#
|
|
4
|
+
module Capitate::Plugins::Profiles
|
|
5
|
+
|
|
6
|
+
ProfileDir = File.dirname(__FILE__) + "/../../profiles"
|
|
7
|
+
|
|
8
|
+
# Load all profiles with prefix.
|
|
9
|
+
#
|
|
10
|
+
# ==== Options
|
|
11
|
+
# +prefix+:: Prefix to filter/search on
|
|
12
|
+
#
|
|
13
|
+
def list(prefix = "")
|
|
14
|
+
Dir[ProfileDir + "/#{prefix}*.rb"].collect { |file| File.basename(file).gsub(File.extname(file), "") }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Choose a profile (via command line).
|
|
18
|
+
#
|
|
19
|
+
# ==== Options
|
|
20
|
+
# +prefix+:: Prefix to filter/search on
|
|
21
|
+
#
|
|
22
|
+
def choose(prefix = "")
|
|
23
|
+
profile = HighLine.new.choose(*list(prefix)) do |menu|
|
|
24
|
+
menu.header = "Choose recipe profile"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
"#{ProfileDir}/#{profile}.rb"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Capistrano.plugin :profile, Capitate::Plugins::Profiles
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
module Capitate::Plugins::Script
|
|
2
|
+
|
|
3
|
+
# Configure, make, make install.
|
|
4
|
+
#
|
|
5
|
+
# ==== Options
|
|
6
|
+
# +name+:: Name for app
|
|
7
|
+
# +options+:: Options
|
|
8
|
+
# - +build_dest+:: Place to build from, ex. /usr/src, defaults to /tmp/name
|
|
9
|
+
# - +url+:: URL to download package from
|
|
10
|
+
# - +configure_options+:: Options for ./configure
|
|
11
|
+
# - +unpack_dir+:: Directory that is unpacked from tgz (if not matching the file name)
|
|
12
|
+
#
|
|
13
|
+
# ==== Examples (in capistrano task)
|
|
14
|
+
# script.make_install("nginx", { :url => "http://sysoev.ru/nginx/nginx-0.5.35.tar.gz", ... })
|
|
15
|
+
#
|
|
16
|
+
def make_install(name, options)
|
|
17
|
+
install(name, options) do |dir|
|
|
18
|
+
configure_options = options[:configure_options] || ""
|
|
19
|
+
sudo "echo 'Configuring #{name}...' && cd #{dir} && ./configure #{configure_options} > configure.log"
|
|
20
|
+
sudo "echo 'Compiling #{name}...' && cd #{dir} && make > make.log"
|
|
21
|
+
sudo "echo 'Installing #{name}...' && cd #{dir} && make install > make_install.log"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Download, unpack and yield (unpacked source director).
|
|
26
|
+
#
|
|
27
|
+
# ==== Options
|
|
28
|
+
# +name+:: Name for app
|
|
29
|
+
# +options+:: Options
|
|
30
|
+
# - +build_dest+:: Place to build from, ex. /usr/src, defaults to /tmp/name
|
|
31
|
+
# - +url+:: URL to download package from
|
|
32
|
+
#
|
|
33
|
+
# ==== Examples (in capistrano task)
|
|
34
|
+
# script.make("rubygems", { :url => :url => "http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz" }) do |dir|
|
|
35
|
+
# sudo "echo 'Running setup...' && cd #{dir} && ruby #{dir}/setup.rb"
|
|
36
|
+
# end
|
|
37
|
+
#
|
|
38
|
+
def install(name, options, &block)
|
|
39
|
+
build_dest = options[:build_dest]
|
|
40
|
+
build_dest ||= "/tmp/#{name}"
|
|
41
|
+
url = options[:url]
|
|
42
|
+
dependencies = options[:dependencies]
|
|
43
|
+
|
|
44
|
+
package.install(dependencies) if dependencies
|
|
45
|
+
|
|
46
|
+
unpack(url, build_dest, options[:clean], options[:unpack_dir]) do |dir|
|
|
47
|
+
yield(dir) if block_given?
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# Run (sh) script. If script has .erb extension it will evaluate it.
|
|
53
|
+
#
|
|
54
|
+
# ==== Options
|
|
55
|
+
# +script+:: Name of sh file (relative to templates dir)
|
|
56
|
+
# +override_binding++:: Binding to override, otherwise defaults to current (task) context
|
|
57
|
+
#
|
|
58
|
+
# ==== Examples
|
|
59
|
+
# script.sh("ruby/openssl_fix.sh")
|
|
60
|
+
#
|
|
61
|
+
def sh(script, override_binding = nil)
|
|
62
|
+
|
|
63
|
+
if File.extname(script) == ".erb"
|
|
64
|
+
name = script[0...script.length-4]
|
|
65
|
+
dest = "/tmp/#{name}"
|
|
66
|
+
run "mkdir -p #{File.dirname(dest)}"
|
|
67
|
+
put template.load(script, override_binding || binding), dest
|
|
68
|
+
else
|
|
69
|
+
name = script
|
|
70
|
+
dest = "/tmp/#{name}"
|
|
71
|
+
run "mkdir -p #{File.dirname(dest)}"
|
|
72
|
+
put template.load(script), dest
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# If want verbose, -v
|
|
76
|
+
sudo "sh -v #{dest}"
|
|
77
|
+
|
|
78
|
+
# Cleanup
|
|
79
|
+
sudo "rm -rf #{File.dirname(dest)}"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Download and unpack URL.
|
|
83
|
+
# Yields path to unpacked source.
|
|
84
|
+
#
|
|
85
|
+
# ==== Options
|
|
86
|
+
# +url+:: URL to download
|
|
87
|
+
# +dest+:: Destination directory
|
|
88
|
+
# +clean+:: If true will remove the unpacked directory
|
|
89
|
+
# +unpack_dir+:: Directory that is unpacked from tgz (if not matching the file name)
|
|
90
|
+
#
|
|
91
|
+
# ==== Examples
|
|
92
|
+
# script.unpack("http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz", "/tmp/rubygems") do
|
|
93
|
+
# sudo "ruby setup.rb"
|
|
94
|
+
# end
|
|
95
|
+
#
|
|
96
|
+
def unpack(url, dest, clean = true, unpack_dir = nil, &block)
|
|
97
|
+
file = url.split("/").last
|
|
98
|
+
|
|
99
|
+
# TODO: Support other types
|
|
100
|
+
if file !~ /\.tar\.gz\Z|\.tgz\Z/
|
|
101
|
+
raise "Can't unpack this file: #{file}; only support tar.gz and tgz formats"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
unpack_dir ||= file.gsub(/\.tar\.gz|\.tgz/, "")
|
|
105
|
+
|
|
106
|
+
sudo "echo 'Getting #{url}...' && mkdir -p #{dest} && cd #{dest} && wget -nv #{url}"
|
|
107
|
+
sudo "echo 'Unpacking...' && cd #{dest} && tar zxf #{file}"
|
|
108
|
+
|
|
109
|
+
if block_given?
|
|
110
|
+
yield("#{dest}/#{unpack_dir}")
|
|
111
|
+
sudo "rm -f #{dest}/#{file}"
|
|
112
|
+
sudo "rm -rf #{dest}" if clean
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
Capistrano.plugin :script, Capitate::Plugins::Script
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
module Capitate::Plugins::Templates
|
|
2
|
+
|
|
3
|
+
# Get the absolute base templates path.
|
|
4
|
+
def gem_templates_root
|
|
5
|
+
File.expand_path(File.dirname(__FILE__) + "/../../templates")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Get full template path from relative path.
|
|
9
|
+
#
|
|
10
|
+
# Something like <tt>monit/monit.cnf => /usr/lib/..../capitate/lib/templates/monit/monit.cnf</tt>.
|
|
11
|
+
#
|
|
12
|
+
# ==== Options
|
|
13
|
+
# +template_path+:: Relative path
|
|
14
|
+
#
|
|
15
|
+
def gem_template_path(template_path)
|
|
16
|
+
File.join(gem_templates_root, template_path)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Load template. If extension is erb will be evaluated with binding.
|
|
20
|
+
#
|
|
21
|
+
# ==== Options
|
|
22
|
+
# +path+:: If starts with '/', absolute path, otherwise relative path to templates dir
|
|
23
|
+
# +override_binding+:: Binding to override, otherwise uses current (task) binding
|
|
24
|
+
#
|
|
25
|
+
# ==== Examples
|
|
26
|
+
# template.load("memcached/memcached.monitrc.erb")
|
|
27
|
+
# put template.load("memcached/memcached.monitrc.erb"), "/tmp/memcached.monitrc"
|
|
28
|
+
#
|
|
29
|
+
def load(path, override_binding = nil)
|
|
30
|
+
template_paths = [ path, gem_template_path(path) ]
|
|
31
|
+
|
|
32
|
+
template_paths = template_paths.select { |file| File.exist?(file) }
|
|
33
|
+
|
|
34
|
+
if template_paths.empty?
|
|
35
|
+
raise <<-EOS
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Template not found: #{path}
|
|
39
|
+
|
|
40
|
+
EOS
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Use first
|
|
44
|
+
template_path = template_paths.first
|
|
45
|
+
|
|
46
|
+
template_data = IO.read(template_path)
|
|
47
|
+
|
|
48
|
+
if File.extname(template_path) == ".erb"
|
|
49
|
+
template = ERB.new(template_data)
|
|
50
|
+
template_data = template.result(override_binding || binding)
|
|
51
|
+
end
|
|
52
|
+
template_data
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Load template from project.
|
|
56
|
+
# If extension is erb will be evaluated with binding.
|
|
57
|
+
#
|
|
58
|
+
# ==== Options
|
|
59
|
+
# +path+:: If starts with '/', absolute path, otherwise relative path to templates dir
|
|
60
|
+
# +override_binding+:: Binding to override, otherwise uses current (task) binding
|
|
61
|
+
#
|
|
62
|
+
# ==== Examples
|
|
63
|
+
# template.project("config/templates/sphinx.conf.erb")
|
|
64
|
+
# put template.project("config/templates/sphinx.conf.erb"), "#{shared_path}/config/sphinx.conf"
|
|
65
|
+
#
|
|
66
|
+
def project(path, override_binding = nil)
|
|
67
|
+
load(project_root + "/" + path, override_binding || binding)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Write template at (relative path) with binding to LOCAL destination path.
|
|
71
|
+
#
|
|
72
|
+
# ==== Options
|
|
73
|
+
# +template_path+:: Path to template relative to templates path
|
|
74
|
+
# +dest_path+:: Local destination path to write to
|
|
75
|
+
# +overwrite_binding+:: Binding
|
|
76
|
+
# +overwrite+:: Force overwrite
|
|
77
|
+
# +verbose+:: Verbose output
|
|
78
|
+
#
|
|
79
|
+
# ==== Examples
|
|
80
|
+
# template.write("config/templates/sphinx.conf.erb", binding, "config/sphinx.conf")
|
|
81
|
+
#
|
|
82
|
+
def write(template_path, dest_path, override_binding = nil, overwrite = false, verbose = true)
|
|
83
|
+
# This is gnarly!
|
|
84
|
+
relative_dest_path = Pathname.new(File.expand_path(dest_path)).relative_path_from(Pathname.new(File.expand_path(".")))
|
|
85
|
+
|
|
86
|
+
if !overwrite && File.exist?(dest_path)
|
|
87
|
+
puts "%10s %-40s (skipped)" % [ "create", relative_dest_path ] if verbose
|
|
88
|
+
return
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
puts "%10s %-40s" % [ "create", relative_dest_path ] if verbose
|
|
92
|
+
template_data = load(template_path, override_binding)
|
|
93
|
+
File.open(dest_path, "w") { |file| file.puts(load(template_path, override_binding)) }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
Capistrano.plugin :template, Capitate::Plugins::Templates
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
|
|
3
|
+
module Capitate::Plugins::Wget
|
|
4
|
+
|
|
5
|
+
# Download the uri, then upload it into the remote destination directory
|
|
6
|
+
#
|
|
7
|
+
# ==== Options
|
|
8
|
+
# +uri+:: URI to get
|
|
9
|
+
# +remote_dest_dir+:: Remote destination directory, defaults to /tmp
|
|
10
|
+
#
|
|
11
|
+
def uri(uri, remote_dest_dir = "/tmp")
|
|
12
|
+
|
|
13
|
+
uri = uri = URI.parse(uri)
|
|
14
|
+
name = uri.path.split("/").last
|
|
15
|
+
remote_dest_path = File.join(remote_dest_dir, name)
|
|
16
|
+
|
|
17
|
+
logger.info "Downloading #{name} from #{uri}..."
|
|
18
|
+
put open(uri).read, remote_dest_path
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Capistrano.plugin :wget, Capitate::Plugins::Wget
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Packages must respond to update, remove, install and clean
|
|
2
|
+
module Capitate::Plugins::Yum
|
|
3
|
+
|
|
4
|
+
# Update all installed packages.
|
|
5
|
+
#
|
|
6
|
+
# ==== Options
|
|
7
|
+
# +packages+:: Packages to update, or empty to update all
|
|
8
|
+
#
|
|
9
|
+
# ==== Examples
|
|
10
|
+
# yum.update
|
|
11
|
+
# yum.update([ "aspell" ])
|
|
12
|
+
#
|
|
13
|
+
# Also can use package plugin with package.type = :yum, and then:
|
|
14
|
+
# package.update
|
|
15
|
+
# package.update([ "aspell" ])
|
|
16
|
+
#
|
|
17
|
+
def update(packages = [])
|
|
18
|
+
sudo "yum -y update #{packages.join(" ")}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Remove via yum.
|
|
22
|
+
#
|
|
23
|
+
# ==== Options
|
|
24
|
+
# +packages+:: Packages to remove
|
|
25
|
+
#
|
|
26
|
+
# ==== Examples
|
|
27
|
+
# yum.remove
|
|
28
|
+
# yum.remove([ "aspell" ])
|
|
29
|
+
#
|
|
30
|
+
# Also can use package plugin with package.type = :yum, and then:
|
|
31
|
+
# package.remove
|
|
32
|
+
# package.remove([ "aspell" ])
|
|
33
|
+
#
|
|
34
|
+
def remove(packages)
|
|
35
|
+
sudo "yum -y remove #{packages.join(" ")}"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Install via yum.
|
|
39
|
+
#
|
|
40
|
+
# ==== Options
|
|
41
|
+
# +packages+:: Packages to install, either String (for single package) or Array
|
|
42
|
+
# +update_existing+:: If package exists, where to yum update it, defaults to true
|
|
43
|
+
#
|
|
44
|
+
# ==== Examples
|
|
45
|
+
# yum.install
|
|
46
|
+
# yum.install([ "aspell" ])
|
|
47
|
+
#
|
|
48
|
+
# Also can use package plugin with package.type = :yum, and then:
|
|
49
|
+
# package.install
|
|
50
|
+
# package.install([ "aspell" ])
|
|
51
|
+
#
|
|
52
|
+
def install(packages, update_existing = true)
|
|
53
|
+
|
|
54
|
+
# If a single object, wrap in array
|
|
55
|
+
packages = [ packages ] unless packages.is_a?(Array)
|
|
56
|
+
|
|
57
|
+
if update_existing
|
|
58
|
+
|
|
59
|
+
installed_packages = []
|
|
60
|
+
|
|
61
|
+
sudo "yum -d 0 list installed #{packages.join(" ")}" do |channel, stream, data|
|
|
62
|
+
installed_packages += data.split("\n")[1..-1].collect { |line| line.split(".").first }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
packages -= installed_packages
|
|
66
|
+
|
|
67
|
+
sudo "yum -y update #{installed_packages.join(" ")}" unless installed_packages.blank?
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
sudo "yum -y install #{packages.join(" ")}" unless packages.blank?
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Clean yum.
|
|
74
|
+
#
|
|
75
|
+
# ==== Examples
|
|
76
|
+
# yum.clean
|
|
77
|
+
#
|
|
78
|
+
# Also can use package plugin with package.type = :yum, and then:
|
|
79
|
+
# package.clean
|
|
80
|
+
#
|
|
81
|
+
def clean
|
|
82
|
+
sudo "yum -y clean all"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
Capistrano.plugin :yum, Capitate::Plugins::Yum
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Load recipes
|
|
2
|
+
# This is only loadable from within Capistrano
|
|
3
|
+
recipes = Dir[File.dirname(__FILE__) + "/../recipes/**/*.rb"].collect { |recipe| File.expand_path(recipe) }
|
|
4
|
+
recipes.each do |recipe|
|
|
5
|
+
Capistrano::Configuration.instance.load recipe
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Reset the password var
|
|
9
|
+
Capistrano::Configuration.instance.load(:string => "reset_password")
|
data/lib/capitate.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'active_support'
|
|
3
|
+
require 'highline'
|
|
4
|
+
require 'capistrano'
|
|
5
|
+
|
|
6
|
+
HighLine.track_eof = false
|
|
7
|
+
|
|
8
|
+
# Add this path to ruby load path
|
|
9
|
+
$:.unshift File.dirname(__FILE__)
|
|
10
|
+
|
|
11
|
+
module Capitate # :nodoc:
|
|
12
|
+
module Plugins # :nodoc:
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
require 'capitate/plugins/base'
|
|
17
|
+
require 'capitate/plugins/gem'
|
|
18
|
+
require 'capitate/plugins/package'
|
|
19
|
+
require 'capitate/plugins/profiles'
|
|
20
|
+
require 'capitate/plugins/script'
|
|
21
|
+
require 'capitate/plugins/templates'
|
|
22
|
+
require 'capitate/plugins/wget'
|
|
23
|
+
require 'capitate/plugins/yum'
|
|
24
|
+
|
|
25
|
+
require "capitate/cap_ext/connections"
|
|
26
|
+
require "capitate/cap_ext/extension_proxy"
|
|
27
|
+
require "capitate/cap_ext/variables"
|
|
28
|
+
|
|
29
|
+
class Capistrano::Configuration
|
|
30
|
+
include Capitate::CapExt::Variables
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
install:
|
|
2
|
+
memcached_memory: |
|
|
3
|
+
Memcached memory (in MB).
|
|
4
|
+
|
|
5
|
+
set :memcached_memory, 64
|
|
6
|
+
|
|
7
|
+
memcached_pid_path: |
|
|
8
|
+
Path to memcached pid file.
|
|
9
|
+
Defaults to /var/run/memcached.pid
|
|
10
|
+
|
|
11
|
+
set :memcached_pid_path, "/var/run/memcached.pid"
|
|
12
|
+
|
|
13
|
+
memcached_port: |
|
|
14
|
+
Memcached port.
|
|
15
|
+
Defaults to 11211.
|
|
16
|
+
|
|
17
|
+
set :memcached_port, 11211
|
|
18
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
install:
|
|
2
|
+
nginx_bin_path: |
|
|
3
|
+
Nginx sbin path.
|
|
4
|
+
Defaults to /sbin/nginx
|
|
5
|
+
|
|
6
|
+
set :nginx_bin_path, "/sbin/nginx"
|
|
7
|
+
|
|
8
|
+
nginx_conf_path: |
|
|
9
|
+
Path to nginx conf.
|
|
10
|
+
Defaults to /etc/nginx/nginx.conf
|
|
11
|
+
|
|
12
|
+
set :nginx_conf_path, "/etc/nginx/nginx.conf"
|
|
13
|
+
|
|
14
|
+
nginx_pid_path: |
|
|
15
|
+
Path to nginx pid file.
|
|
16
|
+
Defaults to /var/run/nginx.pid
|
|
17
|
+
|
|
18
|
+
set :nginx_pid_path, "/var/run/nginx.pid"
|
|
19
|
+
|
|
20
|
+
nginx_prefix_path: |
|
|
21
|
+
Nginx install prefix.
|
|
22
|
+
Defaults to /var/nginx
|
|
23
|
+
|
|
24
|
+
set :nginx_prefix_path, "/var/nginx"
|
|
25
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
install:
|
|
2
|
+
sphinx_prefix: |
|
|
3
|
+
Sphinx install prefix.
|
|
4
|
+
Defaults to "/usr/local/sphinx"
|
|
5
|
+
|
|
6
|
+
set :sphinx_prefix, "/usr/local/sphinx"
|
|
7
|
+
|
|
8
|
+
setup:
|
|
9
|
+
sphinx_prefix: |
|
|
10
|
+
Sphinx install prefix.
|
|
11
|
+
Defaults to "/usr/local/sphinx"
|
|
12
|
+
|
|
13
|
+
set :sphinx_prefix, "/usr/local/sphinx"
|
|
14
|
+
|
data/lib/doc/gems.yml
ADDED
data/lib/doc/install.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
default:
|
|
2
|
+
recipes: |
|
|
3
|
+
Recipes to run as part of install.
|
|
4
|
+
|
|
5
|
+
set :recipes, [ "centos:setup_for_web", "packages:install", "centos:ruby:install" ]
|
|
6
|
+
|
|
7
|
+
install_user: |
|
|
8
|
+
The user to run as for install recipes.
|
|
9
|
+
Defaults to root.
|
|
10
|
+
|
|
11
|
+
set :install_user, "root"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
install_monit:
|
|
2
|
+
memcached_pid_path: |
|
|
3
|
+
Path to memcached pid file.
|
|
4
|
+
Defaults to /var/run/memcached.pid
|
|
5
|
+
|
|
6
|
+
set :memcached_pid_path, "/var/run/memcached.pid"
|
|
7
|
+
|
|
8
|
+
memcached_port: |
|
|
9
|
+
Memcached port.
|
|
10
|
+
Defaults to 11211.
|
|
11
|
+
|
|
12
|
+
set :memcached_port, 11211
|
|
13
|
+
|
data/lib/doc/mysql.yml
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
setup:
|
|
2
|
+
db_name: |
|
|
3
|
+
Database name (application).
|
|
4
|
+
|
|
5
|
+
set :db_name, "app_db_name"
|
|
6
|
+
|
|
7
|
+
db_user: |
|
|
8
|
+
Database user (application).
|
|
9
|
+
|
|
10
|
+
set :db_user, "app_db_user"
|
|
11
|
+
|
|
12
|
+
db_pass: |
|
|
13
|
+
Database password (application).
|
|
14
|
+
|
|
15
|
+
set :db_pass, "the_password"
|
|
16
|
+
|
|
17
|
+
web_host: |
|
|
18
|
+
Web host to provide access privileges to (if recipe used in context of web app).
|
|
19
|
+
Defaults to nil
|
|
20
|
+
TODO: Support multiple web hosts
|
|
21
|
+
|
|
22
|
+
set :web_host, 10.0.6.100
|
|
23
|
+
|
|
24
|
+
db_host: |
|
|
25
|
+
Database host (to provide itself with access).
|
|
26
|
+
|
|
27
|
+
set :db_host, 10.0.6.101
|
|
28
|
+
|
|
29
|
+
mysql_admin_password: |
|
|
30
|
+
Mysql admin password (to use to connect).
|
|
31
|
+
Defaults to password prompt.
|
|
32
|
+
|
|
33
|
+
set :mysql_admin_password, Proc.new { Capistrano::CLI.ui.ask('Mysql admin password: ') })
|
|
34
|
+
|
|
35
|
+
setup_monit:
|
|
36
|
+
db_port: |
|
|
37
|
+
Mysql port.
|
|
38
|
+
Defaults to 3306.
|
|
39
|
+
|
|
40
|
+
set :db_port, 3306
|
|
41
|
+
|
|
42
|
+
mysql_pid_path: |
|
|
43
|
+
Path to mysql pid file.
|
|
44
|
+
Defaults to /var/run/mysqld/mysqld.pid
|
|
45
|
+
|
|
46
|
+
set :mysql_pid_path, "/var/run/mysqld/mysqld.pid"
|
data/lib/doc/nginx.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
install_monit:
|
|
2
|
+
nginx_pid_path: |
|
|
3
|
+
Path to nginx pid file.
|
|
4
|
+
Defaults to /var/run/nginx.pid
|
|
5
|
+
|
|
6
|
+
set :nginx_pid_path, "/var/run/nginx.pid"
|
|
7
|
+
|
|
8
|
+
setup_mongrel:
|
|
9
|
+
mongrel_size: |
|
|
10
|
+
Number of mongrels.
|
|
11
|
+
|
|
12
|
+
set :mongrel_size, 3
|
|
13
|
+
|
|
14
|
+
mongrel_port: |
|
|
15
|
+
Starting port for mongrels.
|
|
16
|
+
If there are 3 mongrels with port 9000, then instances will be at 9000, 9001, and 9002
|
|
17
|
+
|
|
18
|
+
set :mongrel_port, 9000
|
|
19
|
+
|
|
20
|
+
domain_name: |
|
|
21
|
+
Domain name for nginx virtual host, (without www prefix).
|
|
22
|
+
|
|
23
|
+
set :domain_name, "foo.com"
|