kompanee-recipes 0.0.10 → 0.1.0
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.
Potentially problematic release.
This version of kompanee-recipes might be problematic. Click here for more details.
- data/README.md +182 -0
- data/lib/kompanee-recipes/apache.rb +241 -0
- data/lib/kompanee-recipes/bash.rb +44 -0
- data/lib/kompanee-recipes/bundler.rb +24 -0
- data/lib/kompanee-recipes/deploy.rb +56 -247
- data/lib/kompanee-recipes/environment.rb +213 -0
- data/lib/kompanee-recipes/git.rb +40 -0
- data/lib/kompanee-recipes/heroku.rb +243 -0
- data/lib/kompanee-recipes/mysql.rb +128 -0
- data/lib/kompanee-recipes/passenger.rb +124 -0
- data/lib/kompanee-recipes/php.rb +16 -0
- data/lib/kompanee-recipes/phpmyadmin.rb +39 -0
- data/lib/kompanee-recipes/rackspace.rb +35 -0
- data/lib/kompanee-recipes/rvm.rb +99 -0
- data/lib/kompanee-recipes/sqlite3.rb +9 -0
- data/lib/kompanee-recipes/subversion.rb +20 -0
- data/lib/kompanee-recipes/ubuntu.rb +235 -0
- metadata +22 -17
- data/History.txt +0 -4
- data/Manifest.txt +0 -12
- data/PostInstall.txt +0 -7
- data/README.rdoc +0 -51
- data/Rakefile +0 -24
- data/lib/kompanee-recipes.rb +0 -6
- data/lib/kompanee-recipes/app_setup.rb +0 -92
- data/lib/kompanee-recipes/bash_environment.rb +0 -31
- data/lib/kompanee-recipes/ubuntu_server_setup.rb +0 -277
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kompanee-recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.10
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- The Kompanee
|
@@ -57,21 +57,26 @@ executables: []
|
|
57
57
|
|
58
58
|
extensions: []
|
59
59
|
|
60
|
-
extra_rdoc_files:
|
61
|
-
|
62
|
-
- Manifest.txt
|
63
|
-
- PostInstall.txt
|
60
|
+
extra_rdoc_files: []
|
61
|
+
|
64
62
|
files:
|
65
|
-
-
|
66
|
-
- lib/kompanee-recipes/
|
67
|
-
- lib/kompanee-recipes/
|
63
|
+
- lib/kompanee-recipes/apache.rb
|
64
|
+
- lib/kompanee-recipes/bash.rb
|
65
|
+
- lib/kompanee-recipes/bundler.rb
|
68
66
|
- lib/kompanee-recipes/deploy.rb
|
69
|
-
- lib/kompanee-recipes/
|
70
|
-
- lib/kompanee-recipes.rb
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
67
|
+
- lib/kompanee-recipes/environment.rb
|
68
|
+
- lib/kompanee-recipes/git.rb
|
69
|
+
- lib/kompanee-recipes/heroku.rb
|
70
|
+
- lib/kompanee-recipes/mysql.rb
|
71
|
+
- lib/kompanee-recipes/passenger.rb
|
72
|
+
- lib/kompanee-recipes/php.rb
|
73
|
+
- lib/kompanee-recipes/phpmyadmin.rb
|
74
|
+
- lib/kompanee-recipes/rackspace.rb
|
75
|
+
- lib/kompanee-recipes/rvm.rb
|
76
|
+
- lib/kompanee-recipes/sqlite3.rb
|
77
|
+
- lib/kompanee-recipes/subversion.rb
|
78
|
+
- lib/kompanee-recipes/ubuntu.rb
|
79
|
+
- README.md
|
75
80
|
- test/test_helper.rb
|
76
81
|
- test/test_kompanee-recipes.rb
|
77
82
|
has_rdoc: true
|
@@ -81,7 +86,7 @@ licenses: []
|
|
81
86
|
post_install_message:
|
82
87
|
rdoc_options:
|
83
88
|
- --main
|
84
|
-
- README.
|
89
|
+
- README.md
|
85
90
|
require_paths:
|
86
91
|
- lib
|
87
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/History.txt
DELETED
data/Manifest.txt
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
lib/kompanee-recipes/app_setup.rb
|
3
|
-
lib/kompanee-recipes/bash_environment.rb
|
4
|
-
lib/kompanee-recipes/deploy.rb
|
5
|
-
lib/kompanee-recipes/ubuntu_server_setup.rb
|
6
|
-
lib/kompanee-recipes.rb
|
7
|
-
Manifest.txt
|
8
|
-
PostInstall.txt
|
9
|
-
Rakefile
|
10
|
-
README.rdoc
|
11
|
-
test/test_helper.rb
|
12
|
-
test/test_kompanee-recipes.rb
|
data/PostInstall.txt
DELETED
data/README.rdoc
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
= kompanee-recipes
|
2
|
-
|
3
|
-
* http://github.com/thekompanee/kompanee-recipes
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
These are the common recipes we've been using here at The Kompanee. Packaged as a gem.
|
8
|
-
|
9
|
-
== FEATURES/PROBLEMS:
|
10
|
-
|
11
|
-
* None yet
|
12
|
-
|
13
|
-
== SYNOPSIS:
|
14
|
-
|
15
|
-
To the top of your Capfile add:
|
16
|
-
|
17
|
-
require 'rubygems'
|
18
|
-
require 'kompanee-recipes/deploy'
|
19
|
-
|
20
|
-
== REQUIREMENTS:
|
21
|
-
|
22
|
-
Capistrano (Obv)
|
23
|
-
|
24
|
-
== INSTALL:
|
25
|
-
|
26
|
-
gem install git://github.com/thekompanee/kompanee-recipes.git
|
27
|
-
|
28
|
-
== LICENSE:
|
29
|
-
|
30
|
-
(The MIT License)
|
31
|
-
|
32
|
-
Copyright (c) 2010 FIXME full name
|
33
|
-
|
34
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
35
|
-
a copy of this software and associated documentation files (the
|
36
|
-
'Software'), to deal in the Software without restriction, including
|
37
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
38
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
39
|
-
permit persons to whom the Software is furnished to do so, subject to
|
40
|
-
the following conditions:
|
41
|
-
|
42
|
-
The above copyright notice and this permission notice shall be
|
43
|
-
included in all copies or substantial portions of the Software.
|
44
|
-
|
45
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
46
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
47
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
48
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
49
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
50
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
51
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
gem 'hoe', '>= 2.1.0'
|
3
|
-
require 'hoe'
|
4
|
-
require 'fileutils'
|
5
|
-
require './lib/kompanee-recipes'
|
6
|
-
|
7
|
-
Hoe.plugin :newgem
|
8
|
-
# Hoe.plugin :website
|
9
|
-
# Hoe.plugin :cucumberfeatures
|
10
|
-
|
11
|
-
# Generate all the Rake tasks
|
12
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
-
$hoe = Hoe.spec 'kompanee-recipes' do
|
14
|
-
self.developer 'The Kompanee', 'git.hub@thekompanee.com'
|
15
|
-
self.rubyforge_name = self.name
|
16
|
-
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
17
|
-
end
|
18
|
-
|
19
|
-
require 'newgem/tasks'
|
20
|
-
Dir['tasks/**/*.rake'].each { |t| load t }
|
21
|
-
|
22
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
23
|
-
# remove_task :default
|
24
|
-
# task :default => [:spec, :features]
|
data/lib/kompanee-recipes.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
-
namespace :app_setup do
|
3
|
-
namespace :db do
|
4
|
-
desc "Create MySQL Database"
|
5
|
-
task :create, :roles => [:db, :mysql] do
|
6
|
-
create_script = <<-CREATESCRIPT
|
7
|
-
create database #{application_safe} character set utf8;
|
8
|
-
create user '#{application_safe}'@'localhost' identified by '#{db_app_password}';
|
9
|
-
grant all on #{application_safe}.* to #{application_safe}@localhost;
|
10
|
-
CREATESCRIPT
|
11
|
-
|
12
|
-
put create_script, "#{user_home}/create_#{application_safe}_db_script"
|
13
|
-
sudo %Q{bash -c "mysql --user=root --password=#{db_root_password} < #{user_home}/create_#{application_safe}_db_script"}
|
14
|
-
run "rm #{user_home}/create_#{application_safe}_db_script"
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Drop MySQL Database"
|
18
|
-
task :drop, :roles => [:db, :mysql] do
|
19
|
-
drop_script = <<-DROPSCRIPT
|
20
|
-
drop user #{application_safe}@localhost;
|
21
|
-
drop database #{application_safe};
|
22
|
-
DROPSCRIPT
|
23
|
-
|
24
|
-
put drop_script, "#{user_home}/drop_#{application_safe}_db_script"
|
25
|
-
sudo %Q{bash -c "mysql --user=root --password=#{db_root_password} < #{user_home}/drop_#{application_safe}_db_script"}
|
26
|
-
run "rm #{user_home}/drop_#{application_safe}_db_script"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
namespace :apache do
|
31
|
-
desc "Install Virtual Host"
|
32
|
-
task :install_virtual_host, :roles => [:web, :apache] do
|
33
|
-
set :rvm_gemdir, "#{user_home}/.rvm/gems/#{app_ruby_version}"
|
34
|
-
|
35
|
-
virutal_host_config = <<-VHOST
|
36
|
-
<VirtualHost #{web_server_ip}:443>
|
37
|
-
ServerName #{deploy_name}
|
38
|
-
DocumentRoot #{deploy_to}/current/public
|
39
|
-
|
40
|
-
SetEnv GEM_HOME #{rvm_gemdir}@#{application_safe}
|
41
|
-
SetEnv GEM_PATH #{rvm_gemdir}@#{application_safe}:#{rvm_gemdir}@global:#{rvm_gemdir}
|
42
|
-
SetEnv BUNDLE_PATH #{rvm_gemdir}@#{application_safe}
|
43
|
-
|
44
|
-
SSLEngine on
|
45
|
-
SSLCertificateFile /etc/ssl/certs/thekompanee.crt
|
46
|
-
SSLCertificateKeyFile /etc/ssl/certs/thekompanee.key
|
47
|
-
|
48
|
-
<Directory "#{deploy_to}/current/public">
|
49
|
-
Options FollowSymLinks -MultiViews
|
50
|
-
AllowOverride all
|
51
|
-
Order allow,deny
|
52
|
-
Allow from all
|
53
|
-
</Directory>
|
54
|
-
|
55
|
-
RewriteEngine On
|
56
|
-
|
57
|
-
ErrorDocument 503 /system/maintenance.html
|
58
|
-
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
|
59
|
-
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
|
60
|
-
RewriteCond %{REQUEST_URI} !^/images/
|
61
|
-
RewriteCond %{REQUEST_URI} !^/robots.txt
|
62
|
-
RewriteCond %{REQUEST_URI} !^/sitemap
|
63
|
-
RewriteRule ^.*$ - [redirect=503,last]
|
64
|
-
|
65
|
-
ErrorLog /var/log/apache2/#{application}-errors.log
|
66
|
-
|
67
|
-
LogLevel warn
|
68
|
-
|
69
|
-
CustomLog /var/log/apache2/#{application}-access.log combined
|
70
|
-
ServerSignature On
|
71
|
-
</VirtualHost>
|
72
|
-
|
73
|
-
<VirtualHost 174.143.210.66:80>
|
74
|
-
ServerName #{deploy_name}
|
75
|
-
|
76
|
-
Redirect permanent/https://#{deploy_name}
|
77
|
-
</VirtualHost>
|
78
|
-
VHOST
|
79
|
-
|
80
|
-
sudo "a2enmod rewrite"
|
81
|
-
put virutal_host_config, "#{user_home}/#{deploy_name}"
|
82
|
-
sudo "mv #{user_home}/#{deploy_name} /etc/apache2/sites-available"
|
83
|
-
end
|
84
|
-
|
85
|
-
desc "Remove Virtual Host"
|
86
|
-
task :remove_virtual_host, :roles => [:web, :apache] do
|
87
|
-
sudo "a2dissite #{deploy_name}"
|
88
|
-
sudo "rm /etc/apache2/sites-available/#{deploy_name}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
-
namespace :bash do
|
3
|
-
desc "Prepare The Kompanee Common Bash Environment"
|
4
|
-
task :prepare_common_environment do
|
5
|
-
sudo "git clone git://github.com/thekompanee/kompanee-common.git /usr/share/kompanee-common"
|
6
|
-
end
|
7
|
-
|
8
|
-
desc "Install The Kompanee Common Bash Environment for a specific user"
|
9
|
-
task :install_common_environment, :roles => :ubuntu do
|
10
|
-
bash_user = for_user || user
|
11
|
-
puts bash_user
|
12
|
-
bash_user_home = bash_user == 'root' ? "/root" : "/home/#{bash_user}"
|
13
|
-
|
14
|
-
sudo "touch #{bash_user_home}/.inputrc"
|
15
|
-
sudo "touch #{bash_user_home}/.bashrc"
|
16
|
-
sudo "mv #{bash_user_home}/.bashrc #{bash_user_home}/.bashrc.bak"
|
17
|
-
sudo "mv #{bash_user_home}/.inputrc #{bash_user_home}/.inputrc.bak"
|
18
|
-
sudo "ln -s /usr/share/kompanee-common/bash_customizations/bashrc #{bash_user_home}/.bashrc"
|
19
|
-
sudo "ln -s /usr/share/kompanee-common/bash_customizations/inputrc #{bash_user_home}/.inputrc"
|
20
|
-
sudo "ln -s /usr/share/kompanee-common/bash_customizations #{bash_user_home}/.bash"
|
21
|
-
sudo "chown -R #{bash_user}:#{bash_user} #{bash_user_home}"
|
22
|
-
end
|
23
|
-
|
24
|
-
desc "Install the safer sshd_config file"
|
25
|
-
task :install_safer_sshd_config do
|
26
|
-
sudo "mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak"
|
27
|
-
sudo "cp /usr/share/kompanee-common/ssh/sshd_config /etc/ssh/"
|
28
|
-
sudo "/etc/init.d/ssh restart"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,277 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
-
######################################################################
|
3
|
-
# UBUNTU SERVER TASKS #
|
4
|
-
######################################################################
|
5
|
-
|
6
|
-
before "ubuntu:apache:modules:passenger:install", "ubuntu:development_tools:gems:install_passenger"
|
7
|
-
|
8
|
-
namespace :ubuntu do
|
9
|
-
desc "Setup Environment"
|
10
|
-
task :setup, :roles => [:ubuntu] do
|
11
|
-
# Setup Common Bash Environment
|
12
|
-
bash.prepare_common_environment
|
13
|
-
|
14
|
-
bash.install_common_environment # For deploy user
|
15
|
-
|
16
|
-
user_other = user
|
17
|
-
set :user, 'root'
|
18
|
-
bash.install_common_environment # For root
|
19
|
-
set :user, user_other
|
20
|
-
|
21
|
-
bash.install_safer_sshd_config
|
22
|
-
|
23
|
-
ubuntu.package_manager.update
|
24
|
-
ubuntu.development_tools.install_common
|
25
|
-
ubuntu.apache.install
|
26
|
-
ubuntu.apache.modules.ssl.install
|
27
|
-
ubuntu.development_tools.install_php5
|
28
|
-
ubuntu.vc.install_subversion
|
29
|
-
ubuntu.vc.install_git
|
30
|
-
ubuntu.development_tools.install_rvm
|
31
|
-
ubuntu.db.install_sqlite3
|
32
|
-
ubuntu.db.install_mysql5
|
33
|
-
ubuntu.db.install_phpmyadmin
|
34
|
-
ubuntu.apache.modules.passenger.install
|
35
|
-
ubuntu.development_tools.gems.install_bundler
|
36
|
-
end
|
37
|
-
|
38
|
-
namespace :package_manager do
|
39
|
-
desc "Update apt-get sources"
|
40
|
-
task :update, :roles => [:ubuntu] do
|
41
|
-
sudo "apt-get update"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
namespace :development_tools do
|
46
|
-
desc "Install Development Tools"
|
47
|
-
task :install_common, :roles => [:ubuntu] do
|
48
|
-
sudo "apt-get install build-essential debconf-utils libxslt-dev libxml2-dev -y"
|
49
|
-
end
|
50
|
-
|
51
|
-
desc "Install PHP 5"
|
52
|
-
task :install_php5, :roles => [:ubuntu, :web] do
|
53
|
-
sudo "apt-get install php5 -y"
|
54
|
-
end
|
55
|
-
|
56
|
-
desc "Install RVM"
|
57
|
-
task :install_rvm, :roles => [:ubuntu, :web] do
|
58
|
-
sudo "apt-get install curl bison zlib1g-dev libssl-dev libreadline5-dev libxml2-dev autoconf -y"
|
59
|
-
run "bash < <(curl http://rvm.beginrescueend.com/releases/rvm-install-head)"
|
60
|
-
run %Q{echo "[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"" >> #{user_home}/.bashrc}
|
61
|
-
|
62
|
-
rvmrc = <<-RVMRC
|
63
|
-
export rvm_install_on_use_flag=1
|
64
|
-
export rvm_gemset_create_on_use_flag=1
|
65
|
-
|
66
|
-
export rvm_archflags="-arch x86_64"
|
67
|
-
export rvm_project_rvmrc_default=1
|
68
|
-
RVMRC
|
69
|
-
|
70
|
-
put rvmrc, "#{user_home}/.rvmrc"
|
71
|
-
end
|
72
|
-
|
73
|
-
namespace :gems do
|
74
|
-
desc "Install Bundler"
|
75
|
-
task :install_bundler, :roles => :app do
|
76
|
-
Net::SSH.start(web_server_ip, user) do |ssh|
|
77
|
-
ssh.exec!("rvm use #{default_ruby_version}@global && gem install bundler --version #{bundler_version} --no-ri --no-rdoc")
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
desc "Install Passenger"
|
82
|
-
task :install_passenger, :roles => :web do
|
83
|
-
Net::SSH.start(web_server_ip, user) do |ssh|
|
84
|
-
ssh.exec!("rvm use #{default_ruby_version}@global && gem install passenger --version #{passenger_version} --no-ri --no-rdoc")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
namespace :vc do
|
91
|
-
desc "Install Git"
|
92
|
-
task :install_git, :roles => [:ubuntu, :app] do
|
93
|
-
sudo "apt-get install git-core git-svn -y"
|
94
|
-
end
|
95
|
-
|
96
|
-
desc "Install Subversion"
|
97
|
-
task :install_subversion, :roles => [:ubuntu, :app] do
|
98
|
-
sudo "apt-get install subversion -y"
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
namespace :db do
|
103
|
-
desc "Install SQLite3"
|
104
|
-
task :install_sqlite3, :roles => [:ubuntu, :db] do
|
105
|
-
sudo "apt-get install sqlite3 libsqlite3-ruby -y"
|
106
|
-
end
|
107
|
-
|
108
|
-
desc "Install MySQL 5"
|
109
|
-
task :install_mysql5, :roles => [:ubuntu, :db] do
|
110
|
-
mysql_install_answers = <<-INSTALLANSWERS
|
111
|
-
mysql-server mysql-server/root_password select #{db_root_password}
|
112
|
-
mysql-server mysql-server/root_password_again select #{db_root_password}
|
113
|
-
INSTALLANSWERS
|
114
|
-
|
115
|
-
put mysql_install_answers, "#{user_home}/mysql_install_answers"
|
116
|
-
sudo "debconf-set-selections #{user_home}/mysql_install_answers"
|
117
|
-
run "rm #{user_home}/mysql_install_answers"
|
118
|
-
|
119
|
-
sudo "apt-get install mysql-server-5.1 libmysql-ruby -y"
|
120
|
-
end
|
121
|
-
|
122
|
-
desc "Install phpMyAdmin"
|
123
|
-
task :install_phpmyadmin, :roles => [:ubuntu, :db] do
|
124
|
-
set(:phpmyadmin_password) {Capistrano::CLI.password_prompt("Password For phpMyAdmin: ")}
|
125
|
-
|
126
|
-
phpmyadmin_install_answers = <<-INSTALLANSWERS
|
127
|
-
phpmyadmin phpmyadmin/app-password-confirm select #{phpmyadmin_password}
|
128
|
-
phpmyadmin phpmyadmin/mysql/admin-pass select #{db_root_password}
|
129
|
-
phpmyadmin phpmyadmin/password-confirm select #{phpmyadmin_password}
|
130
|
-
phpmyadmin phpmyadmin/setup-password select #{phpmyadmin_password}
|
131
|
-
phpmyadmin phpmyadmin/mysql/app-pass select #{phpmyadmin_password}
|
132
|
-
phpmyadmin phpmyadmin/reconfigure-webserver select apache2
|
133
|
-
phpmyadmin phpmyadmin/dbconfig-install boolean true
|
134
|
-
INSTALLANSWERS
|
135
|
-
|
136
|
-
put phpmyadmin_install_answers, "#{user_home}/phpmyadmin_install_answers"
|
137
|
-
sudo "debconf-set-selections #{user_home}/phpmyadmin_install_answers"
|
138
|
-
run "rm #{user_home}/phpmyadmin_install_answers"
|
139
|
-
|
140
|
-
sudo "apt-get install phpmyadmin -y"
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
namespace :apache do
|
145
|
-
desc "Install Apache"
|
146
|
-
task :install, :roles => [:ubuntu, :web] do
|
147
|
-
sudo "apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 apache2-prefork-dev libapr1-dev -y"
|
148
|
-
sudo "chown -R deploy:deploy /var/www"
|
149
|
-
|
150
|
-
default_httpd_conf = <<-HTTPDCONF
|
151
|
-
# =========================================================
|
152
|
-
# Basic Settings
|
153
|
-
# =========================================================
|
154
|
-
|
155
|
-
Listen #{web_server_ip}:80
|
156
|
-
Listen #{web_server_ip}:443
|
157
|
-
|
158
|
-
ServerName #{web_server_name}
|
159
|
-
|
160
|
-
# =========================================================
|
161
|
-
# Access control
|
162
|
-
# =========================================================
|
163
|
-
|
164
|
-
#<Directory />
|
165
|
-
# Options FollowSymLinks
|
166
|
-
# AllowOverride None
|
167
|
-
# Order deny,allow
|
168
|
-
# Deny from all
|
169
|
-
#</Directory>
|
170
|
-
|
171
|
-
# =========================================================
|
172
|
-
# Virtual Host Directives
|
173
|
-
# =========================================================
|
174
|
-
|
175
|
-
NameVirtualHost #{web_server_ip}:80
|
176
|
-
NameVirtualHost #{web_server_ip}:443
|
177
|
-
HTTPDCONF
|
178
|
-
|
179
|
-
put default_httpd_conf, "#{user_home}/default_httpd_conf"
|
180
|
-
sudo "mv #{user_home}/default_httpd_conf /etc/apache2/httpd.conf"
|
181
|
-
sudo "mv /etc/apache2/ports.conf /etc/apache2/ports.conf.bak"
|
182
|
-
sudo "touch /etc/apache2/ports.conf"
|
183
|
-
|
184
|
-
sudo "rm /var/www/index.html"
|
185
|
-
sudo "rm -rf /etc/apache2/sites-enabled/*"
|
186
|
-
sudo "rm -rf /etc/apache2/sites-available/*"
|
187
|
-
|
188
|
-
sudo "a2enmod rewrite"
|
189
|
-
end
|
190
|
-
|
191
|
-
desc "Stop Apache"
|
192
|
-
task :stop, :roles => [:ubuntu, :web, :apache] do
|
193
|
-
sudo "/etc/init.d/apache2 stop"
|
194
|
-
end
|
195
|
-
|
196
|
-
desc "Start Apache"
|
197
|
-
task :start, :roles => [:ubuntu, :web, :apache] do
|
198
|
-
sudo "/etc/init.d/apache2 start"
|
199
|
-
end
|
200
|
-
|
201
|
-
desc "Restart Apache"
|
202
|
-
task :restart, :roles => [:ubuntu, :web, :apache] do
|
203
|
-
sudo "/etc/init.d/apache2 restart"
|
204
|
-
end
|
205
|
-
|
206
|
-
desc "Enable Site"
|
207
|
-
task :enable, :roles => [:ubuntu, :web, :apache] do
|
208
|
-
sudo "a2ensite #{deploy_name}"
|
209
|
-
end
|
210
|
-
|
211
|
-
desc "Disable Site"
|
212
|
-
task :disable, :roles => [:ubuntu, :web, :apache] do
|
213
|
-
sudo "a2dissite #{deploy_name}"
|
214
|
-
end
|
215
|
-
|
216
|
-
namespace :modules do
|
217
|
-
namespace :ssl do
|
218
|
-
desc "Install SSL Module"
|
219
|
-
task :install, :roles => [:ubuntu, :web, :apache] do
|
220
|
-
certs_dir = "/etc/ssl/certs"
|
221
|
-
|
222
|
-
sudo "a2enmod ssl"
|
223
|
-
sudo %Q{bash -c "openssl genrsa 2048 > #{certs_dir}/thekompanee.key"}
|
224
|
-
sudo %Q{bash -c "openssl req -new -x509 -days 3650 -subj '/C=US/ST=Tennessee/L=Nashville/O=The Kompanee/CN=*.thekompanee.com/emailAddress=webmaster@thekompanee.com' -key #{certs_dir}/thekompanee.key > #{certs_dir}/thekompanee.crt"}
|
225
|
-
sudo %Q{bash -c "openssl x509 -noout -fingerprint -text < #{certs_dir}/thekompanee.crt > #{certs_dir}/thekompanee.info"}
|
226
|
-
sudo %Q{bash -c "cat #{certs_dir}/thekompanee.crt #{certs_dir}/thekompanee.key > #{certs_dir}/thekompanee.pem"}
|
227
|
-
sudo "chmod 400 #{certs_dir}/thekompanee.pem #{certs_dir}/thekompanee.key"
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
namespace :passenger do
|
232
|
-
desc "Install Passenger Module"
|
233
|
-
task :install, :roles => [:ubuntu, :web, :apache] do
|
234
|
-
|
235
|
-
Net::SSH.start(web_server_ip, user) do |ssh|
|
236
|
-
ssh.exec!("rvm use #{default_ruby_version}@global --passenger && rvmsudo passenger-install-apache2-module -a")
|
237
|
-
end
|
238
|
-
|
239
|
-
apache_passenger_load = <<-PASSLOAD
|
240
|
-
LoadModule passenger_module #{user_home}/.rvm/gems/#{default_ruby_version}@global/gems/passenger-#{passenger_version}/ext/apache2/mod_passenger.so
|
241
|
-
PASSLOAD
|
242
|
-
|
243
|
-
apache_passenger_conf = <<-PASSCONF
|
244
|
-
<IfModule mod_passenger.c>
|
245
|
-
PassengerRoot #{user_home}/.rvm/gems/#{default_ruby_version}@global/gems/passenger-#{passenger_version}
|
246
|
-
PassengerRuby #{user_home}/.rvm/bin/#{default_ruby_version}
|
247
|
-
|
248
|
-
<Directory "#{deploy_dir}">
|
249
|
-
Order allow,deny
|
250
|
-
Allow from all
|
251
|
-
</Directory>
|
252
|
-
</IfModule>
|
253
|
-
PASSCONF
|
254
|
-
|
255
|
-
put apache_passenger_load, "#{user_home}/passenger.load"
|
256
|
-
put apache_passenger_conf, "#{user_home}/passenger.conf"
|
257
|
-
sudo "mv #{user_home}/passenger.load /etc/apache2/mods-available/"
|
258
|
-
sudo "mv #{user_home}/passenger.conf /etc/apache2/mods-available/"
|
259
|
-
ubuntu.apache.modules.passenger.enable
|
260
|
-
end
|
261
|
-
|
262
|
-
desc "Enable Passenger"
|
263
|
-
task :enable, :roles => [:ubuntu, :web, :apache] do
|
264
|
-
sudo "a2enmod passenger"
|
265
|
-
ubuntu.apache.restart
|
266
|
-
end
|
267
|
-
|
268
|
-
desc "Disable Passenger"
|
269
|
-
task :disable, :roles => [:ubuntu, :web, :apache] do
|
270
|
-
sudo "a2dismod passenger"
|
271
|
-
ubuntu.apache.restart
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|