winton-cookbook 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/recipes/debian.rb ADDED
@@ -0,0 +1,200 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :debian do
4
+ desc "Configure and install a fresh Debian server"
5
+ task :default do
6
+ if yes("Have you created the user defined in config/deploy.rb? (See vendor/plugins/cookbook/README)")
7
+ debian.aptitude.default
8
+ debian.config.default
9
+ debian.install.default
10
+ end
11
+ end
12
+
13
+ namespace :aptitude do
14
+ desc 'Run all tasks'
15
+ task :default do
16
+ aptitude.update
17
+ aptitude.upgrade
18
+ aptitude.essential
19
+ end
20
+
21
+ desc 'Aptitude update'
22
+ task :update do
23
+ sudo_puts 'aptitude update -q -y'
24
+ end
25
+
26
+ desc 'Aptitude upgrade'
27
+ task :upgrade do
28
+ sudo_puts 'aptitude upgrade -q -y'
29
+ end
30
+
31
+ desc 'Aptitude install build-essential'
32
+ task :essential do
33
+ sudo_puts 'aptitude install build-essential -q -y'
34
+ end
35
+ end
36
+
37
+ namespace :config do
38
+ desc 'Run all tasks'
39
+ task :default do
40
+ debian.config.sshd_config
41
+ debian.config.iptables
42
+ debian.config.locales
43
+ debian.config.bash_profile
44
+ end
45
+
46
+ desc "Uploads the bash_profile file in config/cookbook"
47
+ task :bash_profile do
48
+ question = [
49
+ "This task uploads the bash_profile file in config/cookbook.",
50
+ "OK?"
51
+ ]
52
+ if yes(question)
53
+ usr = ask "Update bash_profile for which user? (default: #{user})", user
54
+ upload_from_erb "/home/#{usr}/.bash_profile", binding, :chown => usr, :folder => 'debian'
55
+ end
56
+ end
57
+
58
+ desc "Updates server iptables from the file in config/cookbook"
59
+ task :iptables do
60
+ question = [
61
+ "This task updates your server's iptables with the file in config/cookbook.",
62
+ "OK?"
63
+ ]
64
+ if yes(question)
65
+ upload_from_erb '/etc/iptables.rules', binding, :folder => 'debian'
66
+ sudo_each [
67
+ 'iptables-restore < /etc/iptables.rules',
68
+ 'rm /etc/iptables.rules'
69
+ ]
70
+ end
71
+ end
72
+
73
+ desc "Updates server locales from the file in config/cookbook"
74
+ task :locales do
75
+ question = [
76
+ "This task updates the server's locales from the file in config/cookbook.",
77
+ "OK?"
78
+ ]
79
+ if yes(question)
80
+ upload_from_erb '/etc/locale.gen', binding, :chown => 'root', :chmod => '0644', :folder => 'debian'
81
+ sudo '/usr/sbin/locale-gen'
82
+ end
83
+ end
84
+
85
+ desc "Updates sshd_config from the file in config/cookbook"
86
+ task :sshd_config do
87
+ question = [
88
+ "This task updates your server's sshd_config with the file in config/cookbook.",
89
+ "This task assumes your server's current ssh port is 22.",
90
+ "This task will change your ssh port to the one in config/deploy.rb.",
91
+ "OK?"
92
+ ]
93
+ if yes(question)
94
+ set :port, 22 # Comment out for testing
95
+ upload_from_erb '/etc/ssh/sshd_config', binding, :chown => 'root', :chmod => '0644', :folder => 'debian'
96
+ sudo '/etc/init.d/ssh reload'
97
+ set :port, ssh_port
98
+ end
99
+ end
100
+ end
101
+
102
+ namespace :install do
103
+ desc 'Run all tasks'
104
+ task :default do
105
+ debian.install.git
106
+ debian.install.lighttpd
107
+ debian.install.mysql
108
+ debian.install.nginx
109
+ debian.install.php
110
+ debian.install.ruby
111
+ debian.install.rubygems
112
+ debian.install.sphinx
113
+ debian.install.monit
114
+ end
115
+
116
+ desc "Install Git"
117
+ task :git, :roles => :app do
118
+ install_source(:git) do |path|
119
+ sudo_puts [
120
+ "aptitude install tcl8.4 tk8.4 gettext -q -y",
121
+ "cd #{path} && ./configure && make && sudo make install"
122
+ ]
123
+ end
124
+ end
125
+
126
+ desc "Install Lighttpd" # Lighttpd install is purely for spawn-fcgi
127
+ task :lighttpd, :roles => :app do
128
+ sudo_puts 'aptitude install libpcre3-dev libbz2-dev -q -y'
129
+ install_source(:lighttpd) do |path|
130
+ sudo_puts "cd #{path} && ./configure && make && sudo make install"
131
+ end
132
+ end
133
+
134
+ desc 'Install Monit'
135
+ task :monit, :roles => :db do
136
+ sudo_puts 'aptitude install monit -q -y'
137
+ monit.config.default
138
+ end
139
+
140
+ desc 'Install MySQL'
141
+ task :mysql, :roles => :db do
142
+ sudo_puts 'aptitude install mysql-server mysql-client libmysqlclient15-dev libmysql-ruby -q -y'
143
+ ROOT.mysql.config
144
+ puts [
145
+ '',
146
+ "It is highly recommended you run mysql_secure_installation manually.",
147
+ "See http://dev.mysql.com/doc/refman/5.1/en/mysql-secure-installation.html",
148
+ ''
149
+ ].join("\n")
150
+ ROOT.mysql.create.user
151
+ end
152
+
153
+ desc 'Install Nginx'
154
+ task :nginx, :roles => :app do
155
+ # apache2-utils for htpasswd, rest for nginx build
156
+ sudo_puts 'aptitude install apache2-utils libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev -q -y'
157
+ install_source(:nginx) do |path|
158
+ sudo_puts "cd #{path} && ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module && make && sudo make install"
159
+ end
160
+ upload_from_erb '/etc/init.d/nginx', binding, :chown => 'root', :chmod => '+x', :folder => 'nginx'
161
+ sudo '/usr/sbin/update-rc.d -f nginx defaults'
162
+ ROOT.nginx.config.run_once.default
163
+ end
164
+
165
+ desc "Install PHP"
166
+ task :php, :roles => :app do
167
+ sudo_puts 'aptitude install php5-cli php5-cgi php5-mysql php5-xcache -q -y'
168
+ upload_from_erb [
169
+ '/usr/local/bin/php-fastcgi',
170
+ '/etc/init.d/init-fastcgi'
171
+ ], binding, :chown => 'root', :chmod => '+x', :folder => 'php'
172
+ sudo '/usr/sbin/update-rc.d -f init-fastcgi defaults'
173
+ end
174
+
175
+ desc 'Install Ruby'
176
+ task :ruby, :roles => :app do
177
+ install_source(:ruby) do |path|
178
+ sudo_puts "cd #{path} && ./configure && make && sudo make install"
179
+ end
180
+ end
181
+
182
+ desc 'Install RubyGems'
183
+ task :rubygems, :roles => :app do
184
+ install_source(:rubygems) do |path|
185
+ sudo_puts "cd #{path} && ruby setup.rb"
186
+ end
187
+ gems.update
188
+ gems.install
189
+ end
190
+
191
+ desc 'Install Sphinx'
192
+ task :sphinx, :roles => :app do
193
+ install_source(:sphinx) do |path|
194
+ sudo_puts "cd #{path} && ./configure && make && sudo make install"
195
+ end
196
+ end
197
+ end
198
+ end
199
+
200
+ end
data/recipes/deploy.rb ADDED
@@ -0,0 +1,50 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :deploy do
4
+ desc "Restart mongrel cluster"
5
+ task :restart, :roles => :app, :except => { :no_release => true } do
6
+ mongrel.restart if platform == :rails
7
+ end
8
+
9
+ desc "Start mongrel cluster"
10
+ task :start, :roles => :app do
11
+ mongrel.start if platform == :rails
12
+ end
13
+
14
+ desc "Stop mongrel cluster"
15
+ task :stop, :roles => :app do
16
+ mongrel.stop if platform == :rails
17
+ end
18
+
19
+ desc "Deploy a fresh app"
20
+ task :create, :roles => :app do
21
+ mysql.create.db
22
+ sudo_each [
23
+ "mkdir -p #{base_dir}",
24
+ "chown -R #{user}:#{user} #{base_dir}"
25
+ ]
26
+ deploy.setup
27
+ if platform == :rails
28
+ mongrel.config.default
29
+ nginx.config.default
30
+ rails.config.default
31
+ deploy.cold
32
+ elsif platform == :php
33
+ php.config.default
34
+ deploy.default
35
+ end
36
+ nginx.restart
37
+ end
38
+
39
+ desc "Stop servers and destroy all files"
40
+ task :destroy, :roles => :app do
41
+ deploy.stop
42
+ mongrel.config.destroy if platform == :rails
43
+ sudo "rm -Rf #{deploy_to}"
44
+ nginx.config.destroy
45
+ nginx.restart
46
+ mysql.destroy.db
47
+ end
48
+ end
49
+
50
+ end
data/recipes/gems.rb ADDED
@@ -0,0 +1,77 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :gems do
4
+ desc "List gems on remote server"
5
+ task :list, :roles => :app do
6
+ run_puts "gem list"
7
+ end
8
+
9
+ desc "Update gems on remote server"
10
+ task :update, :roles => :app do
11
+ sudo_each [
12
+ "gem update --system",
13
+ "gem update"
14
+ ]
15
+ end
16
+
17
+ namespace :install do
18
+ desc 'Install all standard gems'
19
+ task :default, :roles => :app do
20
+ gems.install.haml
21
+ gems.install.hpricot
22
+ gems.install.mime_types
23
+ gems.install.mongrel
24
+ gems.install.rails
25
+ end
26
+
27
+ desc 'Install Chronic'
28
+ task :chronic, :roles => :app do
29
+ gem_install :chronic
30
+ end
31
+
32
+ desc 'Install gchart'
33
+ task :gchart, :roles => :app do
34
+ gem_install :googlecharts
35
+ end
36
+
37
+ desc 'Install HAML'
38
+ task :haml, :roles => :app do
39
+ gem_install :haml, '--no-ri'
40
+ end
41
+
42
+ desc 'Install Hpricot'
43
+ task :hpricot, :roles => :app do
44
+ gem_install :hpricot
45
+ end
46
+
47
+ desc 'Install Json'
48
+ task :json, :roles => :app do
49
+ gem_install :json
50
+ end
51
+
52
+ desc 'Install Mime-types'
53
+ task :mime_types, :roles => :app do
54
+ gem_install 'mime-types'
55
+ end
56
+
57
+ desc 'Install Mongrel'
58
+ task :mongrel, :roles => :app do
59
+ gem_install :mongrel
60
+ gem_install :mongrel_cluster
61
+ mongrel.config.survive_reboot
62
+ end
63
+
64
+ desc 'Install Rails'
65
+ task :rails, :roles => :app do
66
+ gem_install :rails
67
+ end
68
+ end
69
+
70
+ desc "Uninstall a remote gem"
71
+ task :uninstall, :roles => :app do
72
+ gem_name = ask 'Enter the name of the gem to remove:'
73
+ sudo "gem uninstall #{gem_name}"
74
+ end
75
+ end
76
+
77
+ end
data/recipes/log.rb ADDED
@@ -0,0 +1,47 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :log do
4
+ namespace :tail do
5
+ desc "Tail all remote logs"
6
+ task :default, :roles => :app do
7
+ log.tail.nginx
8
+ log.tail.mongrel
9
+ log.tail.production
10
+ end
11
+
12
+ desc "Tail the remote Nginx log"
13
+ task :nginx, :roles => :app do
14
+ puts 'Nginx ' + '=' * 100
15
+ run_puts "tail -100 #{shared_path}/log/nginx.log"
16
+ end
17
+
18
+ desc "Tail the remote Mongrel log"
19
+ task :mongrel, :roles => :app do
20
+ (mongrel_port..(mongrel_port + production_mongrels - 1)).each do |port|
21
+ puts "Mongrel #{port} " + '=' * 100
22
+ run_puts "tail -100 #{shared_path}/log/mongrel.#{port}.log"
23
+ end
24
+ end
25
+
26
+ desc "Tail the remote Rails production log"
27
+ task :production, :roles => :app do
28
+ puts 'Production ' + '=' * 100
29
+ run_puts "tail -100 #{shared_path}/log/production.log"
30
+ end
31
+ end
32
+
33
+ desc "Add logrotate entry for this application"
34
+ task :rotate, :roles => :app do
35
+ upload_from_erb '/etc/rotate.conf', binding, :folder => 'log'
36
+ sudo_each [
37
+ 'cp -f /etc/logrotate.conf /etc/logrotate2.conf',
38
+ 'chmod 777 /etc/logrotate2.conf',
39
+ 'cat /etc/rotate.conf >> /etc/logrotate2.conf',
40
+ 'cp -f /etc/logrotate2.conf /etc/logrotate.conf',
41
+ 'rm -f /etc/logrotate2.conf',
42
+ 'rm -f /etc/rotate.conf'
43
+ ]
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,48 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :mongrel do
4
+ [ :stop, :start, :restart ].each do |t|
5
+ desc "#{t.to_s.capitalize} the mongrel appserver"
6
+ task t, :roles => :app do
7
+ run "mongrel_rails cluster::#{t.to_s} -C #{mongrel_etc_dir}/#{application}_#{stage}.yml"
8
+ end
9
+ end
10
+
11
+ namespace :config do
12
+ desc "Generate remote application config"
13
+ task :default, :roles => :app do
14
+ mongrel.config.cluster
15
+ mongrel.config.nginx
16
+ end
17
+
18
+ desc "Generate remote remote mongrel_cluster config"
19
+ task :cluster, :roles => :app do
20
+ sudo "mkdir -p #{mongrel_etc_dir}"
21
+ upload_from_erb "#{mongrel_etc_dir}/#{application}_#{stage}.yml", binding, :folder => 'mongrel', :name => 'mongrel.yml'
22
+ end
23
+
24
+ desc "Generate remote Nginx vhost"
25
+ task :nginx, :roles => :app do
26
+ upload_from_erb "#{nginx_dir}/vhosts/#{application}_#{stage}.conf", binding, :folder => 'mongrel', :name => 'nginx.vhost'
27
+ end
28
+
29
+ desc "Make our mongrel cluster restart-proof"
30
+ task :survive_reboot, :roles => :app do
31
+ sudo_each [
32
+ "cp -Rf #{mongrel_gem_dir}/resources/mongrel_cluster /etc/init.d/",
33
+ "chmod +x /etc/init.d/mongrel_cluster",
34
+ "/usr/sbin/update-rc.d -f mongrel_cluster defaults"
35
+ ]
36
+ end
37
+
38
+ desc "Destroy all files created by config:create"
39
+ task :destroy, :roles => :app do
40
+ sudo_each [
41
+ "rm -f #{mongrel_etc_dir}/#{application}_#{stage}.yml",
42
+ "rm -f #{nginx_dir}/vhosts/#{application}_#{stage}.conf"
43
+ ]
44
+ end
45
+ end
46
+ end
47
+
48
+ end
data/recipes/monit.rb ADDED
@@ -0,0 +1,47 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :monit do
4
+ [ :stop, :start, :restart ].each do |t|
5
+ desc "#{t.to_s.capitalize} Monit"
6
+ task t, :roles => :app do
7
+ sudo "/etc/init.d/monit #{t.to_s}"
8
+ end
9
+ end
10
+
11
+ namespace :config do
12
+ desc "Generate remote Monit config files"
13
+ task :default, :roles => :app do
14
+ upload_from_erb [
15
+ '/etc/monit/monitrc',
16
+ '/etc/default/monit'
17
+ ], binding, :chown => 'root', :chmod => '0644', :folder => 'monit'
18
+ monit.config.nginx
19
+ end
20
+
21
+ desc "Add mongrel cluster to monitrc"
22
+ task :mongrel, :roles => :app do
23
+ upload_from_erb '/etc/monit/mongrel', binding, :folder => 'monit'
24
+ sudo_each [
25
+ 'cp -f /etc/monit/monitrc /etc/monit/monitrc2',
26
+ 'chmod 777 /etc/monit/monitrc2',
27
+ 'cat /etc/monit/mongrel >> /etc/monit/monitrc2',
28
+ 'cp -f /etc/monit/monitrc2 /etc/monit/monitrc',
29
+ 'rm -f /etc/monit/mongrel',
30
+ 'rm -f /etc/monit/monitrc2'
31
+ ]
32
+ end
33
+
34
+ desc "Generate remote Nginx vhost"
35
+ task :nginx, :roles => :app do
36
+ if monit_auth_user
37
+ sudo_each [
38
+ "mkdir -p #{nginx_dir}/htpasswd",
39
+ "htpasswd -bc #{nginx_dir}/htpasswd/monit #{monit_auth_user} #{monit_auth_pass}"
40
+ ]
41
+ end
42
+ upload_from_erb "#{nginx_dir}/vhosts/monit.conf", binding, :folder => 'monit', :name => 'nginx.vhost'
43
+ end
44
+ end
45
+ end
46
+
47
+ end
data/recipes/mysql.rb ADDED
@@ -0,0 +1,106 @@
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.db
8
+ mysql.create.user
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 '#{db_user}'@'localhost' IDENTIFIED BY '#{db_pass}'",
20
+ "GRANT ALL PRIVILEGES ON *.* TO '#{db_user}'@'localhost'"
21
+ ]
22
+ end
23
+ end
24
+
25
+ namespace :update do
26
+ desc 'Update mysql root password'
27
+ task :root_password, :roles => :db do
28
+ old_pass = ask "Current root password? (default: none)"
29
+ new_pass = ask "New root password? (default: none)"
30
+ sudo "mysqladmin -u root #{old_pass.empty? ? '' : "--password=#{old_pass} "}password #{new_pass}"
31
+ end
32
+ end
33
+
34
+ namespace :destroy do
35
+ desc "Destroy database and user"
36
+ task :default, :roles => :db do
37
+ mysql.destroy.db
38
+ mysql.destroy.user
39
+ end
40
+
41
+ desc "Destroy database"
42
+ task :db, :roles => :db do
43
+ mysql_run "DROP DATABASE #{db_table}"
44
+ end
45
+
46
+ desc "Destroy database user"
47
+ task :user, :roles => :db do
48
+ mysql_run [
49
+ "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '#{db_user}'@'localhost'",
50
+ "DROP USER '#{db_user}'@'localhost'"
51
+ ]
52
+ end
53
+ end
54
+
55
+ desc "Updates my.cnf from the file in config/cookbook"
56
+ task :config, :roles => :db do
57
+ question = [
58
+ "This task updates your server's my.cnf (MySQL config) with the one in config/cookbook.",
59
+ "OK?"
60
+ ]
61
+ if yes(question)
62
+ upload_from_erb "#{mysql_dir}/my.cnf", binding, :chown => 'root', :chmod => '0644', :folder => 'mysql'
63
+ sudo "/etc/init.d/mysql restart"
64
+ end
65
+ end
66
+
67
+ namespace :backup do
68
+ desc "Backup database to local"
69
+ task :to_local, :roles => :db do
70
+ to_server
71
+ system "mkdir -p ~/db_backups/#{stage}/#{application}"
72
+ get "#{shared_path}/db_backups/#{backup_name}.bz2", File.expand_path("~/db_backups/#{stage}/#{application}/#{backup_name}.bz2")
73
+ end
74
+
75
+ desc "Backup database to remote"
76
+ task :to_server, :roles => :db do
77
+ run_each [
78
+ "mkdir -p #{shared_path}/db_backups",
79
+ "mysqldump --add-drop-table -u #{db_user} -p#{db_pass} #{db_table}_production | bzip2 -c > #{shared_path}/db_backups/#{backup_name}.bz2"
80
+ ]
81
+ end
82
+
83
+ desc "Upload local backup to remote"
84
+ task :local_to_server, :roles => :db do
85
+ from = File.expand_path("~/db_backups/#{stage}/#{application}/#{backup_name}.bz2")
86
+ if File.exists?(from)
87
+ run_each "mkdir -p #{shared_path}/db_backups"
88
+ upload from, "#{shared_path}/db_backups/#{backup_name}.bz2"
89
+ else
90
+ puts "Does not exist: #{from}"
91
+ end
92
+ end
93
+
94
+ desc "Restore remote database from backup"
95
+ task :restore, :roles => :db do
96
+ run_each "bunzip2 < #{shared_path}/db_backups/#{backup_name}.bz2 | mysql -u #{db_user} --password=#{db_pass} #{db_table}"
97
+ end
98
+
99
+ def backup_name
100
+ now = Time.now
101
+ [ now.year, now.month, now.day ].join('-') + '.sql'
102
+ end
103
+ end
104
+ end
105
+
106
+ end
data/recipes/nginx.rb ADDED
@@ -0,0 +1,79 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :nginx do
4
+ desc "Restart nginx"
5
+ task :restart, :roles => :app do
6
+ deploy.nginx.stop
7
+ deploy.nginx.start
8
+ end
9
+
10
+ desc "Start nginx"
11
+ task :start, :roles => :app do
12
+ sudo "/etc/init.d/nginx start"
13
+ end
14
+
15
+ desc "Stop nginx"
16
+ task :stop, :roles => :app do
17
+ sudo "/etc/init.d/nginx stop"
18
+ end
19
+
20
+ namespace :config do
21
+ desc "Generate remote application config"
22
+ task :default, :roles => :app do
23
+ if auth_user
24
+ sudo_each [
25
+ "mkdir -p #{nginx_dir}/htpasswd",
26
+ "htpasswd -bc #{nginx_dir}/htpasswd/#{application}_#{stage} #{auth_user} #{auth_pass}"
27
+ ]
28
+ end
29
+ end
30
+
31
+ desc "Destroy all files created by config"
32
+ task :destroy, :roles => :app do
33
+ sudo_each "rm -f #{nginx_dir}/htpasswd/#{application}_#{stage}"
34
+ end
35
+
36
+ namespace :run_once do
37
+ desc "Generate remote system config (run once)"
38
+ task :default, :roles => :app do
39
+ question = [
40
+ "This task updates your server's nginx.conf with the one in config/cookbook.",
41
+ "OK?"
42
+ ]
43
+ if yes(question)
44
+ sudo_each [
45
+ "mkdir -p #{nginx_dir}/vhosts",
46
+ "chmod 0755 #{nginx_dir}/vhosts"
47
+ ]
48
+ upload_from_erb "#{nginx_dir}/nginx.conf", binding, :chown => 'root', :chmod => '0644', :folder => 'nginx'
49
+ end
50
+ end
51
+
52
+ desc "Destroy remote system config"
53
+ task :destroy, :roles => :app do
54
+ sudo_each "rm -f #{nginx_dir}/nginx.conf"
55
+ end
56
+ end
57
+
58
+ namespace :ssl do
59
+ desc "Generate SSL key"
60
+ task :default, :roles => :app do
61
+ # http://www.geotrust.com/quickssl/csr
62
+ question = [
63
+ "This task creates cert/key and cert/csr. Press enter for all optional SSL questions.",
64
+ "Use these files when buying an SSL cert.",
65
+ '',
66
+ "Place the purchased cert in cert/cert. Set :ssl_cert => true in deploy.rb.",
67
+ "OK?"
68
+ ]
69
+ if yes(question)
70
+ system 'mkdir -p cert'
71
+ system 'openssl genrsa -out cert/key 1024'
72
+ system 'openssl req -new -key cert/key -out cert/csr'
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ end
data/recipes/php.rb ADDED
@@ -0,0 +1,17 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :php do
4
+ namespace :config do
5
+ desc "Generate remote application config"
6
+ task :default, :roles => :app do
7
+ php.config.nginx
8
+ end
9
+
10
+ desc "Generate remote Nginx vhost"
11
+ task :nginx, :roles => :app do
12
+ upload_from_erb "#{nginx_dir}/vhosts/#{application}_#{stage}.conf", binding, :folder => 'php', :name => 'nginx.vhost'
13
+ end
14
+ end
15
+ end
16
+
17
+ end