ubistrano 1.2.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/MIT-LICENSE +20 -0
- data/README.markdown +162 -0
- data/Rakefile +25 -0
- data/bin/ubify +13 -0
- data/changelog.markdown +54 -0
- data/example/deploy.rb +29 -0
- data/gemspec.rb +19 -0
- data/lib/ubistrano.rb +83 -0
- data/lib/ubistrano/apache.rb +38 -0
- data/lib/ubistrano/deploy.rb +67 -0
- data/lib/ubistrano/ec2.rb +113 -0
- data/lib/ubistrano/gems.rb +29 -0
- data/lib/ubistrano/helpers.rb +287 -0
- data/lib/ubistrano/log.rb +20 -0
- data/lib/ubistrano/mysql.rb +85 -0
- data/lib/ubistrano/rails.rb +76 -0
- data/lib/ubistrano/sinatra.rb +20 -0
- data/lib/ubistrano/ssh.rb +56 -0
- data/lib/ubistrano/stage.rb +29 -0
- data/lib/ubistrano/ubuntu.rb +273 -0
- data/templates/apache/virtual_host.erb +32 -0
- data/templates/log/rotate.conf.erb +9 -0
- data/templates/rails/database.yml.erb +13 -0
- data/templates/ubuntu/apache.god.erb +31 -0
- data/templates/ubuntu/god.erb +36 -0
- data/templates/ubuntu/god.god.erb +1 -0
- data/templates/ubuntu/iptables.rules.erb +31 -0
- data/templates/ubuntu/mysql.god.erb +31 -0
- data/templates/ubuntu/sshd.god.erb +31 -0
- data/ubistrano.gemspec +32 -0
- metadata +93 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
namespace :log do
|
4
|
+
desc "Add logrotate entry for this application"
|
5
|
+
task :rotate, :roles => :app do
|
6
|
+
if yes(msg(:logrotate))
|
7
|
+
upload_from_erb '/etc/rotate.conf', binding, :folder => 'log'
|
8
|
+
sudo_each [
|
9
|
+
'cp -f /etc/logrotate.conf /etc/logrotate2.conf',
|
10
|
+
'chmod 777 /etc/logrotate2.conf',
|
11
|
+
'cat /etc/rotate.conf >> /etc/logrotate2.conf',
|
12
|
+
'cp -f /etc/logrotate2.conf /etc/logrotate.conf',
|
13
|
+
'rm -f /etc/logrotate2.conf',
|
14
|
+
'rm -f /etc/rotate.conf'
|
15
|
+
]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
namespace :mysql do
|
4
|
+
namespace :create do
|
5
|
+
desc "Create database and user"
|
6
|
+
task :default, :roles => :db do
|
7
|
+
mysql.create.user
|
8
|
+
mysql.create.db
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Create database"
|
12
|
+
task :db, :roles => :db do
|
13
|
+
mysql_run "CREATE DATABASE #{db_table}"
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Create database user"
|
17
|
+
task :user, :roles => :db do
|
18
|
+
mysql_run [
|
19
|
+
"CREATE USER '#{application}'@'localhost' IDENTIFIED BY '#{mysql_app_password}'",
|
20
|
+
"GRANT ALL PRIVILEGES ON #{db_table}.* TO '#{application}'@'localhost'"
|
21
|
+
]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :destroy do
|
26
|
+
desc "Destroy database and user"
|
27
|
+
task :default, :roles => :db do
|
28
|
+
mysql.destroy.db
|
29
|
+
mysql.destroy.user
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Destroy database"
|
33
|
+
task :db, :roles => :db do
|
34
|
+
mysql_run "DROP DATABASE #{db_table}"
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Destroy database user"
|
38
|
+
task :user, :roles => :db do
|
39
|
+
mysql_run [
|
40
|
+
"REVOKE ALL PRIVILEGES, GRANT OPTION FROM '#{application}'@'localhost'",
|
41
|
+
"DROP USER '#{application}'@'localhost'"
|
42
|
+
]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
namespace :backup do
|
47
|
+
desc "Upload local backup to remote"
|
48
|
+
task :local_to_server, :roles => :db do
|
49
|
+
from = File.expand_path("backups/#{backup_name}.bz2", FileUtils.pwd)
|
50
|
+
if File.exists?(from)
|
51
|
+
run_each "mkdir -p #{shared_path}/backups"
|
52
|
+
upload from, "#{shared_path}/backups/#{backup_name}.bz2"
|
53
|
+
else
|
54
|
+
puts "Does not exist: #{from}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Restore remote database from backup"
|
59
|
+
task :restore, :roles => :db do
|
60
|
+
run_each "bunzip2 < #{shared_path}/backups/#{backup_name}.bz2 | mysql -u #{application} --password=#{mysql_app_password} #{db_table}"
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Backup database to local"
|
64
|
+
task :to_local, :roles => :db do
|
65
|
+
to_server
|
66
|
+
system "mkdir -p ~/db_backups/#{stage}/#{application}"
|
67
|
+
get "#{shared_path}/db_backups/#{backup_name}.bz2", File.expand_path("~/db_backups/#{stage}/#{application}/#{backup_name}.bz2")
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Backup database to remote"
|
71
|
+
task :to_server, :roles => :db do
|
72
|
+
run_each [
|
73
|
+
"mkdir -p #{shared_path}/db_backups",
|
74
|
+
"mysqldump --add-drop-table -u #{application} -p#{mysql_app_password} #{db_table} | bzip2 -c > #{shared_path}/db_backups/#{backup_name}.bz2"
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
78
|
+
def backup_name
|
79
|
+
now = Time.now
|
80
|
+
[ now.year, now.month, now.day ].join('-') + '.sql'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
namespace :rails do
|
4
|
+
namespace :config do
|
5
|
+
desc "Creates database.yml in the shared config"
|
6
|
+
task :default, :roles => :app do
|
7
|
+
run "mkdir -p #{shared_path}/config"
|
8
|
+
Dir[File.expand_path('../../templates/rails/*', File.dirname(__FILE__))].each do |f|
|
9
|
+
upload_from_erb "#{shared_path}/config/#{File.basename(f, '.erb')}", binding, :folder => 'rails'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Set up app with app_helpers"
|
14
|
+
task :app_helpers do
|
15
|
+
run "cd #{release_path} && script/plugin install git://github.com/winton/app_helpers.git"
|
16
|
+
run "cd #{release_path} && rake RAILS_ENV=production quiet=true app_helpers"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Configure attachment_fu"
|
20
|
+
task :attachment_fu, :roles => :app do
|
21
|
+
run_each [
|
22
|
+
"mkdir -p #{shared_path}/media",
|
23
|
+
"ln -sf #{shared_path}/media #{release_path}/public/media"
|
24
|
+
]
|
25
|
+
sudo_each [
|
26
|
+
"mkdir -p #{release_path}/tmp/attachment_fu",
|
27
|
+
"chown -R #{user} #{release_path}/tmp/attachment_fu"
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Configure asset_packager"
|
32
|
+
task :asset_packager do
|
33
|
+
run "cd #{release_path} && rake RAILS_ENV=production asset:packager:build_all"
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Configure rails_widget"
|
37
|
+
task :rails_widget, :roles => :app do
|
38
|
+
run "cd #{release_path} && rake RAILS_ENV=production widget:production"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Copies yml files in the shared config folder into our app config"
|
42
|
+
task :to_app, :roles => :app do
|
43
|
+
run "cp -Rf #{shared_path}/config/* #{release_path}/config"
|
44
|
+
end
|
45
|
+
|
46
|
+
namespace :thinking_sphinx do
|
47
|
+
desc "Configures thinking_sphinx"
|
48
|
+
task :default, :roles => :app do
|
49
|
+
sudo ";cd #{release_path} && rake RAILS_ENV=production ts:config"
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Stop thinking_sphinx"
|
53
|
+
task :stop, :roles => :app do
|
54
|
+
sudo ";cd #{release_path} && rake RAILS_ENV=production ts:stop"
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Start thinking_sphinx"
|
58
|
+
task :start, :roles => :app do
|
59
|
+
sudo ";cd #{release_path} && rake RAILS_ENV=production ts:start"
|
60
|
+
end
|
61
|
+
|
62
|
+
desc "Restart thinking_sphinx"
|
63
|
+
task :restart, :roles => :app do
|
64
|
+
rails.config.thinking_sphinx.stop
|
65
|
+
rails.config.thinking_sphinx.start
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Intialize Git submodules"
|
71
|
+
task :setup_git, :roles => :app do
|
72
|
+
run "cd #{release_path}; git submodule init; git submodule update"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
namespace :sinatra do
|
4
|
+
namespace :config do
|
5
|
+
desc "Creates config.ru in shared config"
|
6
|
+
task :default do
|
7
|
+
run "mkdir -p #{shared_path}/config"
|
8
|
+
Dir[File.expand_path('../../templates/rails/*', File.dirname(__FILE__))].each do |f|
|
9
|
+
upload_from_erb "#{shared_path}/config/#{File.basename(f, '.erb')}", binding, :folder => 'rails'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Copies yml files in the shared config folder into our app config"
|
14
|
+
task :to_app, :roles => :app do
|
15
|
+
run "cp -Rf #{shared_path}/config/* #{release_path}/config"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
namespace :ssh do
|
4
|
+
desc 'Generate ssh keys and upload to server'
|
5
|
+
task :default do
|
6
|
+
ssh.keys.create.local
|
7
|
+
ssh.keys.upload
|
8
|
+
ssh.keys.create.remote
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :keys do
|
12
|
+
namespace :create do
|
13
|
+
desc "Creates an rsa ssh key pair (local)"
|
14
|
+
task :local do
|
15
|
+
system('ssh-keygen -t rsa') if yes(msg(:create_keys))
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Creates an rsa ssh key pair (remote)"
|
19
|
+
task :remote do
|
20
|
+
if yes(msg(:create_server_keys))
|
21
|
+
pass = ask "Enter a password for this key:"
|
22
|
+
sudo_each [
|
23
|
+
"ssh-keygen -t rsa -N '#{pass}' -q -f /home/#{user}/.ssh/id_rsa",
|
24
|
+
"chmod 0700 /home/#{user}/.ssh",
|
25
|
+
"chown -R #{user} /home/#{user}/.ssh"
|
26
|
+
]
|
27
|
+
sudo_puts "tail -1 /home/#{user}/.ssh/id_rsa.pub"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Uploads local ssh public keys into remote authorized_keys"
|
33
|
+
task :upload do
|
34
|
+
if yes(msg(:upload_keys))
|
35
|
+
key = ask msg(:upload_keys_2)
|
36
|
+
key = get_ssh_key key
|
37
|
+
if key.nil?
|
38
|
+
ssh.setup if yes("No keys found. Generate ssh keys now?")
|
39
|
+
else
|
40
|
+
sudo_each [
|
41
|
+
"mkdir -p /home/#{user}/.ssh",
|
42
|
+
"touch /home/#{user}/.ssh/authorized_keys"
|
43
|
+
]
|
44
|
+
add_line "/home/#{user}/.ssh/authorized_keys", key
|
45
|
+
sudo_each [
|
46
|
+
"chmod 0700 /home/#{user}/.ssh",
|
47
|
+
"chmod 0600 /home/#{user}/.ssh/authorized_keys",
|
48
|
+
"chown -R #{user} /home/#{user}/.ssh"
|
49
|
+
]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
desc 'Set the target stage to staging'
|
4
|
+
task :staging do
|
5
|
+
set :stage, :staging
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Set the target stage to test'
|
9
|
+
task :testing do
|
10
|
+
set :stage, :test
|
11
|
+
end
|
12
|
+
|
13
|
+
# None of this works in a namespace
|
14
|
+
desc 'Set up stage-dependent properties'
|
15
|
+
task :setup_stage do
|
16
|
+
set :base_dir, "#{ubistrano[:base_dir]}/#{stage}"
|
17
|
+
set :deploy_to, "#{base_dir}/#{application}"
|
18
|
+
set :db_table, "#{application}#{stage == :staging ? "_#{stage}" : ''}"
|
19
|
+
|
20
|
+
ubistrano[stage].each do |key, value|
|
21
|
+
set key, value
|
22
|
+
end
|
23
|
+
|
24
|
+
role :app, host, :primary => true
|
25
|
+
role :web, host, :primary => true
|
26
|
+
role :db, host, :primary => true
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,273 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
namespace :ubuntu do
|
4
|
+
desc "Set up a fresh Ubuntu server"
|
5
|
+
task :default do
|
6
|
+
puts space(msg(:about_templates))
|
7
|
+
exit unless yes(msg(:visudo))
|
8
|
+
if yes("Create the remote deploy user?")
|
9
|
+
exit unless yes(msg(:add_user))
|
10
|
+
end
|
11
|
+
ssh.default
|
12
|
+
ubuntu.config.default
|
13
|
+
ubuntu.aptitude.default
|
14
|
+
puts space(msg(:run_ubuntu_install))
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Restart Ubuntu server"
|
18
|
+
task :restart do
|
19
|
+
if yes(msg(:ubuntu_restart))
|
20
|
+
sudo_each 'shutdown -r now'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :aptitude do
|
25
|
+
desc 'Run all aptitude tasks'
|
26
|
+
task :default do
|
27
|
+
if yes(msg(:aptitude_default))
|
28
|
+
aptitude.update
|
29
|
+
aptitude.upgrade
|
30
|
+
aptitude.essential
|
31
|
+
ubuntu.restart
|
32
|
+
else
|
33
|
+
exit unless yes(msg(:aptitude_instructions))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Aptitude update'
|
38
|
+
task :update do
|
39
|
+
sudo_puts 'aptitude update -q -y'
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'Aptitude upgrade'
|
43
|
+
task :upgrade do
|
44
|
+
sudo_puts 'aptitude upgrade -q -y'
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Aptitude install build-essential'
|
48
|
+
task :essential do
|
49
|
+
sudo_puts 'aptitude install build-essential -q -y'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
namespace :config do
|
54
|
+
desc 'Run all tasks'
|
55
|
+
task :default do
|
56
|
+
ubuntu.config.sshd_config
|
57
|
+
ubuntu.config.ssh_config
|
58
|
+
ubuntu.config.iptables
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Updates server iptables"
|
62
|
+
task :iptables do
|
63
|
+
if yes(msg(:iptables))
|
64
|
+
upload_from_erb '/etc/iptables.rules', binding, :folder => 'ubuntu'
|
65
|
+
sudo_each [
|
66
|
+
'iptables-restore < /etc/iptables.rules',
|
67
|
+
'rm /etc/iptables.rules'
|
68
|
+
]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "Updates sshd_config"
|
73
|
+
task :sshd_config do
|
74
|
+
if yes(msg(:sshd_config))
|
75
|
+
set :ssh_port, port
|
76
|
+
set :port, 22
|
77
|
+
change_line '/etc/ssh/sshd_config', 'Port 22', "Port #{port}"
|
78
|
+
change_line '/etc/ssh/sshd_config', 'PermitRootLogin yes', 'PermitRootLogin no'
|
79
|
+
change_line '/etc/ssh/sshd_config', 'X11Forwarding yes', 'X11Forwarding no'
|
80
|
+
change_line '/etc/ssh/sshd_config', 'UsePAM yes', 'UsePAM no'
|
81
|
+
remove_line '/etc/ssh/sshd_config', 'UseDNS .*'
|
82
|
+
add_line '/etc/ssh/sshd_config', 'UseDNS no'
|
83
|
+
remove_line '/etc/ssh/sshd_config', 'StrictHostKeyChecking .*'
|
84
|
+
sudo_puts '/etc/init.d/ssh reload'
|
85
|
+
set :port, ssh_port
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Updates ssh_config"
|
90
|
+
task :ssh_config do
|
91
|
+
if yes(msg(:ssh_config))
|
92
|
+
remove_line '/etc/ssh/ssh_config', 'StrictHostKeyChecking .*'
|
93
|
+
add_line '/etc/ssh/ssh_config', 'StrictHostKeyChecking no'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
namespace :install do
|
99
|
+
desc 'Run all install tasks'
|
100
|
+
task :default do
|
101
|
+
ubuntu.install.apache
|
102
|
+
ubuntu.install.git
|
103
|
+
ubuntu.install.mysql
|
104
|
+
ubuntu.install.mysqltuner
|
105
|
+
ubuntu.install.perl
|
106
|
+
ubuntu.install.php
|
107
|
+
ubuntu.install.postfix
|
108
|
+
ubuntu.install.ruby
|
109
|
+
ubuntu.install.rubygems
|
110
|
+
ubuntu.install.passenger
|
111
|
+
ubuntu.install.god
|
112
|
+
ubuntu.install.rails
|
113
|
+
ubuntu.install.sinatra
|
114
|
+
ubuntu.install.sphinx
|
115
|
+
ubuntu.restart
|
116
|
+
puts space(msg(:ubuntu_finished))
|
117
|
+
end
|
118
|
+
|
119
|
+
desc 'Install Apache'
|
120
|
+
task :apache, :roles => :web do
|
121
|
+
if yes("May I install Apache?")
|
122
|
+
sudo_puts [
|
123
|
+
'aptitude install apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapr1 libaprutil1 ssl-cert apache2-prefork-dev -q -y',
|
124
|
+
'a2enmod rewrite',
|
125
|
+
'a2enmod ssl',
|
126
|
+
'a2dissite default'
|
127
|
+
]
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
desc 'Install Git'
|
132
|
+
task :git, :roles => :app do
|
133
|
+
install_source(:git) do |path|
|
134
|
+
sudo_puts [
|
135
|
+
'apt-get build-dep git-core -q -y',
|
136
|
+
make_install(path)
|
137
|
+
]
|
138
|
+
end if yes("May I install Git?")
|
139
|
+
end
|
140
|
+
|
141
|
+
desc 'Install MySQL'
|
142
|
+
task :mysql, :roles => :db do
|
143
|
+
if yes("May I install MySQL?")
|
144
|
+
sudo_puts 'aptitude install mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 libmysqlclient15-dev libmysqlclient15off -q -y'
|
145
|
+
sudo "mysqladmin -u root password #{mysql_root_password || ''}"
|
146
|
+
exit unless yes(msg(:secure_mysql))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
desc "Install MySQLTuner"
|
151
|
+
task :mysqltuner, :roles => :db do
|
152
|
+
if yes(msg(:mysqltuner))
|
153
|
+
bin = "/usr/local/bin"
|
154
|
+
run_each [
|
155
|
+
"cd #{bin} && sudo wget --quiet #{sources[:mysqltuner]}",
|
156
|
+
"cd #{bin} && sudo chmod 0700 mysqltuner.pl",
|
157
|
+
"cd #{bin} && sudo mv mysqltuner.pl mysqltuner"
|
158
|
+
]
|
159
|
+
exit unless yes(msg(:mysqltuner_instructions))
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
desc 'Install Perl'
|
164
|
+
task :perl, :roles => :web do
|
165
|
+
if yes("May I install Perl?")
|
166
|
+
sudo_puts 'aptitude install libdbi-perl libnet-daemon-perl libplrpc-perl libdbd-mysql-perl -q -y'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
desc 'Install PHP'
|
171
|
+
task :php, :roles => :web do
|
172
|
+
if yes("May I install PHP?")
|
173
|
+
sudo_puts 'aptitude install php5-common php5-mysql libapache2-mod-php5 php-pear php-mail php-net-smtp -q -y'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
desc 'Install Postfix'
|
178
|
+
task :postfix, :roles => :web do
|
179
|
+
if yes("May I install Postfix and set it up as a relay?")
|
180
|
+
smtp = ask 'What is your SMTP server address?'
|
181
|
+
login = ask 'What is your SMTP server username?'
|
182
|
+
pass = ask 'What is your SMTP server password?'
|
183
|
+
sudo_puts 'aptitude install postfix -q -y'
|
184
|
+
add_line '/etc/postfix/main.cf',
|
185
|
+
'smtp_sasl_auth_enable = yes',
|
186
|
+
'smtp_sasl_security_options = noanonymous',
|
187
|
+
'smtp_sasl_password_maps = hash:/etc/postfix/saslpasswd',
|
188
|
+
'smtp_always_send_ehlo = yes',
|
189
|
+
"relayhost = #{smtp}"
|
190
|
+
sudo_each 'touch /etc/postfix/saslpasswd'
|
191
|
+
add_line '/etc/postfix/saslpasswd', "#{smtp} #{login}:#{pass}"
|
192
|
+
sudo_each [
|
193
|
+
'postmap /etc/postfix/saslpasswd',
|
194
|
+
'/etc/init.d/postfix restart'
|
195
|
+
]
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
desc 'Install Ruby'
|
200
|
+
task :ruby, :roles => :app do
|
201
|
+
if yes("May I install Ruby?")
|
202
|
+
sudo_puts "aptitude install libopenssl-ruby -q -y"
|
203
|
+
install_source(:ruby) do |path|
|
204
|
+
sudo_puts make_install(path)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
desc 'Install RubyGems'
|
210
|
+
task :rubygems, :roles => :app do
|
211
|
+
if yes("May I install RubyGems?")
|
212
|
+
install_source(:rubygems) do |path|
|
213
|
+
run_puts "cd #{path} && sudo ruby setup.rb"
|
214
|
+
end
|
215
|
+
gems.update
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
desc 'Install Passenger'
|
220
|
+
task :passenger, :roles => :app do
|
221
|
+
if yes("May I install Passenger (mod_rails)?")
|
222
|
+
gem_install :passenger
|
223
|
+
ROOT.apache.reload if yes(msg(:passenger))
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
desc 'Install God'
|
228
|
+
task :god, :roles => :app do
|
229
|
+
if yes(msg(:god))
|
230
|
+
gem_install 'god'
|
231
|
+
upload_from_erb '/etc/init.d/god', binding, :folder => 'ubuntu'
|
232
|
+
sudo_each [
|
233
|
+
';cd /etc/init.d && sudo chmod +x god',
|
234
|
+
'mkdir -p /usr/local/etc/god'
|
235
|
+
]
|
236
|
+
upload_from_erb('/usr/local/etc/god.god', binding, :folder => 'ubuntu')
|
237
|
+
upload_from_erb('/usr/local/etc/god/apache.god', binding, :folder => 'ubuntu') if yes(msg(:god_apache))
|
238
|
+
upload_from_erb('/usr/local/etc/god/mysql.god', binding, :folder => 'ubuntu') if yes(msg(:god_mysql))
|
239
|
+
upload_from_erb('/usr/local/etc/god/sshd.god', binding, :folder => 'ubuntu') if yes(msg(:god_sshd))
|
240
|
+
sudo_puts [
|
241
|
+
'update-rc.d god defaults'
|
242
|
+
]
|
243
|
+
exit unless yes(msg(:god_finished))
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
desc 'Install Rails'
|
248
|
+
task :rails, :roles => :app do
|
249
|
+
if yes("May I install Rails?")
|
250
|
+
gem_install :mysql
|
251
|
+
gem_install :rails
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
desc 'Install Sinatra'
|
256
|
+
task :sinatra, :roles => :app do
|
257
|
+
if yes("May I install Sinatra?")
|
258
|
+
gem_install :do_mysql # Datamapper
|
259
|
+
gem_install 'dm-core'
|
260
|
+
gem_install :sinatra # Sinatra
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
desc 'Install Sphinx'
|
265
|
+
task :sphinx, :roles => :app do
|
266
|
+
install_source(:sphinx) do |path|
|
267
|
+
sudo_puts make_install(path)
|
268
|
+
end if yes("May I install Sphinx?")
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|