kompanee-recipes 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kompanee-recipes might be problematic. Click here for more details.
- data/History.txt +4 -0
- data/Manifest.txt +12 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +51 -0
- data/Rakefile +24 -0
- data/lib/kompanee-recipes/app_setup.rb +73 -0
- data/lib/kompanee-recipes/bash_environment.rb +31 -0
- data/lib/kompanee-recipes/deploy.rb +91 -0
- data/lib/kompanee-recipes/ubuntu_server_setup.rb +262 -0
- data/lib/kompanee-recipes.rb +6 -0
- data/test/test_helper.rb +3 -0
- data/test/test_kompanee-recipes.rb +11 -0
- metadata +114 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,12 @@
|
|
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
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,51 @@
|
|
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
ADDED
@@ -0,0 +1,24 @@
|
|
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]
|
@@ -0,0 +1,73 @@
|
|
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} character set utf8;
|
8
|
+
create user '#{application}'@'localhost' identified by '#{db_app_password}';
|
9
|
+
grant all on #{application}.* to #{application}@localhost;
|
10
|
+
CREATESCRIPT
|
11
|
+
|
12
|
+
put create_script, "#{user_home}/create_#{application}_db_script"
|
13
|
+
sudo "mysql --user=root --password=#{db_root_password} < #{user_home}/create_#{application}_db_script"
|
14
|
+
run "rm #{user_home}/create_#{application}_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}@localhost;
|
21
|
+
drop database #{application};
|
22
|
+
DROPSCRIPT
|
23
|
+
|
24
|
+
put drop_script, "#{user_home}/drop_#{application}_db_script"
|
25
|
+
sudo "mysql --user=root --password=#{db_root_password} < #{user_home}/drop_#{application}_db_script"
|
26
|
+
run "rm #{user_home}/drop_#{application}_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}:80>
|
37
|
+
ServerName #{deploy_name}
|
38
|
+
DocumentRoot #{deploy_to}/current/public
|
39
|
+
|
40
|
+
SetEnv GEM_HOME #{rvm_gemdir}@#{application}
|
41
|
+
SetEnv GEM_PATH #{rvm_gemdir}@#{application}:#{rvm_gemdir}@global:#{rvm_gemdir}
|
42
|
+
|
43
|
+
<Directory "#{deploy_to}/current/public">
|
44
|
+
Options FollowSymLinks -MultiViews
|
45
|
+
AllowOverride all
|
46
|
+
Order allow,deny
|
47
|
+
Allow from all
|
48
|
+
</Directory>
|
49
|
+
|
50
|
+
RewriteEngine On
|
51
|
+
|
52
|
+
ErrorLog /var/log/apache2/#{application}-errors.log
|
53
|
+
|
54
|
+
LogLevel warn
|
55
|
+
|
56
|
+
CustomLog /var/log/apache2/#{application}-access.log combined
|
57
|
+
ServerSignature On
|
58
|
+
</VirtualHost>
|
59
|
+
VHOST
|
60
|
+
|
61
|
+
sudo "a2enmod rewrite"
|
62
|
+
put virutal_host_config, "#{user_home}/#{deploy_name}"
|
63
|
+
sudo "mv #{user_home}/#{deploy_name} /etc/apache2/sites-available"
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Remove Virtual Host"
|
67
|
+
task :remove_virtual_host, :roles => [:web, :apache] do
|
68
|
+
sudo "a2dissite #{deploy_name}"
|
69
|
+
sudo "rm /etc/apache2/sites-available/#{deploy_name}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'kompanee-recipes/ubuntu_server_setup'
|
2
|
+
require 'kompanee-recipes/app_setup'
|
3
|
+
require 'kompanee-recipes/bash_environment'
|
4
|
+
|
5
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
6
|
+
######################################################################
|
7
|
+
# DEPLOYMENT TASKS #
|
8
|
+
######################################################################
|
9
|
+
|
10
|
+
namespace :deploy do
|
11
|
+
task :start do ; end
|
12
|
+
task :stop do ; end
|
13
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
14
|
+
run "touch #{File.join(current_path,'tmp','restart.txt')}"
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :gems do
|
18
|
+
desc "Install Bundled Gems"
|
19
|
+
task :install do
|
20
|
+
run "bundle install"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Update Bundled Gems"
|
24
|
+
task :update do deploy.gems.install; end
|
25
|
+
end
|
26
|
+
|
27
|
+
namespace :web do
|
28
|
+
desc "Uses the Web Server to enable the site."
|
29
|
+
task :site_up do
|
30
|
+
ubuntu.apache.enable
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Uses the Web Server to disable the site."
|
34
|
+
task :site_down do
|
35
|
+
ubuntu.apache.disable
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Takes the entire web server up."
|
39
|
+
task :server_up do
|
40
|
+
ubuntu.apache.start
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Takes the entire web server down."
|
44
|
+
task :server_down do
|
45
|
+
ubuntu.apache.stop
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "Takes the entire web server up."
|
49
|
+
task :server_restart do
|
50
|
+
ubuntu.apache.restart
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Installs the site configuration for the files."
|
54
|
+
task :install do
|
55
|
+
app_setup.apache.install_virtual_host
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Completely removes the site configuration from the server (but leaves the files.)"
|
59
|
+
task :remove do
|
60
|
+
app_setup.apache.remove_virtual_host
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
namespace :db do
|
65
|
+
desc "Adds the DBizzle to the Sizzle. Also adds the appropriate user."
|
66
|
+
task :create do
|
67
|
+
app_setup.db.create
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Removes the DB from the Server. Also removes the user."
|
71
|
+
task :drop do
|
72
|
+
app_setup.db.drop
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
desc "Prepare the server for deployment."
|
77
|
+
task :prepare do
|
78
|
+
deploy.db.create
|
79
|
+
deploy.web.install
|
80
|
+
deploy.setup
|
81
|
+
deploy.web.site_up
|
82
|
+
deploy.web.server_restart
|
83
|
+
deploy.check
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Make sure server has all necessary software for deployment."
|
87
|
+
task :server_setup do
|
88
|
+
ubuntu.setup
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,262 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
set :passenger_version, "2.2.13"
|
3
|
+
|
4
|
+
######################################################################
|
5
|
+
# UBUNTU SERVER TASKS #
|
6
|
+
######################################################################
|
7
|
+
|
8
|
+
before "ubuntu:apache:modules:passenger:install", "ubuntu:development_tools:gems:install_passenger"
|
9
|
+
|
10
|
+
namespace :ubuntu do
|
11
|
+
desc "Setup Environment"
|
12
|
+
task :setup, :roles => [:ubuntu] do
|
13
|
+
# Setup Common Bash Environment
|
14
|
+
bash.prepare_common_environment
|
15
|
+
|
16
|
+
bash.install_common_environment # For deploy user
|
17
|
+
|
18
|
+
user_other = user
|
19
|
+
set :user, 'root'
|
20
|
+
bash.install_common_environment # For root
|
21
|
+
set :user, user_other
|
22
|
+
|
23
|
+
bash.install_safer_sshd_config
|
24
|
+
|
25
|
+
ubuntu.package_manager.update
|
26
|
+
ubuntu.development_tools.install_common
|
27
|
+
ubuntu.apache.install
|
28
|
+
ubuntu.development_tools.install_php5
|
29
|
+
ubuntu.vc.install_subversion
|
30
|
+
ubuntu.vc.install_git
|
31
|
+
ubuntu.development_tools.install_rvm
|
32
|
+
ubuntu.db.install_sqlite3
|
33
|
+
ubuntu.db.install_mysql5
|
34
|
+
ubuntu.db.install_phpmyadmin
|
35
|
+
ubuntu.apache.modules.passenger.install
|
36
|
+
ubuntu.development_tools.gems.install_bundler
|
37
|
+
end
|
38
|
+
|
39
|
+
namespace :package_manager do
|
40
|
+
desc "Update apt-get sources"
|
41
|
+
task :update, :roles => [:ubuntu] do
|
42
|
+
sudo "apt-get update"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
namespace :development_tools do
|
47
|
+
desc "Install Development Tools"
|
48
|
+
task :install_common, :roles => [:ubuntu] do
|
49
|
+
sudo "apt-get install build-essential debconf-utils libxslt-dev libxml2-dev -y"
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Install PHP 5"
|
53
|
+
task :install_php5, :roles => [:ubuntu, :web] do
|
54
|
+
sudo "apt-get install php5 -y"
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Install RVM"
|
58
|
+
task :install_rvm, :roles => [:ubuntu, :web] do
|
59
|
+
sudo "apt-get install curl bison zlib1g-dev libssl-dev libreadline5-dev libxml2-dev autoconf -y"
|
60
|
+
run "bash < <(curl http://rvm.beginrescueend.com/releases/rvm-install-head)"
|
61
|
+
run %Q{echo "[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"" >> #{user_home}/.bashrc}
|
62
|
+
|
63
|
+
rvmrc = <<-RVMRC
|
64
|
+
export rvm_install_on_use_flag=1
|
65
|
+
export rvm_gemset_create_on_use_flag=1
|
66
|
+
|
67
|
+
export rvm_archflags="-arch x86_64"
|
68
|
+
export rvm_project_rvmrc_default=1
|
69
|
+
RVMRC
|
70
|
+
|
71
|
+
put rvmrc, "#{user_home}/.rvmrc"
|
72
|
+
end
|
73
|
+
|
74
|
+
namespace :gems do
|
75
|
+
desc "Install Bundler"
|
76
|
+
task :install_bundler do
|
77
|
+
Net::SSH.start(web_server_ip, user) do |ssh|
|
78
|
+
ssh.exec!("rvm use #{default_ruby_version}@global && gem install bundler --no-ri --no-rdoc")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Install Passenger"
|
83
|
+
task :install_passenger do
|
84
|
+
Net::SSH.start(web_server_ip, user) do |ssh|
|
85
|
+
ssh.exec!("rvm use #{default_ruby_version}@global && gem install passenger --version #{passenger_version} --no-ri --no-rdoc")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
namespace :vc do
|
92
|
+
desc "Install Git"
|
93
|
+
task :install_git, :roles => [:ubuntu] do
|
94
|
+
sudo "apt-get install git-core git-svn -y"
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "Install Subversion"
|
98
|
+
task :install_subversion, :roles => [:ubuntu] do
|
99
|
+
sudo "apt-get install subversion -y"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
namespace :db do
|
104
|
+
desc "Install SQLite3"
|
105
|
+
task :install_sqlite3, :roles => [:ubuntu, :db] do
|
106
|
+
sudo "apt-get install sqlite3 libsqlite3-ruby -y"
|
107
|
+
end
|
108
|
+
|
109
|
+
desc "Install MySQL 5"
|
110
|
+
task :install_mysql5, :roles => [:ubuntu, :db] do
|
111
|
+
mysql_install_answers = <<-INSTALLANSWERS
|
112
|
+
mysql-server mysql-server/root_password select #{db_root_password}
|
113
|
+
mysql-server mysql-server/root_password_again select #{db_root_password}
|
114
|
+
INSTALLANSWERS
|
115
|
+
|
116
|
+
put mysql_install_answers, "#{user_home}/mysql_install_answers"
|
117
|
+
sudo "debconf-set-selections #{user_home}/mysql_install_answers"
|
118
|
+
run "rm #{user_home}/mysql_install_answers"
|
119
|
+
|
120
|
+
sudo "apt-get install mysql-server-5.1 libmysql-ruby -y"
|
121
|
+
end
|
122
|
+
|
123
|
+
desc "Install phpMyAdmin"
|
124
|
+
task :install_phpmyadmin, :roles => [:ubuntu, :db] do
|
125
|
+
phpmyadmin_install_answers = <<-INSTALLANSWERS
|
126
|
+
phpmyadmin phpmyadmin/app-password-confirm select 2377KrLpZ6G4ECYG8BRoD4YcZVdFBDMoHL3ChsewUdcpE2HZhX
|
127
|
+
phpmyadmin phpmyadmin/mysql/admin-pass select #{db_root_password}
|
128
|
+
phpmyadmin phpmyadmin/password-confirm select 2377KrLpZ6G4ECYG8BRoD4YcZVdFBDMoHL3ChsewUdcpE2HZhX
|
129
|
+
phpmyadmin phpmyadmin/setup-password select 2377KrLpZ6G4ECYG8BRoD4YcZVdFBDMoHL3ChsewUdcpE2HZhX
|
130
|
+
phpmyadmin phpmyadmin/mysql/app-pass select 2377KrLpZ6G4ECYG8BRoD4YcZVdFBDMoHL3ChsewUdcpE2HZhX
|
131
|
+
phpmyadmin phpmyadmin/reconfigure-webserver select apache2
|
132
|
+
phpmyadmin phpmyadmin/dbconfig-install boolean true
|
133
|
+
INSTALLANSWERS
|
134
|
+
|
135
|
+
put phpmyadmin_install_answers, "#{user_home}/phpmyadmin_install_answers"
|
136
|
+
sudo "debconf-set-selections #{user_home}/phpmyadmin_install_answers"
|
137
|
+
run "rm #{user_home}/phpmyadmin_install_answers"
|
138
|
+
|
139
|
+
sudo "apt-get install phpmyadmin -y"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
namespace :apache do
|
144
|
+
desc "Install Apache"
|
145
|
+
task :install, :roles => [:ubuntu, :web] do
|
146
|
+
sudo "apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 apache2-prefork-dev libapr1-dev -y"
|
147
|
+
sudo "chown -R deploy:deploy /var/www"
|
148
|
+
|
149
|
+
default_httpd_conf = <<-HTTPDCONF
|
150
|
+
# =========================================================
|
151
|
+
# Basic Settings
|
152
|
+
# =========================================================
|
153
|
+
|
154
|
+
Listen #{web_server_ip}:80
|
155
|
+
Listen #{web_server_ip}:443
|
156
|
+
|
157
|
+
ServerName #{web_server_name}
|
158
|
+
|
159
|
+
# =========================================================
|
160
|
+
# Access control
|
161
|
+
# =========================================================
|
162
|
+
|
163
|
+
#<Directory />
|
164
|
+
# Options FollowSymLinks
|
165
|
+
# AllowOverride None
|
166
|
+
# Order deny,allow
|
167
|
+
# Deny from all
|
168
|
+
#</Directory>
|
169
|
+
|
170
|
+
# =========================================================
|
171
|
+
# Virtual Host Directives
|
172
|
+
# =========================================================
|
173
|
+
|
174
|
+
NameVirtualHost #{web_server_ip}:80
|
175
|
+
NameVirtualHost #{web_server_ip}:443
|
176
|
+
HTTPDCONF
|
177
|
+
|
178
|
+
put default_httpd_conf, "#{user_home}/default_httpd_conf"
|
179
|
+
sudo "mv #{user_home}/default_httpd_conf /etc/apache2/httpd.conf"
|
180
|
+
sudo "mv /etc/apache2/ports.conf /etc/apache2/ports.conf.bak"
|
181
|
+
sudo "touch /etc/apache2/ports.conf"
|
182
|
+
|
183
|
+
sudo "rm /var/www/index.html"
|
184
|
+
sudo "rm -rf /etc/apache2/sites-enabled/*"
|
185
|
+
sudo "rm -rf /etc/apache2/sites-available/*"
|
186
|
+
|
187
|
+
sudo "a2enmod rewrite"
|
188
|
+
end
|
189
|
+
|
190
|
+
desc "Stop Apache"
|
191
|
+
task :stop, :roles => [:ubuntu, :web, :apache] do
|
192
|
+
sudo "/etc/init.d/apache2 stop"
|
193
|
+
end
|
194
|
+
|
195
|
+
desc "Start Apache"
|
196
|
+
task :start, :roles => [:ubuntu, :web, :apache] do
|
197
|
+
sudo "/etc/init.d/apache2 start"
|
198
|
+
end
|
199
|
+
|
200
|
+
desc "Restart Apache"
|
201
|
+
task :restart, :roles => [:ubuntu, :web, :apache] do
|
202
|
+
sudo "/etc/init.d/apache2 restart"
|
203
|
+
end
|
204
|
+
|
205
|
+
desc "Enable Site"
|
206
|
+
task :enable, :roles => [:ubuntu, :web, :apache] do
|
207
|
+
sudo "a2ensite #{deploy_name}"
|
208
|
+
end
|
209
|
+
|
210
|
+
desc "Disable Site"
|
211
|
+
task :disable, :roles => [:ubuntu, :web, :apache] do
|
212
|
+
sudo "a2dissite #{deploy_name}"
|
213
|
+
end
|
214
|
+
|
215
|
+
namespace :modules do
|
216
|
+
namespace :passenger do
|
217
|
+
desc "Install Passenger Module"
|
218
|
+
task :install, :roles => [:ubuntu, :web, :apache] do
|
219
|
+
|
220
|
+
Net::SSH.start(web_server_ip, user) do |ssh|
|
221
|
+
ssh.exec!("rvm use #{default_ruby_version}@global --passenger && rvmsudo passenger-install-apache2-module -a")
|
222
|
+
end
|
223
|
+
|
224
|
+
apache_passenger_load = <<-PASSLOAD
|
225
|
+
LoadModule passenger_module #{user_home}/.rvm/gems/#{default_ruby_version}@global/gems/passenger-#{passenger_version}/ext/apache2/mod_passenger.so
|
226
|
+
PASSLOAD
|
227
|
+
|
228
|
+
apache_passenger_conf = <<-PASSCONF
|
229
|
+
<IfModule mod_passenger.c>
|
230
|
+
PassengerRoot #{user_home}/.rvm/gems/#{default_ruby_version}@global/gems/passenger-#{passenger_version}
|
231
|
+
PassengerRuby #{user_home}/.rvm/bin/#{default_ruby_version}
|
232
|
+
|
233
|
+
<Directory "#{deploy_dir}">
|
234
|
+
Order allow,deny
|
235
|
+
Allow from all
|
236
|
+
</Directory>
|
237
|
+
</IfModule>
|
238
|
+
PASSCONF
|
239
|
+
|
240
|
+
put apache_passenger_load, "#{user_home}/passenger.load"
|
241
|
+
put apache_passenger_conf, "#{user_home}/passenger.conf"
|
242
|
+
sudo "mv #{user_home}/passenger.load /etc/apache2/mods-available/"
|
243
|
+
sudo "mv #{user_home}/passenger.conf /etc/apache2/mods-available/"
|
244
|
+
ubuntu.apache.modules.passenger.enable
|
245
|
+
end
|
246
|
+
|
247
|
+
desc "Enable Passenger"
|
248
|
+
task :enable, :roles => [:ubuntu, :web, :apache] do
|
249
|
+
sudo "a2enmod passenger"
|
250
|
+
ubuntu.apache.restart
|
251
|
+
end
|
252
|
+
|
253
|
+
desc "Disable Passenger"
|
254
|
+
task :disable, :roles => [:ubuntu, :web, :apache] do
|
255
|
+
sudo "a2dismod passenger"
|
256
|
+
ubuntu.apache.restart
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kompanee-recipes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- The Kompanee
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-29 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rubyforge
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
- 4
|
34
|
+
version: 2.0.4
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: hoe
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 21
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 6
|
49
|
+
- 1
|
50
|
+
version: 2.6.1
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
description: These are the common recipes we've been using here at The Kompanee. Packaged as a gem.
|
54
|
+
email:
|
55
|
+
- git.hub@thekompanee.com
|
56
|
+
executables: []
|
57
|
+
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files:
|
61
|
+
- History.txt
|
62
|
+
- Manifest.txt
|
63
|
+
- PostInstall.txt
|
64
|
+
files:
|
65
|
+
- History.txt
|
66
|
+
- lib/kompanee-recipes/app_setup.rb
|
67
|
+
- lib/kompanee-recipes/bash_environment.rb
|
68
|
+
- lib/kompanee-recipes/deploy.rb
|
69
|
+
- lib/kompanee-recipes/ubuntu_server_setup.rb
|
70
|
+
- lib/kompanee-recipes.rb
|
71
|
+
- Manifest.txt
|
72
|
+
- PostInstall.txt
|
73
|
+
- Rakefile
|
74
|
+
- README.rdoc
|
75
|
+
- test/test_helper.rb
|
76
|
+
- test/test_kompanee-recipes.rb
|
77
|
+
has_rdoc: true
|
78
|
+
homepage: http://github.com/thekompanee/kompanee-recipes
|
79
|
+
licenses: []
|
80
|
+
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options:
|
83
|
+
- --main
|
84
|
+
- README.rdoc
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
105
|
+
requirements: []
|
106
|
+
|
107
|
+
rubyforge_project: kompanee-recipes
|
108
|
+
rubygems_version: 1.3.7
|
109
|
+
signing_key:
|
110
|
+
specification_version: 3
|
111
|
+
summary: These are the common recipes we've been using here at The Kompanee
|
112
|
+
test_files:
|
113
|
+
- test/test_helper.rb
|
114
|
+
- test/test_kompanee-recipes.rb
|