capistrano-cluster 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/capistrano-cluster.gemspec +29 -0
- data/files/Procfile.erb +2 -0
- data/files/apt.conf.d/10periodic +4 -0
- data/files/apt.conf.d/50unattended-upgrades +4 -0
- data/files/database.yml.erb +11 -0
- data/files/etc/hosts.erb +9 -0
- data/files/firewall.erb +8 -0
- data/files/issue.net +11 -0
- data/files/lb-sysctl.conf +24 -0
- data/files/nginx/application.conf.erb +67 -0
- data/files/nginx/lb-application.conf.erb +91 -0
- data/files/nginx/lb-nginx.conf.erb +84 -0
- data/files/nginx/nginx.conf.erb +80 -0
- data/files/pg_hba.conf.erb +10 -0
- data/files/postgresql.conf +19 -0
- data/files/redis/redis.conf +597 -0
- data/files/service.erb +67 -0
- data/files/solr/conf/lang/contractions_ca.txt +8 -0
- data/files/solr/conf/lang/contractions_fr.txt +9 -0
- data/files/solr/conf/lang/contractions_ga.txt +5 -0
- data/files/solr/conf/lang/contractions_it.txt +23 -0
- data/files/solr/conf/lang/hyphenations_ga.txt +5 -0
- data/files/solr/conf/lang/stemdict_nl.txt +6 -0
- data/files/solr/conf/lang/stoptags_ja.txt +420 -0
- data/files/solr/conf/lang/stopwords_ar.txt +125 -0
- data/files/solr/conf/lang/stopwords_bg.txt +193 -0
- data/files/solr/conf/lang/stopwords_ca.txt +220 -0
- data/files/solr/conf/lang/stopwords_cz.txt +172 -0
- data/files/solr/conf/lang/stopwords_da.txt +108 -0
- data/files/solr/conf/lang/stopwords_de.txt +292 -0
- data/files/solr/conf/lang/stopwords_el.txt +78 -0
- data/files/solr/conf/lang/stopwords_en.txt +54 -0
- data/files/solr/conf/lang/stopwords_es.txt +354 -0
- data/files/solr/conf/lang/stopwords_eu.txt +99 -0
- data/files/solr/conf/lang/stopwords_fa.txt +313 -0
- data/files/solr/conf/lang/stopwords_fi.txt +95 -0
- data/files/solr/conf/lang/stopwords_fr.txt +183 -0
- data/files/solr/conf/lang/stopwords_ga.txt +110 -0
- data/files/solr/conf/lang/stopwords_gl.txt +161 -0
- data/files/solr/conf/lang/stopwords_hi.txt +235 -0
- data/files/solr/conf/lang/stopwords_hu.txt +209 -0
- data/files/solr/conf/lang/stopwords_hy.txt +46 -0
- data/files/solr/conf/lang/stopwords_id.txt +359 -0
- data/files/solr/conf/lang/stopwords_it.txt +301 -0
- data/files/solr/conf/lang/stopwords_ja.txt +127 -0
- data/files/solr/conf/lang/stopwords_lv.txt +172 -0
- data/files/solr/conf/lang/stopwords_nl.txt +117 -0
- data/files/solr/conf/lang/stopwords_no.txt +192 -0
- data/files/solr/conf/lang/stopwords_pt.txt +251 -0
- data/files/solr/conf/lang/stopwords_ro.txt +233 -0
- data/files/solr/conf/lang/stopwords_ru.txt +241 -0
- data/files/solr/conf/lang/stopwords_sv.txt +131 -0
- data/files/solr/conf/lang/stopwords_th.txt +119 -0
- data/files/solr/conf/lang/stopwords_tr.txt +212 -0
- data/files/solr/conf/lang/userdict_ja.txt +29 -0
- data/files/solr/conf/mapping-FoldToASCII.txt +3813 -0
- data/files/solr/conf/schema.xml +111 -0
- data/files/solr/conf/solrconfig.xml +59 -0
- data/files/solr/conf/stopwords.txt +14 -0
- data/files/solr/solr.xml +45 -0
- data/files/ssh/authorized_keys.erb +4 -0
- data/files/ssh/config +3 -0
- data/files/sshd_config +40 -0
- data/files/tmux.conf +136 -0
- data/files/ufw +44 -0
- data/files/unicorn.rb.erb +63 -0
- data/lib/capistrano/cluster/application.rb +75 -0
- data/lib/capistrano/cluster/core_ext/object.rb +17 -0
- data/lib/capistrano/cluster/files.rb +57 -0
- data/lib/capistrano/cluster/packages.rb +62 -0
- data/lib/capistrano/cluster/paths.rb +18 -0
- data/lib/capistrano/cluster/service.rb +70 -0
- data/lib/capistrano/cluster/version.rb +5 -0
- data/lib/capistrano/cluster.rb +35 -0
- data/tasks/deploy/application.rake +48 -0
- data/tasks/deploy.rake +71 -0
- data/tasks/roles/app.rake +71 -0
- data/tasks/roles/cache.rake +16 -0
- data/tasks/roles/db.rake +66 -0
- data/tasks/roles/indexer.rake +132 -0
- data/tasks/roles/proxy.rake +59 -0
- data/tasks/roles/rabbit.rake +52 -0
- data/tasks/roles/resque.rake +96 -0
- data/tasks/roles/sidekiq.rake +42 -0
- data/tasks/roles/web.rake +64 -0
- data/tasks/setup/firewall.rake +53 -0
- data/tasks/setup.rake +96 -0
- metadata +221 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
set :proxy_files, fetch(:proxy_files,{})
|
2
|
+
namespace :setup do
|
3
|
+
|
4
|
+
task :proxy do
|
5
|
+
|
6
|
+
on roles(:proxy) do
|
7
|
+
|
8
|
+
install "nginx"
|
9
|
+
|
10
|
+
upload_as :root, file("lb-sysctl.conf"), "/etc/sysctl.d/20-web.conf"
|
11
|
+
sudo :sysctl, "-p", "/etc/sysctl.d/20-web.conf"
|
12
|
+
sudo :mkdir, "-p", "/etc/nginx/servers"
|
13
|
+
upload_as :root, file("nginx/lb-nginx.conf", user: fetch(:user)), "/etc/nginx/nginx.conf", mode: 644
|
14
|
+
|
15
|
+
sudo :rm, "-f", *%w[fastcgi_params proxy_params scgi_params uwsgi_params].map { |file| file.prepend("/etc/nginx/") }
|
16
|
+
sudo :rm, "-rf", *%w[sites-available sites-enabled conf.d].map { |file| file.prepend("/etc/nginx/") }
|
17
|
+
|
18
|
+
sudo "bash -c 'nginx -s reload || service nginx restart'"
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
after "setup:system", "setup:proxy"
|
27
|
+
|
28
|
+
namespace :deploy do
|
29
|
+
|
30
|
+
namespace :application do
|
31
|
+
|
32
|
+
task :proxy do
|
33
|
+
|
34
|
+
on roles(:proxy) do
|
35
|
+
|
36
|
+
shared_path = Pathname.new("/etc/nginx/servers/#{fetch(:application)}-#{fetch(:framework_env)}")
|
37
|
+
|
38
|
+
sudo :mkdir, '-p', shared_path
|
39
|
+
sudo :chown, "-R", fetch(:user), shared_path
|
40
|
+
|
41
|
+
if ssl_certificate = fetch(:ssl_certificate)
|
42
|
+
upload_as :root, StringIO.new(ssl_certificate), shared_path.join("ssl.pem")
|
43
|
+
end
|
44
|
+
|
45
|
+
fetch(:proxy_files).each_pair do |file, remote_file|
|
46
|
+
upload_as :root, file(file), shared_path.join(remote_file)
|
47
|
+
end
|
48
|
+
|
49
|
+
upload_as :root, file("nginx/lb-application.conf", ssl: ssl_certificate), shared_path.join("nginx.conf")
|
50
|
+
|
51
|
+
sudo "bash -c 'nginx -s reload || service nginx restart'"
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
namespace :setup do
|
3
|
+
|
4
|
+
before :package_sources, :"rabbitmq:sources"
|
5
|
+
|
6
|
+
|
7
|
+
namespace :rabbitmq do
|
8
|
+
task :sources do
|
9
|
+
|
10
|
+
on roles(:rabbitmq) do
|
11
|
+
unless test "[ -f /etc/apt/sources.list.d/rabbitmq.list ]"
|
12
|
+
execute %q[wget --quiet -O - http://www.rabbitmq.com/rabbitmq-signing-key-public.asc | sudo apt-key add -]
|
13
|
+
upload_as :root, StringIO.new("deb http://www.rabbitmq.com/debian/ testing main"), "/etc/apt/sources.list.d/rabbitmq.list"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
task :rabbitmq do
|
21
|
+
|
22
|
+
on roles(:rabbitmq) do
|
23
|
+
install "rabbitmq-server"
|
24
|
+
upload_as :rabbitmq, StringIO.new("[rabbitmq_management,rabbitmq_management_visualiser,rabbitmq_stomp,rabbitmq_amqp1_0,rabbitmq_mqtt]."), "/etc/rabbitmq/enabled_plugins"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
after "setup:system", "setup:rabbitmq"
|
32
|
+
|
33
|
+
|
34
|
+
namespace :deploy do
|
35
|
+
task :rabbitmq do
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
namespace :firewall do
|
40
|
+
task :rabbitmq do
|
41
|
+
on roles(:rabbitmq) do |server|
|
42
|
+
sudo :ufw, :allow, :in, :epmd
|
43
|
+
sudo :ufw, :allow, :in, :amqp
|
44
|
+
sudo :ufw, :allow, :in, :'25672'
|
45
|
+
sudo :ufw, :allow, :in, :'15672'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
before "deploy:publishing", "deploy:rabbitmq"
|
52
|
+
after "setup:firewall", "firewall:rabbitmq"
|
@@ -0,0 +1,96 @@
|
|
1
|
+
|
2
|
+
namespace :deploy do
|
3
|
+
before :starting, "deploy:resque:deployment_hooks"
|
4
|
+
|
5
|
+
namespace :resque do
|
6
|
+
|
7
|
+
task :deployment_hooks do
|
8
|
+
after 'deploy:starting', 'deploy:resque:stop'
|
9
|
+
after 'deploy:updated', 'deploy:resque:update'
|
10
|
+
after 'deploy:reverted', 'deploy:resque:stop'
|
11
|
+
after 'deploy:published', 'deploy:resque:start'
|
12
|
+
end
|
13
|
+
|
14
|
+
task :stop do
|
15
|
+
on roles(:resque) do
|
16
|
+
service = [fetch(:application), fetch(:stage), 'resque', '*'].join("-")
|
17
|
+
execute :find, "/etc/init.d", "-type f", "-name #{service}", "-exec {} stop \\;"
|
18
|
+
end
|
19
|
+
on primary :resque_scheduler do
|
20
|
+
execute "/etc/init.d/#{fetch(:application)}-scheduler stop || true"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
task update: :stop do
|
27
|
+
on roles(:resque) do |host|
|
28
|
+
|
29
|
+
match = [fetch(:application), fetch(:stage), 'resque', '*'].join("-")
|
30
|
+
sudo :find, "/etc/init.d", "-type f", "-name '#{match}'", "-exec rm -f {} \\;"
|
31
|
+
|
32
|
+
if test "[ -f /etc/init/#{fetch(:application)}-worker.conf ]"
|
33
|
+
sudo "stop '#{fetch(:application)}-worker' || true"
|
34
|
+
sudo "rm -f /etc/init/#{fetch(:application)}-worker*.conf"
|
35
|
+
end
|
36
|
+
|
37
|
+
host.properties.workers.to_i.times do |worker_id|
|
38
|
+
|
39
|
+
service_name = [fetch(:application), fetch(:stage), 'resque', worker_id].join("-")
|
40
|
+
service service_name do
|
41
|
+
user fetch(:user)
|
42
|
+
working_dir release_path
|
43
|
+
|
44
|
+
pid_file shared_path.join("tmp/pids/resque-#{worker_id}.pid")
|
45
|
+
log_file shared_path.join("log/resque-#{worker_id}.log")
|
46
|
+
|
47
|
+
start "bundle exec rake resque:work RAILS_ENV=#{fetch(:framework_env)} 'QUEUE=*' PIDFILE=#{pid_file} INTERVAL=#{fetch(:resque_interval, 0.1)} LOGFILE=#{log_file}"
|
48
|
+
stop "kill -QUIT $(cat '#{pid_file}')"
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
on primary :resque_scheduler do
|
56
|
+
|
57
|
+
service "#{fetch(:application)}-scheduler" do
|
58
|
+
user fetch(:user)
|
59
|
+
working_dir release_path
|
60
|
+
|
61
|
+
pid_file shared_path.join("tmp/pids/resque-scheduler.pid")
|
62
|
+
log_file shared_path.join("log/resque-scheduler.log")
|
63
|
+
|
64
|
+
start "bundle exec rake environment resque:scheduler RAILS_ENV=#{fetch(:framework_env)} 'QUEUE=*' PIDFILE=#{pid_file} RESQUE_SCHEDULER_INTERVAL=#{fetch(:resque_interval, 0.1)} LOGFILE=#{log_file}"
|
65
|
+
stop "kill -QUIT $(cat '#{pid_file}')"
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
task :start do
|
73
|
+
on roles(:resque) do
|
74
|
+
|
75
|
+
host.properties.workers.to_i.times do |worker_id|
|
76
|
+
service_name = [fetch(:application), fetch(:stage), 'resque', worker_id].join("-")
|
77
|
+
sudo "/etc/init.d/#{service_name}", :start
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
on primary :resque_scheduler do
|
82
|
+
if test "[ -f '/etc/init.d/#{fetch(:application)}-scheduler' ]"
|
83
|
+
sudo "/etc/init.d/#{fetch(:application)}-scheduler", :start
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
task restart: [:stop, :start]
|
90
|
+
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
namespace :deploy do
|
2
|
+
|
3
|
+
before :starting, "deploy:sidekiq:deployment_hooks"
|
4
|
+
|
5
|
+
namespace :sidekiq do
|
6
|
+
task :deployment_hooks do
|
7
|
+
after 'deploy:starting', 'deploy:sidekiq:stop'
|
8
|
+
after 'deploy:updated', 'deploy:sidekiq:update'
|
9
|
+
after 'deploy:reverted', 'deploy:sidekiq:stop'
|
10
|
+
after 'deploy:published', 'deploy:sidekiq:start'
|
11
|
+
end
|
12
|
+
|
13
|
+
task :update do
|
14
|
+
on roles(:sidekiq) do
|
15
|
+
service "#{fetch(:application)}-sidekiq" do
|
16
|
+
user fetch(:user)
|
17
|
+
working_dir current_path
|
18
|
+
start "bundle exec sidekiq -e '#{fetch(:framework_env)}' -C '#{current_path}/config/sidekiq.yml' -L '#{current_path}/log/sidekiq.log' -P '#{current_path}/tmp/pids/sidekiq.pid' #{fetch(:sidekiq_options)}"
|
19
|
+
stop "bundle exec sidekiqctl stop '#{current_path}/tmp/pids/sidekiq.pid' 10"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
task :start do
|
26
|
+
on roles(:sidekiq) do
|
27
|
+
sudo "/etc/init.d/#{fetch(:application)}-sidekiq" , :start
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
task :stop do
|
32
|
+
on roles(:sidekiq) do
|
33
|
+
sudo "/etc/init.d/#{fetch(:application)}-sidekiq stop || true"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
task restart: [:stop, :start]
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
namespace :setup do
|
2
|
+
|
3
|
+
task :web do
|
4
|
+
|
5
|
+
on roles(:web) do
|
6
|
+
install %w[nginx]
|
7
|
+
upload_as :root, file("lb-sysctl.conf"), "/etc/sysctl.d/20-web.conf"
|
8
|
+
sudo :sysctl, "-p", "/etc/sysctl.d/20-web.conf"
|
9
|
+
|
10
|
+
sudo :mkdir, "-p", "/etc/nginx/servers"
|
11
|
+
upload_as :root, file("nginx/nginx.conf", user: fetch(:user)), "/etc/nginx/nginx.conf"
|
12
|
+
sudo :rm, "-f", *%w[fastcgi_params proxy_params scgi_params uwsgi_params].map { |file| file.prepend("/etc/nginx/") }
|
13
|
+
sudo :rm, "-rf", *%w[sites-available sites-enabled conf.d].map { |file| file.prepend("/etc/nginx/") }
|
14
|
+
sudo "nginx -s reload || sudo service nginx restart"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
after "setup:customizations", "setup:web"
|
22
|
+
|
23
|
+
namespace :deploy do
|
24
|
+
|
25
|
+
namespace :application do
|
26
|
+
|
27
|
+
task :web do
|
28
|
+
|
29
|
+
on roles(:web) do |host|
|
30
|
+
|
31
|
+
upload! file("unicorn.rb", instances: host.properties.instances ), shared_path.join("config/unicorn.rb")
|
32
|
+
upload! file("nginx/application.conf"), shared_path.join("config/nginx.conf")
|
33
|
+
|
34
|
+
service "#{fetch(:application)}-web" do
|
35
|
+
user fetch(:user)
|
36
|
+
working_dir current_path
|
37
|
+
start "bundle exec unicorn_rails -E '#{fetch(:framework_env)}' -l '#{shared_path.join("tmp/sockets/nginx.sock")}' -c '#{shared_path.join("config/unicorn.rb")}'"
|
38
|
+
stop "kill -TERM $(cat '#{shared_path.join("tmp/pids/unicorn.pid")}')"
|
39
|
+
reload "kill -USR2 $(cat '#{shared_path.join("tmp/pids/unicorn.pid")}') || start "
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
task :reload do
|
48
|
+
on roles(:web) do
|
49
|
+
sudo "nginx -s reload || sudo service nginx restart"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
namespace :deploy do
|
62
|
+
after :restart, "application:reload"
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
namespace :setup do
|
2
|
+
|
3
|
+
task :firewall do
|
4
|
+
|
5
|
+
def ufw(*rule)
|
6
|
+
sudo :ufw, *rule
|
7
|
+
end
|
8
|
+
|
9
|
+
on roles(:all) do
|
10
|
+
upload_as :root, file("ufw"), "/etc/default/ufw"
|
11
|
+
ufw :allow, "in ssh"
|
12
|
+
end
|
13
|
+
|
14
|
+
on roles(:db) do
|
15
|
+
roles(:app).each do |server|
|
16
|
+
ufw :allow, "proto tcp from #{server.hostname} to any port postgresql"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
on roles(:indexer) do
|
21
|
+
roles(:app).each do |server|
|
22
|
+
ufw :allow, "proto tcp from #{server.hostname} to any port 8983"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
on roles(:cache) do
|
27
|
+
roles(:app).each do |server|
|
28
|
+
ufw :allow, "proto tcp from #{server.hostname} to any port 6379"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
on roles(:web) do
|
33
|
+
roles(:proxy).each do |server|
|
34
|
+
ufw :allow, "proto tcp from #{server.hostname} to any port http"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
on roles(:proxy).each do |server|
|
40
|
+
ufw :allow, "in http"
|
41
|
+
ufw :allow, "in https"
|
42
|
+
end
|
43
|
+
|
44
|
+
on roles(:all) do
|
45
|
+
execute :yes, "| sudo ufw enable"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
before "setup:finished", "setup:firewall"
|
data/tasks/setup.rake
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
|
2
|
+
set :default_packages, %w{tmux htop vim-nox software-properties-common curl wget unattended-upgrades bash-completion git lsof ufw ngrep}
|
3
|
+
set :packages, fetch(:packages, [])
|
4
|
+
|
5
|
+
desc "Bootstraps the servers"
|
6
|
+
task prepare: %w{setup:system setup:finished}
|
7
|
+
|
8
|
+
|
9
|
+
namespace :setup do
|
10
|
+
|
11
|
+
task system: [:hostname, :swap, :users, :package_sources, :packages, :customizations]
|
12
|
+
|
13
|
+
task :users do
|
14
|
+
on roles(:all) do |host|
|
15
|
+
|
16
|
+
login_as(:root, on: host) do
|
17
|
+
user = fetch(:user)
|
18
|
+
|
19
|
+
unless test "id -u #{user}"
|
20
|
+
execute :useradd, "--home", "/home/#{user}", "-m", "--shell", "/bin/bash", user
|
21
|
+
execute :mkdir, "-p", "#{home_path}/.ssh"
|
22
|
+
execute :chmod, "0700", "#{home_path}/.ssh"
|
23
|
+
execute :chown, "-R", "#{user}:#{user}", "#{home_path}"
|
24
|
+
upload! StringIO.new("#{user} ALL=NOPASSWD:ALL"), "/etc/sudoers.d/#{user}"
|
25
|
+
end
|
26
|
+
|
27
|
+
upload! file('ssh/authorized_keys', keys: fetch(:deploy_keys,[])), "#{home_path}/.ssh/authorized_keys"
|
28
|
+
upload! file('ssh/config', keys: fetch(:deploy_keys,[])), "#{home_path}/.ssh/config"
|
29
|
+
execute :chmod, "0600", "#{home_path}/.ssh/authorized_keys #{home_path}/.ssh/config"
|
30
|
+
execute :chown, "#{user}:#{user}", "#{home_path}/.ssh/authorized_keys #{home_path}/.ssh/config"
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
task :finished
|
39
|
+
|
40
|
+
task :hostname do
|
41
|
+
|
42
|
+
on roles(:all) do |host|
|
43
|
+
login_as :root, on: host do
|
44
|
+
unless (hostname = capture(:hostname).strip).empty?
|
45
|
+
upload_as :root, file("etc/hosts", hostname: hostname), "/etc/hosts"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
task :packages do
|
53
|
+
|
54
|
+
on roles(:all) do
|
55
|
+
upload_as :root, file("apt.conf.d/10periodic"), "/etc/apt/apt.conf.d/10periodic"
|
56
|
+
upload_as :root, file("apt.conf.d/50unattended-upgrades"), "/etc/apt/apt.conf.d/50unattended-upgrades"
|
57
|
+
packages = fetch(:default_packages,[]) + fetch(:packages,[])
|
58
|
+
install *packages unless packages.empty?
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
task :customizations do
|
64
|
+
on roles(:all) do
|
65
|
+
upload_as :root, file("tmux.conf"), "/etc/tmux.conf"
|
66
|
+
sudo :chmod, "0644", "/etc/tmux.conf"
|
67
|
+
upload_as :root, file("sshd_config"), "/etc/ssh/sshd_config"
|
68
|
+
upload_as :root, file("issue.net"), "/etc/issue.net"
|
69
|
+
sudo :service, 'ssh', 'reload'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
task :swap do
|
74
|
+
on roles(:swap) do
|
75
|
+
if test "[ ! -f /swap ]"
|
76
|
+
sudo "dd if=/dev/zero of=/swap count=$(cat /proc/meminfo | head -1 | awk '{ print $2*2 }') bs=1KB"
|
77
|
+
sudo "mkswap /swap"
|
78
|
+
sudo "swapon /swap"
|
79
|
+
sudo "echo '/swap none swap sw 0 0' >> /etc/fstab "
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
task :package_sources do
|
86
|
+
on roles(:all) do
|
87
|
+
unless test "[ -f /etc/apt/sources.list.d/pgdg.list ]"
|
88
|
+
execute %q[wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -]
|
89
|
+
sudo %q[echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -c | awk '{print $2}'`-pgdg main" >/etc/apt/sources.list.d/pgdg.list]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-cluster
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vlad Verestiuc
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: capistrano
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capistrano-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: capistrano-bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nokogiri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Setup tasks and role additions for capistrano
|
98
|
+
email:
|
99
|
+
- verestiuc.vlad@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- capistrano-cluster.gemspec
|
110
|
+
- files/Procfile.erb
|
111
|
+
- files/apt.conf.d/10periodic
|
112
|
+
- files/apt.conf.d/50unattended-upgrades
|
113
|
+
- files/database.yml.erb
|
114
|
+
- files/etc/hosts.erb
|
115
|
+
- files/firewall.erb
|
116
|
+
- files/issue.net
|
117
|
+
- files/lb-sysctl.conf
|
118
|
+
- files/nginx/application.conf.erb
|
119
|
+
- files/nginx/lb-application.conf.erb
|
120
|
+
- files/nginx/lb-nginx.conf.erb
|
121
|
+
- files/nginx/nginx.conf.erb
|
122
|
+
- files/pg_hba.conf.erb
|
123
|
+
- files/postgresql.conf
|
124
|
+
- files/redis/redis.conf
|
125
|
+
- files/service.erb
|
126
|
+
- files/solr/conf/lang/contractions_ca.txt
|
127
|
+
- files/solr/conf/lang/contractions_fr.txt
|
128
|
+
- files/solr/conf/lang/contractions_ga.txt
|
129
|
+
- files/solr/conf/lang/contractions_it.txt
|
130
|
+
- files/solr/conf/lang/hyphenations_ga.txt
|
131
|
+
- files/solr/conf/lang/stemdict_nl.txt
|
132
|
+
- files/solr/conf/lang/stoptags_ja.txt
|
133
|
+
- files/solr/conf/lang/stopwords_ar.txt
|
134
|
+
- files/solr/conf/lang/stopwords_bg.txt
|
135
|
+
- files/solr/conf/lang/stopwords_ca.txt
|
136
|
+
- files/solr/conf/lang/stopwords_cz.txt
|
137
|
+
- files/solr/conf/lang/stopwords_da.txt
|
138
|
+
- files/solr/conf/lang/stopwords_de.txt
|
139
|
+
- files/solr/conf/lang/stopwords_el.txt
|
140
|
+
- files/solr/conf/lang/stopwords_en.txt
|
141
|
+
- files/solr/conf/lang/stopwords_es.txt
|
142
|
+
- files/solr/conf/lang/stopwords_eu.txt
|
143
|
+
- files/solr/conf/lang/stopwords_fa.txt
|
144
|
+
- files/solr/conf/lang/stopwords_fi.txt
|
145
|
+
- files/solr/conf/lang/stopwords_fr.txt
|
146
|
+
- files/solr/conf/lang/stopwords_ga.txt
|
147
|
+
- files/solr/conf/lang/stopwords_gl.txt
|
148
|
+
- files/solr/conf/lang/stopwords_hi.txt
|
149
|
+
- files/solr/conf/lang/stopwords_hu.txt
|
150
|
+
- files/solr/conf/lang/stopwords_hy.txt
|
151
|
+
- files/solr/conf/lang/stopwords_id.txt
|
152
|
+
- files/solr/conf/lang/stopwords_it.txt
|
153
|
+
- files/solr/conf/lang/stopwords_ja.txt
|
154
|
+
- files/solr/conf/lang/stopwords_lv.txt
|
155
|
+
- files/solr/conf/lang/stopwords_nl.txt
|
156
|
+
- files/solr/conf/lang/stopwords_no.txt
|
157
|
+
- files/solr/conf/lang/stopwords_pt.txt
|
158
|
+
- files/solr/conf/lang/stopwords_ro.txt
|
159
|
+
- files/solr/conf/lang/stopwords_ru.txt
|
160
|
+
- files/solr/conf/lang/stopwords_sv.txt
|
161
|
+
- files/solr/conf/lang/stopwords_th.txt
|
162
|
+
- files/solr/conf/lang/stopwords_tr.txt
|
163
|
+
- files/solr/conf/lang/userdict_ja.txt
|
164
|
+
- files/solr/conf/mapping-FoldToASCII.txt
|
165
|
+
- files/solr/conf/schema.xml
|
166
|
+
- files/solr/conf/solrconfig.xml
|
167
|
+
- files/solr/conf/stopwords.txt
|
168
|
+
- files/solr/solr.xml
|
169
|
+
- files/ssh/authorized_keys.erb
|
170
|
+
- files/ssh/config
|
171
|
+
- files/sshd_config
|
172
|
+
- files/tmux.conf
|
173
|
+
- files/ufw
|
174
|
+
- files/unicorn.rb.erb
|
175
|
+
- lib/capistrano/cluster.rb
|
176
|
+
- lib/capistrano/cluster/application.rb
|
177
|
+
- lib/capistrano/cluster/core_ext/object.rb
|
178
|
+
- lib/capistrano/cluster/files.rb
|
179
|
+
- lib/capistrano/cluster/packages.rb
|
180
|
+
- lib/capistrano/cluster/paths.rb
|
181
|
+
- lib/capistrano/cluster/service.rb
|
182
|
+
- lib/capistrano/cluster/version.rb
|
183
|
+
- tasks/deploy.rake
|
184
|
+
- tasks/deploy/application.rake
|
185
|
+
- tasks/roles/app.rake
|
186
|
+
- tasks/roles/cache.rake
|
187
|
+
- tasks/roles/db.rake
|
188
|
+
- tasks/roles/indexer.rake
|
189
|
+
- tasks/roles/proxy.rake
|
190
|
+
- tasks/roles/rabbit.rake
|
191
|
+
- tasks/roles/resque.rake
|
192
|
+
- tasks/roles/sidekiq.rake
|
193
|
+
- tasks/roles/web.rake
|
194
|
+
- tasks/setup.rake
|
195
|
+
- tasks/setup/firewall.rake
|
196
|
+
homepage: ''
|
197
|
+
licenses:
|
198
|
+
- MIT
|
199
|
+
metadata: {}
|
200
|
+
post_install_message:
|
201
|
+
rdoc_options: []
|
202
|
+
require_paths:
|
203
|
+
- lib
|
204
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
requirements: []
|
215
|
+
rubyforge_project:
|
216
|
+
rubygems_version: 2.2.2
|
217
|
+
signing_key:
|
218
|
+
specification_version: 4
|
219
|
+
summary: Environment setup automation.
|
220
|
+
test_files: []
|
221
|
+
has_rdoc:
|