calas-capitate 0.3.6
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 +13 -0
- data/History.txt +167 -0
- data/License.txt +20 -0
- data/Manifest.txt +121 -0
- data/README.txt +8 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +72 -0
- data/config/requirements.rb +17 -0
- data/lib/capitate.rb +56 -0
- data/lib/capitate/cap_ext/connections.rb +105 -0
- data/lib/capitate/cap_ext/docs.rb +26 -0
- data/lib/capitate/cap_ext/namespace.rb +34 -0
- data/lib/capitate/cap_ext/run_via.rb +16 -0
- data/lib/capitate/cap_ext/task_definition.rb +22 -0
- data/lib/capitate/cap_ext/variables.rb +132 -0
- data/lib/capitate/plugins/base.rb +140 -0
- data/lib/capitate/plugins/build.rb +71 -0
- data/lib/capitate/plugins/gem.rb +24 -0
- data/lib/capitate/plugins/prompt.rb +109 -0
- data/lib/capitate/plugins/rake.rb +25 -0
- data/lib/capitate/plugins/script.rb +96 -0
- data/lib/capitate/plugins/templates.rb +113 -0
- data/lib/capitate/plugins/utils.rb +151 -0
- data/lib/capitate/plugins/yum.rb +76 -0
- data/lib/capitate/recipes.rb +5 -0
- data/lib/capitate/task_node.rb +262 -0
- data/lib/capitate/version.rb +9 -0
- data/lib/deployment/centos-5.1-64-web/install.rb +196 -0
- data/lib/recipes/active_record.rb +36 -0
- data/lib/recipes/apache.rb +47 -0
- data/lib/recipes/backgroundrb.rb +29 -0
- data/lib/recipes/centos/backgroundjob.rb +27 -0
- data/lib/recipes/centos/backgroundrb.rb +23 -0
- data/lib/recipes/centos/centos.rb +45 -0
- data/lib/recipes/centos/imagemagick.rb +29 -0
- data/lib/recipes/centos/memcached.rb +45 -0
- data/lib/recipes/centos/merb.rb +23 -0
- data/lib/recipes/centos/mongrel_cluster.rb +54 -0
- data/lib/recipes/centos/monit.rb +62 -0
- data/lib/recipes/centos/mysql.rb +25 -0
- data/lib/recipes/centos/nginx.rb +64 -0
- data/lib/recipes/centos/ruby.rb +40 -0
- data/lib/recipes/centos/sphinx.rb +59 -0
- data/lib/recipes/docs.rb +24 -0
- data/lib/recipes/logrotate/backgroundjob.rb +26 -0
- data/lib/recipes/logrotate/backgroundrb.rb +26 -0
- data/lib/recipes/logrotate/merb.rb +25 -0
- data/lib/recipes/logrotate/mongrel_cluster.rb +29 -0
- data/lib/recipes/logrotate/monit.rb +28 -0
- data/lib/recipes/logrotate/mysql.rb +26 -0
- data/lib/recipes/logrotate/nginx.rb +37 -0
- data/lib/recipes/logrotate/rails.rb +21 -0
- data/lib/recipes/logrotate/sphinx.rb +21 -0
- data/lib/recipes/logrotated.rb +61 -0
- data/lib/recipes/memcached.rb +26 -0
- data/lib/recipes/merb.rb +32 -0
- data/lib/recipes/monit.rb +35 -0
- data/lib/recipes/monit/backgroundjob.rb +38 -0
- data/lib/recipes/monit/backgroundrb.rb +38 -0
- data/lib/recipes/monit/database.rb +25 -0
- data/lib/recipes/monit/memcached.rb +22 -0
- data/lib/recipes/monit/merb.rb +58 -0
- data/lib/recipes/monit/mongrel_cluster.rb +85 -0
- data/lib/recipes/monit/mysql.rb +20 -0
- data/lib/recipes/monit/nginx.rb +37 -0
- data/lib/recipes/monit/sphinx.rb +38 -0
- data/lib/recipes/monit/sshd.rb +27 -0
- data/lib/recipes/mysql.rb +42 -0
- data/lib/recipes/nginx.rb +29 -0
- data/lib/recipes/rails.rb +71 -0
- data/lib/recipes/redmine.rb +38 -0
- data/lib/recipes/sphinx.rb +60 -0
- data/lib/recipes/sshd.rb +47 -0
- data/lib/recipes/syslogd.rb +21 -0
- data/lib/templates/apache/vhost.mongrel_cluster.conf.erb +46 -0
- data/lib/templates/backgroundjob/backgroundjob.initd.centos.erb +54 -0
- data/lib/templates/backgroundjob/backgroundjob.monitrc.erb +3 -0
- data/lib/templates/backgroundrb/backgroundrb.initd.centos.erb +58 -0
- data/lib/templates/backgroundrb/backgroundrb.monitrc.erb +3 -0
- data/lib/templates/backgroundrb/backgroundrb.yml.erb +14 -0
- data/lib/templates/capistrano/Capfile +22 -0
- data/lib/templates/logrotated/conf.erb +3 -0
- data/lib/templates/memcached/memcached.initd.centos.erb +58 -0
- data/lib/templates/memcached/memcached.monitrc.erb +4 -0
- data/lib/templates/memcached/memcached.yml.erb +14 -0
- data/lib/templates/merb/merb-no-http.monitrc.erb +13 -0
- data/lib/templates/merb/merb.initd.centos.erb +123 -0
- data/lib/templates/merb/merb.monitrc.erb +15 -0
- data/lib/templates/mongrel/mongrel_cluster.initd.centos.erb +94 -0
- data/lib/templates/mongrel/mongrel_cluster.monitrc.erb +15 -0
- data/lib/templates/mongrel/mongrel_cluster.yml.erb +11 -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 +18 -0
- data/lib/templates/mysql/install_db.sql.erb +6 -0
- data/lib/templates/mysql/my.cnf.innodb_1024.erb +122 -0
- data/lib/templates/mysql/my.cnf.innodb_512.erb +127 -0
- data/lib/templates/mysql/mysql.monitrc.erb +6 -0
- data/lib/templates/nginx/nginx.conf.erb +97 -0
- data/lib/templates/nginx/nginx.initd.centos.erb +69 -0
- data/lib/templates/nginx/nginx.monitrc.erb +4 -0
- data/lib/templates/nginx/nginx_vhost.conf.erb +101 -0
- data/lib/templates/nginx/nginx_vhost_generic.conf.erb +99 -0
- data/lib/templates/rails/database.yml.erb +7 -0
- data/lib/templates/redmine/email.yml.erb +10 -0
- data/lib/templates/ruby/fix_openssl.sh +12 -0
- data/lib/templates/sphinx/sphinx.conf.erb +157 -0
- data/lib/templates/sphinx/sphinx.monitrc.erb +4 -0
- data/lib/templates/sphinx/sphinx_app.initd.centos.erb +90 -0
- data/lib/templates/sshd/sshd.monitrc.erb +5 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +80 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +23 -0
- data/test/test_helper.rb +2 -0
- data/test/test_plugin_upload.rb +32 -0
- data/test/test_recipes.rb +37 -0
- data/test/test_templates.rb +29 -0
- metadata +198 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
namespace :active_record do
|
|
2
|
+
|
|
3
|
+
desc <<-DESC
|
|
4
|
+
Create (ActiveRecord) database yaml in shared path.
|
|
5
|
+
Note: If both @:db_host@ and @:db_socket@ are used, @db_socket@ wins.
|
|
6
|
+
|
|
7
|
+
"Source":#{link_to_source(__FILE__)}
|
|
8
|
+
DESC
|
|
9
|
+
task_arg(:db_name, "Database name")
|
|
10
|
+
task_arg(:db_user, "Database user")
|
|
11
|
+
task_arg(:db_pass, "Database password")
|
|
12
|
+
task_arg(:db_host, "Database host", :default => nil)
|
|
13
|
+
task_arg(:db_socket, "Database socket", :default => nil)
|
|
14
|
+
task_arg(:database_yml_template, "Database yml template", :default => "rails/database.yml.erb")
|
|
15
|
+
task :setup, :roles => :app do
|
|
16
|
+
|
|
17
|
+
unless db_host.blank?
|
|
18
|
+
set :db_connect_type, "host"
|
|
19
|
+
set :db_connect, db_host
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
unless db_socket.blank?
|
|
23
|
+
set :db_connect_type, "socket"
|
|
24
|
+
set :db_connect, db_socket
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
run "mkdir -p #{shared_path}/config"
|
|
28
|
+
put template.load(database_yml_template), "#{shared_path}/config/database.yml"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc "Make symlink for database yaml"
|
|
32
|
+
task :update_code do
|
|
33
|
+
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
namespace :apache do
|
|
2
|
+
|
|
3
|
+
desc "Reload apache configuration"
|
|
4
|
+
task :reload, :roles => :app do
|
|
5
|
+
sudo "/etc/init.d/apache2 reload"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
namespace :vhost do
|
|
9
|
+
|
|
10
|
+
desc "Enable vhost"
|
|
11
|
+
task_arg(:application, "Application Name", :default => Proc.new{ fetch(:application)})
|
|
12
|
+
task :enable, :roles => :app do
|
|
13
|
+
sudo "/usr/sbin/a2ensite #{application}.conf"
|
|
14
|
+
apache.reload
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Disable vhost"
|
|
18
|
+
task_arg(:application, "Application Name", :default => Proc.new{ fetch(:application)})
|
|
19
|
+
task :disable, :roles => :app do
|
|
20
|
+
sudo "/usr/sbin/a2dissite #{application}.conf"
|
|
21
|
+
apache.reload
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc "Create (and upload) an apache vhost configuration for this application"
|
|
25
|
+
task_arg(:domain, "Application domain")
|
|
26
|
+
task_arg(:domain_aliases, "Domain Aliases", :default => [])
|
|
27
|
+
task_arg(:current_path, "Current Path", :default => Proc.new{ fetch(:current_path)})
|
|
28
|
+
task_arg(:application, "Application Name", :default => Proc.new{ fetch(:application)})
|
|
29
|
+
task :setup, :roles => :app do
|
|
30
|
+
fetch(:mongrel_size)
|
|
31
|
+
fetch(:mongrel_port)
|
|
32
|
+
|
|
33
|
+
set :public_path, "#{current_path}/public"
|
|
34
|
+
set :cluster_name, "#{application}_cluster"
|
|
35
|
+
|
|
36
|
+
mongrel_instances = []
|
|
37
|
+
ports = (0...mongrel_size).collect { |i| mongrel_port + i }
|
|
38
|
+
ports.each { |port| mongrel_instances << "127.0.0.1:#{port}" }
|
|
39
|
+
|
|
40
|
+
set :mongrel_instances, mongrel_instances
|
|
41
|
+
set :server_alias, domain_aliases.empty? ? nil : "ServerAlias #{domain_aliases.join(' ')}"
|
|
42
|
+
|
|
43
|
+
put template.load("apache/vhost.mongrel_cluster.conf.erb"), "/tmp/#{application}.vhost.conf"
|
|
44
|
+
sudo "mv /tmp/#{application}.vhost.conf /etc/apache2/sites-available/#{application}.conf"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
namespace :backgroundrb do
|
|
2
|
+
|
|
3
|
+
desc <<-DESC
|
|
4
|
+
Create backgroundrb.yml configuration.
|
|
5
|
+
|
|
6
|
+
For pid path support, change backgroundrb script pid_file line to:
|
|
7
|
+
|
|
8
|
+
pid_file = "\#{CONFIG_FILE[:backgroundrb][:pid_file]}"
|
|
9
|
+
|
|
10
|
+
"Source":#{link_to_source(__FILE__)}
|
|
11
|
+
DESC
|
|
12
|
+
task_arg(:backgroundrb_host, "Backgroundrb host", :default => "0.0.0.0")
|
|
13
|
+
task_arg(:backgroundrb_port, "Backgroundrb port", :default => 11006)
|
|
14
|
+
task_arg(:backgroundrb_pid_path, "Backgroundrb pid path", :default => Proc.new{"#{shared_path}/pids/backgroundrb.pid"}, :default_desc => "\#{shared_path}/pids/backgroundrb.pid")
|
|
15
|
+
task_arg(:backgroundrb_yml_template, "Backgroundrb yml template", :default => "backgroundrb/backgroundrb.yml.erb")
|
|
16
|
+
task :setup do
|
|
17
|
+
utils.install_template(backgroundrb_yml_template, "#{shared_path}/config/backgroundrb.yml")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc <<-DESC
|
|
21
|
+
Symlink backgroundrb config into current path.
|
|
22
|
+
|
|
23
|
+
"Source":#{link_to_source(__FILE__)}
|
|
24
|
+
DESC
|
|
25
|
+
task :update_code do
|
|
26
|
+
run "ln -nfs #{shared_path}/config/backgroundrb.yml #{release_path}/config/backgroundrb.yml"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
namespace :backgroundjob do
|
|
2
|
+
|
|
3
|
+
namespace :centos do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Setup backgroundjob for application.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:backgroundjob_bin_path, "Path to backgroundjob",
|
|
11
|
+
:default => Proc.new{"#{current_path}/script/bj run --forever --rails_env=production --rails_root=#{current_path} --redirect=#{backgroundjob_log_path} --log=#{backgroundjob_log_path} --pidfile=#{backgroundjob_pid_path} --daemon"},
|
|
12
|
+
:default_desc => "\#{current_path}/script/bj run --forever --rails_env=production --rails_root=\#{current_path} --redirect=\#{backgroundjob_log_path} --log=\#{backgroundjob_log_path} --pidfile=\#{backgroundjob_pid_path} --daemon")
|
|
13
|
+
task_arg(:backgroundjob_pid_path, "Path to backgroundjob pid file", :default => Proc.new{"#{shared_path}/pids/bj.pid"}, :default_desc => "\#{shared_path}/pids/bj.pid")
|
|
14
|
+
task_arg(:backgroundjob_log_path, "Path to backgroundjob log file", :default => Proc.new{"#{shared_path}/log/bj.log"}, :default_desc => "\#{shared_path}/log/bj.log")
|
|
15
|
+
task :setup do
|
|
16
|
+
|
|
17
|
+
# Install initscript
|
|
18
|
+
utils.install_template("backgroundjob/backgroundjob.initd.centos.erb", "/etc/init.d/backgroundjob_#{application}")
|
|
19
|
+
|
|
20
|
+
# Enable service
|
|
21
|
+
run_via "/sbin/chkconfig --level 345 backgroundjob_#{application} on"
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
namespace :backgroundrb do
|
|
2
|
+
|
|
3
|
+
namespace :centos do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Setup backgroundrb for application.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:backgroundrb_bin_path, "Path to backgroundrb bin", :default => Proc.new{"#{current_path}/script/backgroundrb -e production start"}, :default_desc => "\#{current_path}/script/backgroundrb -e production start")
|
|
11
|
+
task_arg(:backgroundrb_pid_path, "Path to backgroundrb pid file", :default => Proc.new{"#{shared_path}/pids/backgroundrb.pid"}, :default_desc => "\#{shared_path}/pids/backgroundrb.pid")
|
|
12
|
+
task :setup do
|
|
13
|
+
# Install initscript
|
|
14
|
+
utils.install_template("backgroundrb/backgroundrb.initd.centos.erb", "/etc/init.d/backgroundrb_#{application}")
|
|
15
|
+
|
|
16
|
+
# Enable service
|
|
17
|
+
run_via "/sbin/chkconfig --level 345 backgroundrb_#{application} on"
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Custom tasks for centos OS profiles
|
|
2
|
+
namespace :centos do
|
|
3
|
+
|
|
4
|
+
# Add user for an application
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Add user and set user password for application. Adds user to specified groups.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:user_add, "User to add")
|
|
11
|
+
task_arg(:groups, "Groups for user to be in", :default => nil, :example => "\"admin,foo,bar\"")
|
|
12
|
+
task_arg(:home, "Home directory for user", :set => :deploy_to)
|
|
13
|
+
task_arg(:home_readable, "Whether home permissions are readable by all. Needed if using deploy dir as home.", :default => true)
|
|
14
|
+
task :add_user do
|
|
15
|
+
|
|
16
|
+
adduser_options = []
|
|
17
|
+
adduser_options << "-d #{home}" unless home.blank?
|
|
18
|
+
adduser_options << "-G #{groups}" unless groups.blank?
|
|
19
|
+
|
|
20
|
+
user_existed = false
|
|
21
|
+
run "id #{user_add} || /usr/sbin/adduser #{adduser_options.join(" ")} #{user_add}" do |channel, stream, data|
|
|
22
|
+
logger.info data
|
|
23
|
+
user_existed = data =~ /uid/
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
logger.info "User already existed, aborting..." if user_existed
|
|
27
|
+
|
|
28
|
+
unless user_existed
|
|
29
|
+
run "chmod a+rx #{home}" if home_readable
|
|
30
|
+
|
|
31
|
+
new_password = prompt.password("Password to set for #{user_add}: ", :verify => true, :lazy => false)
|
|
32
|
+
|
|
33
|
+
run "passwd #{user_add}" do |channel, stream, data|
|
|
34
|
+
logger.info data
|
|
35
|
+
|
|
36
|
+
if data =~ /password:/i
|
|
37
|
+
channel.send_data "#{new_password}\n"
|
|
38
|
+
channel.send_data "#{new_password}\n"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
namespace :imagemagick do
|
|
2
|
+
namespace :centos do
|
|
3
|
+
|
|
4
|
+
desc <<-DESC
|
|
5
|
+
Install imagemagick.
|
|
6
|
+
|
|
7
|
+
"Source":#{link_to_source(__FILE__)}
|
|
8
|
+
DESC
|
|
9
|
+
task_arg(:imagemagick_build_options, <<-EOS)
|
|
10
|
+
Imagemagick build options
|
|
11
|
+
<pre>
|
|
12
|
+
<code class="ruby">
|
|
13
|
+
set :imagemagick_build_options, {
|
|
14
|
+
:url => "ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz",
|
|
15
|
+
:unpack_dir => "ImageMagick-*"
|
|
16
|
+
}
|
|
17
|
+
</code>
|
|
18
|
+
</pre>
|
|
19
|
+
EOS
|
|
20
|
+
task :install do
|
|
21
|
+
# Install dependencies
|
|
22
|
+
yum.install([ "libjpeg-devel", "libpng-devel", "glib2-devel", "fontconfig-devel", "zlib-devel",
|
|
23
|
+
"libwmf-devel", "freetype-devel", "libtiff-devel" ])
|
|
24
|
+
|
|
25
|
+
build.make_install("imagemagick", imagemagick_build_options)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
namespace :memcached do
|
|
2
|
+
|
|
3
|
+
namespace :centos do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install memcached.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:memcached_pid_path, "Path to memcached pid file.", :default => "/var/run/memcached.pid")
|
|
11
|
+
task_arg(:memcached_port, "Memcached port", :default => 11211)
|
|
12
|
+
task_arg(:memcached_memory, "Memcached memory (in MB)")
|
|
13
|
+
task_arg(:memcached_build_options, <<-EOS)
|
|
14
|
+
Memcached build options
|
|
15
|
+
<pre>
|
|
16
|
+
<code class="ruby">
|
|
17
|
+
set :memcached_build_options, {
|
|
18
|
+
:url => "http://www.danga.com/memcached/dist/memcached-1.2.4.tar.gz",
|
|
19
|
+
:configure_options => "--prefix=/usr/local"
|
|
20
|
+
}
|
|
21
|
+
</code>
|
|
22
|
+
</pre>
|
|
23
|
+
EOS
|
|
24
|
+
task :install do
|
|
25
|
+
# Build
|
|
26
|
+
build.make_install("memcached", memcached_build_options)
|
|
27
|
+
initscript
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc <<-DESC
|
|
31
|
+
Install memcached initscript.
|
|
32
|
+
|
|
33
|
+
"Source":#{link_to_source(__FILE__)}
|
|
34
|
+
DESC
|
|
35
|
+
task_arg(:memcached_pid_path, "Path to memcached pid file.", :default => "/var/run/memcached.pid")
|
|
36
|
+
task_arg(:memcached_port, "Memcached port", :default => 11211)
|
|
37
|
+
task_arg(:memcached_memory, "Memcached memory (in MB)")
|
|
38
|
+
task :initscript do
|
|
39
|
+
utils.install_template("memcached/memcached.initd.centos.erb", "/etc/init.d/memcached")
|
|
40
|
+
run_via "/sbin/chkconfig --level 345 memcached on"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
namespace :merb do
|
|
2
|
+
namespace :centos do
|
|
3
|
+
|
|
4
|
+
desc <<-DESC
|
|
5
|
+
Setup merb.
|
|
6
|
+
|
|
7
|
+
"Source":#{link_to_source(__FILE__)}
|
|
8
|
+
DESC
|
|
9
|
+
task_arg(:merb_nodes, "Number of merb daemons to run")
|
|
10
|
+
task_arg(:merb_port, "Starting port for merb nodes. If there are 3 merb nodes with port 9000, then instances will be at 9000, 9001, and 9002")
|
|
11
|
+
task_arg(:merb_command_path, "The path for merb startup command", :default => "merb")
|
|
12
|
+
task_arg(:merb_pid_path, "Path for merb pids", :default => Proc.new{"#{shared_path}/pids/merb.pid"}, :default_desc => "\#{shared_path}/pids/merb.pid")
|
|
13
|
+
task_arg(:merb_root, "Directory for merb root", :set => :current_path)
|
|
14
|
+
task_arg(:merb_application, "Merb application name", :default => Proc.new{"merb_#{application}"}, :default_desc => "merb_\#{application}")
|
|
15
|
+
task_arg(:merb_initscript_name, "Initscript name", :default => Proc.new{"merb_#{application}"}, :default_desc => "merb_\#{application}")
|
|
16
|
+
task :setup do
|
|
17
|
+
utils.install_template("merb/merb.initd.centos.erb", "/etc/init.d/#{merb_initscript_name}")
|
|
18
|
+
run_via "/sbin/chkconfig --level 345 #{merb_initscript_name} on"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
namespace :mongrel do
|
|
2
|
+
|
|
3
|
+
namespace :cluster do
|
|
4
|
+
|
|
5
|
+
namespace :centos do
|
|
6
|
+
|
|
7
|
+
desc <<-DESC
|
|
8
|
+
Create mongrel cluster.
|
|
9
|
+
|
|
10
|
+
"Source":#{link_to_source(__FILE__)}
|
|
11
|
+
DESC
|
|
12
|
+
|
|
13
|
+
task_arg(:mongrel_application, "Name of mongrel application")
|
|
14
|
+
task_arg(:mongrel_size, "Number of mongrels")
|
|
15
|
+
task_arg(:mongrel_port, "Starting port for mongrels. If there are 3 mongrels with port 9000, then instances will be at 9000, 9001, and 9002")
|
|
16
|
+
task_arg(:mongrel_config_dir, "Directory for mongrel config", :default => Proc.new{"#{shared_path}/config/mongrel"}, :default_desc => "\#{shared_path}/config/mongrel")
|
|
17
|
+
task_arg(:mongrel_pid_dir, "Directory for mongrel pids", :default => Proc.new{"#{shared_path}/pids"}, :default_desc => "\#{shared_path}/pids")
|
|
18
|
+
task_arg(:mongrel_config_script, "Config script to load with mongrel", :default => nil)
|
|
19
|
+
|
|
20
|
+
task_arg(:mongrel_cluster_command, "Mongrel cluster command", :default => "mongrel_cluster_ctl")
|
|
21
|
+
task_arg(:mongrel_initscript_name, "Mongrel initscript name", :default => Proc.new{"mongrel_cluster_#{application}"}, :default_desc => "mongrel_cluster_\#{application}")
|
|
22
|
+
task_arg(:mongrel_config_options, "Config options appended to cluster yml", :default => {})
|
|
23
|
+
|
|
24
|
+
task :setup do
|
|
25
|
+
|
|
26
|
+
unless mongrel_config_script.blank?
|
|
27
|
+
mongrel_config_options["config_script"] = mongrel_config_script
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
run "mkdir -p #{mongrel_config_dir}"
|
|
31
|
+
|
|
32
|
+
set :mongrel_pid_path, "#{mongrel_pid_dir}/#{mongrel_application}.pid"
|
|
33
|
+
set :mongrel_log_path, "log/#{mongrel_application}.log"
|
|
34
|
+
|
|
35
|
+
put template.load("mongrel/mongrel_cluster.yml.erb"), "#{mongrel_config_dir}/mongrel_cluster.yml"
|
|
36
|
+
|
|
37
|
+
initscript
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
desc "Mongrel cluster setup initscript for application"
|
|
41
|
+
task_arg(:mongrel_config_dir, "Directory for mongrel config", :default => Proc.new{"#{shared_path}/config/mongrel"}, :default_desc => "\#{shared_path}/config/mongrel")
|
|
42
|
+
task_arg(:mongrel_pid_dir, "Directory for mongrel pids", :default => Proc.new{"#{shared_path}/pids"}, :default_desc => "\#{shared_path}/pids")
|
|
43
|
+
task_arg(:mongrel_cluster_command, "Mongrel cluster command", :default => "mongrel_cluster_ctl")
|
|
44
|
+
task_arg(:mongrel_initscript_name, "Mongrel initscript name", :default => Proc.new{"mongrel_cluster_#{application}"}, :default_desc => "mongrel_cluster_\#{application}")
|
|
45
|
+
task :initscript do
|
|
46
|
+
utils.install_template("mongrel/mongrel_cluster.initd.centos.erb", "/etc/init.d/#{mongrel_initscript_name}")
|
|
47
|
+
run_via "/sbin/chkconfig --level 345 #{mongrel_initscript_name} on"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
namespace :monit do
|
|
2
|
+
|
|
3
|
+
namespace :centos do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install monit.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:monit_port, "Monit port", :default => 2812)
|
|
11
|
+
task_arg(:monit_password, "Monit password", :default => Proc.new{prompt.password('Monit admin password (to set): ', :verify => true)}, :default_desc => "password prompt")
|
|
12
|
+
task_arg(:monit_conf_dir, :default => "/etc/monit")
|
|
13
|
+
task_arg(:monit_pid_path, "Path to monit pid", :default => "/var/run/monit.pid")
|
|
14
|
+
task_arg(:monit_log_path, "Path to monit log file", :default => "/var/log/monit.log")
|
|
15
|
+
task_arg(:monit_build_options, <<-EOS)
|
|
16
|
+
Monit build options
|
|
17
|
+
<pre>
|
|
18
|
+
<code class="ruby">
|
|
19
|
+
set :monit_build_options, { :url => "http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz" }
|
|
20
|
+
</code>
|
|
21
|
+
</pre>
|
|
22
|
+
EOS
|
|
23
|
+
task :install do
|
|
24
|
+
|
|
25
|
+
# Install dependencies
|
|
26
|
+
yum.install([ "flex", "byacc" ])
|
|
27
|
+
|
|
28
|
+
# Build
|
|
29
|
+
build.make_install("monit", monit_build_options)
|
|
30
|
+
|
|
31
|
+
# Install initscript
|
|
32
|
+
utils.install_template("monit/monit.initd.centos.erb", "/etc/init.d/monit")
|
|
33
|
+
|
|
34
|
+
# Install monitrc
|
|
35
|
+
run_via "mkdir -p /etc/monit"
|
|
36
|
+
utils.install_template("monit/monitrc.erb", "/etc/monitrc", :user => "root", :mode => "700")
|
|
37
|
+
|
|
38
|
+
# Build cert
|
|
39
|
+
run_via "mkdir -p /var/certs"
|
|
40
|
+
utils.install_template("monit/monit.cnf", "/var/certs/monit.cnf")
|
|
41
|
+
|
|
42
|
+
script.run_all <<-CMDS
|
|
43
|
+
openssl req -new -x509 -days 365 -nodes -config /var/certs/monit.cnf -out /var/certs/monit.pem -keyout /var/certs/monit.pem -batch > /var/certs/debug_req.log 2>&1
|
|
44
|
+
openssl gendh 512 >> /var/certs/monit.pem 2> /var/certs/debug_gendh.log
|
|
45
|
+
openssl x509 -subject -dates -fingerprint -noout -in /var/certs/monit.pem > /var/certs/debug_x509.log
|
|
46
|
+
chmod 700 /var/certs/monit.pem
|
|
47
|
+
CMDS
|
|
48
|
+
|
|
49
|
+
# Install to inittab
|
|
50
|
+
utils.append_to("/etc/inittab", <<-APPEND, "^mo:345:respawn:/usr/local/bin/monit")
|
|
51
|
+
|
|
52
|
+
# Run monit in standard run-levels
|
|
53
|
+
mo:345:respawn:/usr/local/bin/monit -Ic /etc/monitrc -l #{monit_log_path} -p #{monit_pid_path}
|
|
54
|
+
APPEND
|
|
55
|
+
|
|
56
|
+
# HUP the inittab
|
|
57
|
+
run_via "telinit q"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
namespace :mysql do
|
|
2
|
+
|
|
3
|
+
namespace :centos do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install mysql.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:mysql_admin_password_set, "Mysql admin password (to set)", :default => Proc.new{prompt.password('Mysql admin password (to set): ', :verify => true)}, :default_desc => "password prompt")
|
|
11
|
+
task :install do
|
|
12
|
+
# Install through package manager
|
|
13
|
+
yum.install([ "mysql", "mysql-devel", "mysql-server" ])
|
|
14
|
+
|
|
15
|
+
# Install service
|
|
16
|
+
run_via "/sbin/chkconfig --level 345 mysqld on"
|
|
17
|
+
run_via "/sbin/service mysqld restart"
|
|
18
|
+
|
|
19
|
+
# Set admin password
|
|
20
|
+
run_via "/usr/bin/mysqladmin -u root password #{mysql_admin_password_set}"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|