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,64 @@
|
|
|
1
|
+
namespace :nginx do
|
|
2
|
+
|
|
3
|
+
namespace :centos do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install nginx, conf, initscript, nginx user and service.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:nginx_build_options, <<-EOS)
|
|
11
|
+
Nginx build options.
|
|
12
|
+
<pre>
|
|
13
|
+
<code class="ruby">
|
|
14
|
+
set :nginx_build_options, {
|
|
15
|
+
:url => "http://sysoev.ru/nginx/nginx-0.5.35.tar.gz",
|
|
16
|
+
:configure_options => "--sbin-path=\#{nginx_bin_path} --conf-path=\#{nginx_conf_path}
|
|
17
|
+
--pid-path=\#{nginx_pid_path} --error-log-path=/var/log/nginx_master_error.log --lock-path=/var/lock/nginx
|
|
18
|
+
--prefix=\#{nginx_prefix_path} --with-md5=auto/lib/md5 --with-sha1=auto/lib/sha1 --with-http_ssl_module"
|
|
19
|
+
}
|
|
20
|
+
</code>
|
|
21
|
+
</pre>
|
|
22
|
+
EOS
|
|
23
|
+
task_arg(:nginx_bin_path, "Nginx sbin path", :default => "/sbin/nginx")
|
|
24
|
+
task_arg(:nginx_conf_path, "Path to nginx conf", :default => "/etc/nginx/nginx.conf")
|
|
25
|
+
task_arg(:nginx_pid_path, "Path to nginx pid file", :default => "/var/run/nginx.pid")
|
|
26
|
+
task_arg(:nginx_prefix_path, "Nginx install prefix", :default => "/var/nginx")
|
|
27
|
+
task :install do
|
|
28
|
+
# Install dependencies
|
|
29
|
+
yum.install([ "pcre-devel", "openssl", "openssl-devel" ])
|
|
30
|
+
|
|
31
|
+
# Build
|
|
32
|
+
build.make_install("nginx", nginx_build_options)
|
|
33
|
+
|
|
34
|
+
# Initscript
|
|
35
|
+
initscript
|
|
36
|
+
|
|
37
|
+
# Setup nginx
|
|
38
|
+
run_via "mkdir -p /etc/nginx/vhosts"
|
|
39
|
+
run_via "echo \"# Blank nginx conf; work-around for nginx conf include issue\" > /etc/nginx/vhosts/blank.conf"
|
|
40
|
+
put template.load("nginx/nginx.conf.erb", binding), "/tmp/nginx.conf"
|
|
41
|
+
run_via "install -o root -m 644 /tmp/nginx.conf #{nginx_conf_path} && rm -f /tmp/nginx.conf"
|
|
42
|
+
|
|
43
|
+
# Create nginx user
|
|
44
|
+
run_via "id nginx || /usr/sbin/adduser -r nginx"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
desc "Install nginx initscript"
|
|
48
|
+
task_arg(:nginx_bin_path, "Nginx sbin path", :default => "/sbin/nginx")
|
|
49
|
+
task_arg(:nginx_conf_path, "Path to nginx conf", :default => "/etc/nginx/nginx.conf")
|
|
50
|
+
task_arg(:nginx_pid_path, "Path to nginx pid file", :default => "/var/run/nginx.pid")
|
|
51
|
+
task :initscript do
|
|
52
|
+
utils.install_template("nginx/nginx.initd.centos.erb", "/etc/init.d/nginx")
|
|
53
|
+
run_via "/sbin/chkconfig --level 345 nginx on"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Restart nginx
|
|
57
|
+
desc "Restart nginx (service)"
|
|
58
|
+
task :restart do
|
|
59
|
+
sudo "/sbin/service nginx restart"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
namespace :ruby do
|
|
2
|
+
|
|
3
|
+
namespace :centos do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install ruby and rubygems.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:ruby_build_options, <<-EOS)
|
|
11
|
+
Rubygems build options.
|
|
12
|
+
<pre>
|
|
13
|
+
<code class="ruby">
|
|
14
|
+
set :ruby_build_options, {
|
|
15
|
+
:url => "http://capitate.s3.amazonaws.com/ruby-1.8.6-p110.tar.gz",
|
|
16
|
+
:build_dest => "/usr/src",
|
|
17
|
+
:configure_options => "--prefix=/usr",
|
|
18
|
+
:clean => false
|
|
19
|
+
}
|
|
20
|
+
</code>
|
|
21
|
+
</pre>
|
|
22
|
+
EOS
|
|
23
|
+
task_arg(:rubygems_build_options, "Rubygems build options")
|
|
24
|
+
task :install do
|
|
25
|
+
# Install dependencies
|
|
26
|
+
yum.install([ "zlib", "zlib-devel", "readline-devel" ])
|
|
27
|
+
|
|
28
|
+
# Install ruby 1.8.6
|
|
29
|
+
build.make_install("ruby", ruby_build_options)
|
|
30
|
+
|
|
31
|
+
# Install rubygems
|
|
32
|
+
build.install("rubygems", rubygems_build_options) do |dir|
|
|
33
|
+
run_via "cd #{dir} && ruby setup.rb"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
namespace :sphinx do
|
|
2
|
+
|
|
3
|
+
namespace :centos do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install sphinx.\n
|
|
7
|
+
|
|
8
|
+
DESC
|
|
9
|
+
task_arg(:sphinx_build_options, <<-EOS)
|
|
10
|
+
Sphinx build options.
|
|
11
|
+
<pre>
|
|
12
|
+
<code class="ruby">
|
|
13
|
+
set :sphinx_build_options, {
|
|
14
|
+
:url => "http://www.sphinxsearch.com/downloads/sphinx-0.9.7.tar.gz",
|
|
15
|
+
:configure_options => "--with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql
|
|
16
|
+
--prefix=\#{sphinx_prefix}"
|
|
17
|
+
}
|
|
18
|
+
</code>
|
|
19
|
+
</pre>
|
|
20
|
+
EOS
|
|
21
|
+
task_arg(:sphinx_prefix, "Sphinx install prefix", :default => "/usr/local/sphinx")
|
|
22
|
+
task :install do
|
|
23
|
+
# Install dependencies
|
|
24
|
+
yum.install([ "gcc-c++" ])
|
|
25
|
+
|
|
26
|
+
# Build
|
|
27
|
+
build.make_install("sphinx", sphinx_build_options)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc <<-DESC
|
|
31
|
+
Setup sphinx for application.
|
|
32
|
+
|
|
33
|
+
"Source":#{link_to_source(__FILE__)}
|
|
34
|
+
DESC
|
|
35
|
+
task_arg(:sphinx_prefix, "Sphinx install prefix", :default => "/usr/local/sphinx")
|
|
36
|
+
task_arg(:sphinx_pid_path, "Directory to sphinx pid", :default => Proc.new{"#{shared_path}/pids/searchd.pid"}, :default_desc => "\#{shared_path}/pids/searchd.pid")
|
|
37
|
+
task_arg(:sphinx_conf_path, "Path to sphinx.conf", :default => Proc.new{"#{shared_path}/config/sphinx.conf"}, :default_desc => "\#{shared_path}/config/sphinx.conf")
|
|
38
|
+
task_arg(:sphinx_index_root, "Path to sphinx indexes", :default => Proc.new{"#{shared_path}/var/index"}, :default_desc => "\#{shared_path}/var/index")
|
|
39
|
+
task :setup do
|
|
40
|
+
initscript
|
|
41
|
+
# Create app indexes dir
|
|
42
|
+
run "mkdir -p #{shared_path}/var/index"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
desc "Setup sphinx initscript"
|
|
47
|
+
task_arg(:sphinx_prefix, "Sphinx install prefix", :default => "/usr/local/sphinx")
|
|
48
|
+
task_arg(:sphinx_pid_path, "Directory to sphinx pid", :default => Proc.new{"#{shared_path}/pids/searchd.pid"}, :default_desc => "\#{shared_path}/pids/searchd.pid")
|
|
49
|
+
task_arg(:sphinx_conf_path, "Path to sphinx.conf", :default => Proc.new{"#{shared_path}/config/sphinx.conf"}, :default_desc => "\#{shared_path}/config/sphinx.conf")
|
|
50
|
+
task_arg(:sphinx_index_root, "Path to sphinx indexes", :default => Proc.new{"#{shared_path}/var/index"}, :default_desc => "\#{shared_path}/var/index")
|
|
51
|
+
task :initscript do
|
|
52
|
+
utils.install_template("sphinx/sphinx_app.initd.centos.erb", "/etc/init.d/sphinx_#{application}")
|
|
53
|
+
run_via "/sbin/chkconfig --level 345 sphinx_#{application} on"
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
data/lib/recipes/docs.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
namespace :docs do
|
|
2
|
+
|
|
3
|
+
desc <<-DESC
|
|
4
|
+
Generate documentation for all currently loaded recipes. Assumes textile formatting.
|
|
5
|
+
|
|
6
|
+
This recipe generated this documentation.
|
|
7
|
+
|
|
8
|
+
"Source":#{link_to_source(__FILE__)}
|
|
9
|
+
DESC
|
|
10
|
+
task_arg(:docs_recipes_dir, "Destination directory", :default => "docs/recipes")
|
|
11
|
+
task_arg(:docs_recipes_clear, "Whether to clear destination before generating.", :default => true)
|
|
12
|
+
task :recipes do
|
|
13
|
+
|
|
14
|
+
# Build task tree
|
|
15
|
+
top_node = capitate.task_tree
|
|
16
|
+
|
|
17
|
+
FileUtils.rm_rf(docs_recipes_dir) if docs_recipes_clear
|
|
18
|
+
FileUtils.mkdir_p(docs_recipes_dir)
|
|
19
|
+
|
|
20
|
+
top_node.write_doc(docs_recipes_dir, "index", "Recipes", :include_source => true)
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
namespace :backgroundjob do
|
|
2
|
+
|
|
3
|
+
namespace :logrotate do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install logrotated conf for backgroundjob.
|
|
7
|
+
|
|
8
|
+
<dl>
|
|
9
|
+
<dt>backgroundjob_logrotate_path<dt>
|
|
10
|
+
<dd>Backgroundjob logrotate paths.</dd>
|
|
11
|
+
<dd class="default">Defaults to @\#{shared_path}/log/bj*.log@</dd>
|
|
12
|
+
</dl>
|
|
13
|
+
"Source":#{link_to_source(__FILE__)}
|
|
14
|
+
DESC
|
|
15
|
+
task :install do
|
|
16
|
+
fetch_or_default(:backgroundjob_logrotate_path, "#{shared_path}/log/bj*.log")
|
|
17
|
+
|
|
18
|
+
set :logrotate_name, "backgroundjob_#{application}"
|
|
19
|
+
set :logrotate_log_path, backgroundjob_logrotate_path
|
|
20
|
+
set :logrotate_options, [ { :rotate => 2 }, :weekly, :missingok, :notifempty, :copytruncate ]
|
|
21
|
+
|
|
22
|
+
logrotated.install_conf
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
namespace :backgroundrb do
|
|
2
|
+
|
|
3
|
+
namespace :logrotate do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install logrotated conf for backgroundrb.
|
|
7
|
+
|
|
8
|
+
<dl>
|
|
9
|
+
<dt>backgroundrb_logrotate_path<dt>
|
|
10
|
+
<dd>Backgroundrb logrotate paths.</dd>
|
|
11
|
+
<dd class="default">Defaults to @\#{shared_path}/log/backgroundrb*.log@</dd>
|
|
12
|
+
</dl>
|
|
13
|
+
"Source":#{link_to_source(__FILE__)}
|
|
14
|
+
DESC
|
|
15
|
+
task :install do
|
|
16
|
+
fetch_or_default(:backgroundrb_logrotate_path, "#{shared_path}/log/backgroundrb*.log")
|
|
17
|
+
|
|
18
|
+
set :logrotate_name, "backgroundrb_#{application}"
|
|
19
|
+
set :logrotate_log_path, backgroundrb_logrotate_path
|
|
20
|
+
set :logrotate_options, [ { :rotate => 2 }, :weekly, :missingok, :notifempty, :copytruncate ]
|
|
21
|
+
|
|
22
|
+
logrotated.install_conf
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
namespace :merb do
|
|
2
|
+
|
|
3
|
+
namespace :logrotate do
|
|
4
|
+
desc <<-DESC
|
|
5
|
+
Install logrotated conf for merb.
|
|
6
|
+
|
|
7
|
+
<dl>
|
|
8
|
+
<dt>merb_logrotate_path</dt>
|
|
9
|
+
<dd>Merb logrotate path</dd>
|
|
10
|
+
<dd class="default">Defaults to @\#{shared_path}/log/merb.*.log@</dd>
|
|
11
|
+
</dl>
|
|
12
|
+
"Source":#{link_to_source(__FILE__)}
|
|
13
|
+
DESC
|
|
14
|
+
task :install do
|
|
15
|
+
fetch_or_default(:merb_logrotate_path, "#{shared_path}/log/merb.*.log")
|
|
16
|
+
|
|
17
|
+
set :logrotate_name, "merb_#{application}"
|
|
18
|
+
set :logrotate_log_path, merb_logrotate_path
|
|
19
|
+
set :logrotate_options, [ { :rotate => 7 }, :daily, :missingok, :notifempty, :copytruncate ]
|
|
20
|
+
|
|
21
|
+
logrotated.install_conf
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
namespace :mongrel do
|
|
2
|
+
|
|
3
|
+
namespace :cluster do
|
|
4
|
+
|
|
5
|
+
namespace :logrotate do
|
|
6
|
+
desc <<-DESC
|
|
7
|
+
Install logrotated conf for mongrel cluster.
|
|
8
|
+
|
|
9
|
+
<dl>
|
|
10
|
+
<dt>mongrel_cluster_logrotate_path</dt>
|
|
11
|
+
<dd>Mongrel cluster logrotate path</dd>
|
|
12
|
+
<dd class="default">Defaults to @\#{shared_path}/log/mongrel_cluster_*.log@</dd>
|
|
13
|
+
</dl>
|
|
14
|
+
"Source":#{link_to_source(__FILE__)}
|
|
15
|
+
DESC
|
|
16
|
+
task :install do
|
|
17
|
+
fetch_or_default(:mongrel_cluster_logrotate_path, "#{shared_path}/log/mongrel_cluster_*.log")
|
|
18
|
+
|
|
19
|
+
set :logrotate_name, "mongrel_cluster_#{application}"
|
|
20
|
+
set :logrotate_log_path, mongrel_cluster_logrotate_path
|
|
21
|
+
set :logrotate_options, [ { :rotate => 7 }, :daily, :missingok, :notifempty, :copytruncate ]
|
|
22
|
+
|
|
23
|
+
logrotated.install_conf
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
namespace :monit do
|
|
2
|
+
|
|
3
|
+
namespace :logrotate do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install logrotated conf for monit.
|
|
7
|
+
|
|
8
|
+
<dl>
|
|
9
|
+
<dt>monit_log_path</dt>
|
|
10
|
+
<dd>Path to monit log</dd>
|
|
11
|
+
<dd class="default">Defaults to @"/var/log/monit.log"@</dd>
|
|
12
|
+
</dl>
|
|
13
|
+
"Source":#{link_to_source(__FILE__)}
|
|
14
|
+
DESC
|
|
15
|
+
task :install do
|
|
16
|
+
|
|
17
|
+
fetch_or_default(:monit_log_path, "/var/log/monit.log")
|
|
18
|
+
|
|
19
|
+
set :logrotate_name, "monit"
|
|
20
|
+
set :logrotate_log_path, monit_log_path
|
|
21
|
+
set :logrotate_options, [ { :rotate => 1, :size => "200k" }, :weekly, :missingok, :notifempty, :copytruncate ]
|
|
22
|
+
|
|
23
|
+
logrotated.install_conf
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
namespace :mysql do
|
|
2
|
+
|
|
3
|
+
namespace :logrotate do
|
|
4
|
+
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install logrotated conf for mysql.
|
|
7
|
+
|
|
8
|
+
<dl>
|
|
9
|
+
<dt>mysql_logrotate_path</dt>
|
|
10
|
+
<dd>Mysql logrotate path</dd>
|
|
11
|
+
<dd class="default">Defaults to @"/var/lib/mysql/localhost-slow.log"@</dd>
|
|
12
|
+
</dl>
|
|
13
|
+
"Source":#{link_to_source(__FILE__)}
|
|
14
|
+
DESC
|
|
15
|
+
task :install do
|
|
16
|
+
fetch_or_default(:mysql_logrotate_path, "/var/lib/mysql/localhost-slow.log")
|
|
17
|
+
|
|
18
|
+
set :logrotate_name, "mysql"
|
|
19
|
+
set :logrotate_log_path, mysql_logrotate_path
|
|
20
|
+
set :logrotate_options, [ { :rotate => 7, :size => "10M" }, :daily, :missingok, :notifempty, :copytruncate ]
|
|
21
|
+
|
|
22
|
+
logrotated.install_conf
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
namespace :nginx do
|
|
2
|
+
|
|
3
|
+
# Logrotate recipes for nginx
|
|
4
|
+
namespace :logrotate do
|
|
5
|
+
|
|
6
|
+
desc <<-DESC
|
|
7
|
+
Install logrotated conf for nginx.
|
|
8
|
+
|
|
9
|
+
*nginx_logrotate_path*: Nginx logrotate path. _Defaults to <tt>/var/log/nginx_*.log</tt>_
|
|
10
|
+
DESC
|
|
11
|
+
task :install do
|
|
12
|
+
fetch_or_default(:nginx_logrotate_path, "/var/log/nginx_*.log")
|
|
13
|
+
|
|
14
|
+
set :logrotate_name, "nginx_main"
|
|
15
|
+
set :logrotate_log_path, nginx_logrotate_path
|
|
16
|
+
set :logrotate_options, [ { :rotate => 2, :size => "10M" }, :daily, :missingok, :notifempty, :copytruncate ]
|
|
17
|
+
|
|
18
|
+
logrotated.install_conf
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc <<-DESC
|
|
22
|
+
Install logrotated conf for vhost.
|
|
23
|
+
|
|
24
|
+
*nginx_vhost_logrotate_path*: Nginx logrotate path (for vhost). _Defaults to <tt>{shared_path}/log/nginx.*.log</tt>_
|
|
25
|
+
DESC
|
|
26
|
+
task :install_vhost do
|
|
27
|
+
fetch_or_default(:nginx_vhost_logrotate_path, "#{shared_path}/log/nginx.*.log")
|
|
28
|
+
|
|
29
|
+
set :logrotate_name, "nginx_#{application}"
|
|
30
|
+
set :logrotate_log_path, nginx_vhost_logrotate_path
|
|
31
|
+
set :logrotate_options, [ { :rotate => 2, :size => "10M" }, :daily, :missingok, :notifempty, :copytruncate ]
|
|
32
|
+
|
|
33
|
+
logrotated.install_conf
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
namespace :rails do
|
|
2
|
+
|
|
3
|
+
# Log rotate tasks
|
|
4
|
+
namespace :logrotate do
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install logrotated conf for rails.
|
|
7
|
+
|
|
8
|
+
*rails_logrotate_path*: Rails logrotate path. _Defaults to <tt>{shared_path}/log/production.log</tt>_
|
|
9
|
+
DESC
|
|
10
|
+
task :install do
|
|
11
|
+
fetch_or_default(:rails_logrotate_path, "#{shared_path}/log/production.log")
|
|
12
|
+
|
|
13
|
+
set :logrotate_name, "rails_#{application}"
|
|
14
|
+
set :logrotate_log_path, rails_logrotate_path
|
|
15
|
+
set :logrotate_options, [ { :rotate => 7, :size => "10M" }, :daily, :missingok, :notifempty, :copytruncate ]
|
|
16
|
+
|
|
17
|
+
logrotated.install_conf
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
namespace :sphinx do
|
|
2
|
+
|
|
3
|
+
# Log rotate tasks
|
|
4
|
+
namespace :logrotate do
|
|
5
|
+
desc <<-DESC
|
|
6
|
+
Install logrotated conf for sphinx.
|
|
7
|
+
|
|
8
|
+
*sphinx_logrotate_path*: Sphinx logrotate paths. _Defaults to <tt>{shared_path}/log/query.log {shared_path}/log/searchd.log</tt>_
|
|
9
|
+
DESC
|
|
10
|
+
task :install do
|
|
11
|
+
fetch_or_default(:sphinx_logrotate_path, "#{shared_path}/log/query.log #{shared_path}/log/searchd.log")
|
|
12
|
+
|
|
13
|
+
set :logrotate_name, "sphinx_#{application}"
|
|
14
|
+
set :logrotate_log_path, sphinx_logrotate_path
|
|
15
|
+
set :logrotate_options, [ { :rotate => 7 }, :daily, :missingok, :notifempty, :copytruncate ]
|
|
16
|
+
|
|
17
|
+
logrotated.install_conf
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
namespace :logrotated do
|
|
3
|
+
|
|
4
|
+
desc <<-DESC
|
|
5
|
+
Create logrotated conf. You probably use this in other recipes and not standalone.
|
|
6
|
+
|
|
7
|
+
"Source":#{link_to_source(__FILE__)}
|
|
8
|
+
DESC
|
|
9
|
+
task_arg(:logrotate_name, "Name of file in /etc/logrotate.d/")
|
|
10
|
+
task_arg(:logrotate_log_path, "Path to log file. Can include wildcards, like /var/log/foo_*.log.")
|
|
11
|
+
task_arg(:logrotate_options, <<-EOS)
|
|
12
|
+
Log rotate options
|
|
13
|
+
|
|
14
|
+
* :rotate (Number of times to rotate before discarding)
|
|
15
|
+
* :size (Rotate when file hits this size)
|
|
16
|
+
* :daily, :weekly, :monthly (How often to perform rotate)
|
|
17
|
+
* :missingok
|
|
18
|
+
* :compress
|
|
19
|
+
* :delaycompress
|
|
20
|
+
* :notifempty
|
|
21
|
+
* :copytruncate
|
|
22
|
+
|
|
23
|
+
See man page for all the options.
|
|
24
|
+
|
|
25
|
+
<pre>
|
|
26
|
+
<code class="ruby">
|
|
27
|
+
set :logrotate_options, [ { :rotate => 7, :size => 10MB },
|
|
28
|
+
:daily, :missingok, :compress, :delaycompress, :notifempty, :copytruncate ]
|
|
29
|
+
</code>
|
|
30
|
+
</pre>
|
|
31
|
+
EOS
|
|
32
|
+
task :install_conf do
|
|
33
|
+
|
|
34
|
+
text = []
|
|
35
|
+
logrotate_options.each do |option|
|
|
36
|
+
if option.is_a?(Hash)
|
|
37
|
+
option.each do |key, value|
|
|
38
|
+
text << "#{key.to_s} #{value.to_s}"
|
|
39
|
+
end
|
|
40
|
+
else
|
|
41
|
+
text << option.to_s
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
set :logrotate_options_text, " " + text.join("\n ")
|
|
45
|
+
|
|
46
|
+
utils.install_template("logrotated/conf.erb", "/etc/logrotate.d/#{logrotate_name}")
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
desc <<-DESC
|
|
51
|
+
Force rotate files.
|
|
52
|
+
|
|
53
|
+
"Source":#{link_to_source(__FILE__)}
|
|
54
|
+
DESC
|
|
55
|
+
task_arg(:logrotate_bin_path, "Logrotate bin path", :default => "logrotate", :example => "/usr/local/bin/logrotate")
|
|
56
|
+
task_arg(:logrotate_conf_path, "Path to logrotate conf", :default => "/etc/logrotate.conf")
|
|
57
|
+
task :force do
|
|
58
|
+
run_via "#{logrotate_bin_path} -f #{logrotate_conf_path}"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|