kompanee-recipes 0.0.10 → 0.1.0
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/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
@@ -0,0 +1,16 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
run_task "php:install", :as => "manager"
|
3
|
+
|
4
|
+
namespace :php do
|
5
|
+
desc "[internal] Install PHP 5 on Ubuntu"
|
6
|
+
task :install_on_ubuntu do
|
7
|
+
set :dependencies, %w{php5}
|
8
|
+
os.package_manager.install
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Install PHP 5"
|
12
|
+
task :install do
|
13
|
+
php.send("install_on_#{os_type}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
run_task "phpmyadmin:install", :as => "manager"
|
3
|
+
|
4
|
+
namespace :phpmyadmin do
|
5
|
+
desc <<-DESC
|
6
|
+
Installs phpMyAdmin on the server.
|
7
|
+
DESC
|
8
|
+
task :install do
|
9
|
+
phpmyadmin.send("install_on_#{os_type}")
|
10
|
+
end
|
11
|
+
|
12
|
+
desc <<-DESC
|
13
|
+
[internal] Installs phpMyAdmin on Ubuntu.
|
14
|
+
|
15
|
+
* Installs phpMyAdmin via apt-get.
|
16
|
+
* Creates a Debian answer file to allow for an unattended installation.
|
17
|
+
DESC
|
18
|
+
task :install_on_ubuntu do
|
19
|
+
set(:phpmyadmin_password) {Capistrano::CLI.password_prompt("Password For phpMyAdmin: ")}
|
20
|
+
|
21
|
+
phpmyadmin_install_answers = <<-INSTALLANSWERS
|
22
|
+
phpmyadmin phpmyadmin/app-password-confirm select #{phpmyadmin_password}
|
23
|
+
phpmyadmin phpmyadmin/mysql/admin-pass select #{db_root_password}
|
24
|
+
phpmyadmin phpmyadmin/password-confirm select #{phpmyadmin_password}
|
25
|
+
phpmyadmin phpmyadmin/setup-password select #{phpmyadmin_password}
|
26
|
+
phpmyadmin phpmyadmin/mysql/app-pass select #{phpmyadmin_password}
|
27
|
+
phpmyadmin phpmyadmin/reconfigure-webserver select apache2
|
28
|
+
phpmyadmin phpmyadmin/dbconfig-install boolean true
|
29
|
+
INSTALLANSWERS
|
30
|
+
|
31
|
+
put phpmyadmin_install_answers, "#{user_home}/phpmyadmin_install_answers"
|
32
|
+
run "#{sudo} debconf-set-selections #{user_home}/phpmyadmin_install_answers"
|
33
|
+
run "rm #{user_home}/phpmyadmin_install_answers"
|
34
|
+
|
35
|
+
set :dependencies, %w{phpmyadmin}
|
36
|
+
os.package_manager.install
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
desc <<-DESC
|
3
|
+
Makes certain that the server is set up properly to handle deployments.
|
4
|
+
|
5
|
+
It will install:
|
6
|
+
* A web server
|
7
|
+
* The web server's SSL capabilities
|
8
|
+
* PHP
|
9
|
+
* RVM
|
10
|
+
* Database Server
|
11
|
+
* phpMyAdmin
|
12
|
+
* Phusion Passenger
|
13
|
+
* Bundler
|
14
|
+
* Bash Environment
|
15
|
+
* VIM Environment
|
16
|
+
DESC
|
17
|
+
task :server_setup do
|
18
|
+
git.install
|
19
|
+
|
20
|
+
os.package_manager.update
|
21
|
+
os.development_tools.install_common
|
22
|
+
|
23
|
+
web_server.install
|
24
|
+
apache.modules.ssl.install
|
25
|
+
php.install
|
26
|
+
rvm.install.default
|
27
|
+
db.install
|
28
|
+
phpmyadmin.install
|
29
|
+
passenger.install.default
|
30
|
+
bundler.install
|
31
|
+
|
32
|
+
vim.environment.setup
|
33
|
+
bash.environment.setup
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
run_task "rvm:install:prerequisites", :as => "manager"
|
3
|
+
run_task "rvm:install:manager_symlink", :as => "manager"
|
4
|
+
|
5
|
+
namespace :rvm do
|
6
|
+
namespace :install do
|
7
|
+
desc <<-DESC
|
8
|
+
[internal] Packages required by RVM for installation.
|
9
|
+
|
10
|
+
Ubuntu requires a certain set of packages be available before
|
11
|
+
RVM can be installed. This task installs those packages. It has no value
|
12
|
+
on its own.
|
13
|
+
DESC
|
14
|
+
task :prerequisites do
|
15
|
+
set :dependencies, %w{curl bison zlib1g-dev libssl-dev libreadline5-dev libxml2-dev autoconf subversion ruby}
|
16
|
+
os.package_manager.install
|
17
|
+
end
|
18
|
+
|
19
|
+
namespace :for_user do
|
20
|
+
desc <<-DESC
|
21
|
+
[internal] Installs a `.rvmrc` file for the current Capistrano user.
|
22
|
+
|
23
|
+
The settings include:
|
24
|
+
* Install an application's Ruby version on use.
|
25
|
+
If an application has an `.rvmrc` file which invokes a Ruby version
|
26
|
+
that is not installed, RVM will install it.
|
27
|
+
* Create an application's gemset on use.
|
28
|
+
If an application has an `.rvmrc` file which invokes a gemset that
|
29
|
+
does not exist, RVM will create it.
|
30
|
+
* Revert to system Ruby
|
31
|
+
Set Ruby version back to `system` when changing out of a project
|
32
|
+
directory.
|
33
|
+
DESC
|
34
|
+
task :rvmrc do
|
35
|
+
rvmrc = <<-RVMRC
|
36
|
+
export rvm_install_on_use_flag=1
|
37
|
+
export rvm_gemset_create_on_use_flag=1
|
38
|
+
|
39
|
+
export rvm_project_rvmrc_default=1
|
40
|
+
export rvm_trust_rvmrcs_flag=1
|
41
|
+
RVMRC
|
42
|
+
|
43
|
+
put rvmrc, "#{user_home}/.rvmrc"
|
44
|
+
end
|
45
|
+
|
46
|
+
desc <<-DESC
|
47
|
+
[internal] Installs the requisite line in the .bashrc file which will load
|
48
|
+
RVM when the user logs in.
|
49
|
+
DESC
|
50
|
+
task :bashrc do
|
51
|
+
run %Q{echo "[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"" >> #{user_home}/.bashrc}
|
52
|
+
end
|
53
|
+
|
54
|
+
desc <<-DESC
|
55
|
+
Installs RVM for whichever user is currently being used with Capistrano.
|
56
|
+
DESC
|
57
|
+
task :default do
|
58
|
+
run "bash < <(curl http://rvm.beginrescueend.com/releases/rvm-install-head)"
|
59
|
+
rvm.install.for_user.bashrc
|
60
|
+
rvm.install.for_user.rvmrc
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc <<-DESC
|
65
|
+
[internal] This task will symlink the .rvm directory from the deployment user to the management user's home directory.
|
66
|
+
|
67
|
+
It doesn't do any good to have a different RVM installed for the deployment user and management user.
|
68
|
+
|
69
|
+
It will also create a .rvmrc file in the management user's home directory.
|
70
|
+
DESC
|
71
|
+
task :manager_symlink do
|
72
|
+
run "ln -sfn #{deployment_user_home}/.rvm #{manager_user_home}/.rvm"
|
73
|
+
rvm.install.for_user.rvmrc
|
74
|
+
rvm.install.for_user.bashrc
|
75
|
+
end
|
76
|
+
|
77
|
+
desc <<-DESC
|
78
|
+
[internal] Install RVM on Ubuntu.
|
79
|
+
DESC
|
80
|
+
task :on_ubuntu do
|
81
|
+
rvm.install.prerequisites
|
82
|
+
rvm.install.for_user.default
|
83
|
+
rvm.install.manager_symlink
|
84
|
+
end
|
85
|
+
|
86
|
+
desc <<-DESC
|
87
|
+
Installs RVM on the server.
|
88
|
+
|
89
|
+
Installs RVM for the deployment user. The deployment user will own RVM
|
90
|
+
but it will also be available for the management user as well via a symlink.
|
91
|
+
|
92
|
+
Both users will also have a .rvmrc file installed.
|
93
|
+
DESC
|
94
|
+
task :default do
|
95
|
+
rvm.install.send("on_#{os_type}")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :sqlite3 do
|
3
|
+
desc "Install SQLite3"
|
4
|
+
task :install_on_ubuntu, :roles => [:ubuntu, :sqlite3, :db] do
|
5
|
+
set :dependencies, %w{sqlite3 libsqlite3-ruby}
|
6
|
+
os.package_manager.install
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :deploy do
|
3
|
+
task :tag do
|
4
|
+
raise "Tagging deployments with Subversion has not been implemented yet."
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :svn do
|
9
|
+
desc "Install Subversion"
|
10
|
+
task :install_on_ubuntu do
|
11
|
+
set :dependencies, %w{subversion}
|
12
|
+
os.package_manager.install
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Install Subversion"
|
16
|
+
task :install do
|
17
|
+
svn.send("install_on_#{os_type}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,235 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
######################################################################
|
3
|
+
# UBUNTU SERVER TASKS #
|
4
|
+
######################################################################
|
5
|
+
set :os_type, "ubuntu"
|
6
|
+
|
7
|
+
before "deploy:config:symlink", "deploy:config:create"
|
8
|
+
|
9
|
+
run_task "os:package_manager:update", :as => "manager"
|
10
|
+
run_task "os:development_tools:install_common", :as => "manager"
|
11
|
+
|
12
|
+
namespace :deploy do
|
13
|
+
namespace :config do
|
14
|
+
desc <<-DESC
|
15
|
+
Creates the directory where the `symlink` task will look for its configuration files.
|
16
|
+
|
17
|
+
It will first look in the user's home directory to see if there is
|
18
|
+
a file of the same name as one of the shared files. If there is, it
|
19
|
+
will move that to the shared location. If not, it will create an
|
20
|
+
empty file.
|
21
|
+
DESC
|
22
|
+
task :create do
|
23
|
+
run "if [ ! -d #{shared_path}/config ]; then mkdir -p #{shared_path}/config; fi"
|
24
|
+
|
25
|
+
global_shared_files.each do |shared_file|
|
26
|
+
local_shared_file = "#{shared_file}.#{rails_env}"
|
27
|
+
|
28
|
+
if File.exists?(local_shared_file)
|
29
|
+
top.upload(local_shared_file, "#{shared_path}/#{shared_file}", :mode => "400")
|
30
|
+
else
|
31
|
+
run "touch #{shared_path}/#{shared_file}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc <<-DESC
|
37
|
+
Symlinks sensitive configuration files which shouldn't be checked into source control.
|
38
|
+
|
39
|
+
By default, these live in the shared directory that Capistrano sets up.
|
40
|
+
DESC
|
41
|
+
task :symlink do
|
42
|
+
global_shared_files.each do |shared_file|
|
43
|
+
run "ln -nfs #{shared_path}/#{shared_file} #{latest_release}/#{shared_file}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
run_task 'os:users:manager:create', :as => "root"
|
50
|
+
run_task 'os:users:deploy:create', :as => "root"
|
51
|
+
|
52
|
+
run_task 'os:users:deploy:public_key:authorize', :as => "deploy"
|
53
|
+
run_task 'os:users:deploy:public_key:create', :as => "deploy"
|
54
|
+
run_task 'os:users:manager:public_key:authorize', :as => "manager"
|
55
|
+
run_task 'os:users:manager:public_key:create', :as => "manager"
|
56
|
+
|
57
|
+
namespace :os do
|
58
|
+
namespace :users do
|
59
|
+
desc <<-DESC
|
60
|
+
Creates the users which will be used to interact with the system.
|
61
|
+
|
62
|
+
This task will create both the `deploy` user and the `manager` user.
|
63
|
+
DESC
|
64
|
+
task :create do
|
65
|
+
os.users.manager.create
|
66
|
+
os.users.deploy.create
|
67
|
+
end
|
68
|
+
|
69
|
+
desc <<-DESC
|
70
|
+
Installs the local public key as an authorized key for the manager user and deployment user on the remote system.
|
71
|
+
DESC
|
72
|
+
task :authorize_public_keys do
|
73
|
+
os.users.manager.public_key.authorize
|
74
|
+
os.users.deploy.public_key.authorize
|
75
|
+
end
|
76
|
+
|
77
|
+
desc <<-DESC
|
78
|
+
[internal] Installs the local public key as an authorized key for the current user.
|
79
|
+
DESC
|
80
|
+
task :authorize_public_key_for_current_user do
|
81
|
+
pk = exists?(:public_key) ? public_key : `cat $HOME/.ssh/id_rsa.pub`
|
82
|
+
|
83
|
+
run "if [ ! -d .ssh ]; then mkdir .ssh; fi"
|
84
|
+
run "echo \"#{pk}\" > ./.ssh/authorized_keys"
|
85
|
+
run "chmod 600 ./.ssh/authorized_keys"
|
86
|
+
end
|
87
|
+
|
88
|
+
desc <<-DESC
|
89
|
+
[internal] Creates a public/private key pair for the current user.
|
90
|
+
DESC
|
91
|
+
task :create_key_pair_for_current_user do
|
92
|
+
set(:public_key_passphrase) {Capistrano::CLI.password_prompt("Public Key Passphrase: ")}
|
93
|
+
hostname = capture("echo $HOSTNAME").chomp
|
94
|
+
run %Q{ssh-keygen -t rsa -C "#{hostname}@#{domain}" -P "#{public_key_passphrase}" -f ~/.ssh/id_rsa}
|
95
|
+
end
|
96
|
+
|
97
|
+
namespace :root do
|
98
|
+
desc <<-DESC
|
99
|
+
[internal] Switches Capistrano to use the root user for all subsequent SSH actions.
|
100
|
+
|
101
|
+
It will prompt for the root user's password the first time it's needed.
|
102
|
+
(If the Kompanee Bash environment has been installed, you will no longer
|
103
|
+
be able to log in as root.)
|
104
|
+
DESC
|
105
|
+
task :use do
|
106
|
+
set_user_to("root")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
namespace :manager do
|
111
|
+
desc <<-DESC
|
112
|
+
Creates the manager user on the remote system.
|
113
|
+
|
114
|
+
If the user already exists, this task will fail.
|
115
|
+
DESC
|
116
|
+
task :create do
|
117
|
+
run "useradd #{manager_username} --create-home --shell /bin/bash"
|
118
|
+
run "rm /home/#{manager_username}/.bashrc"
|
119
|
+
end
|
120
|
+
|
121
|
+
desc <<-DESC
|
122
|
+
Switches Capistrano to use the manager user for all subsequent SSH actions.
|
123
|
+
|
124
|
+
It will prompt for the manager user's password the first time it's needed.
|
125
|
+
(If public key authentication is already installed, you will not be prompted.)
|
126
|
+
DESC
|
127
|
+
task :use do
|
128
|
+
set_user_to(manager_username)
|
129
|
+
end
|
130
|
+
|
131
|
+
namespace :public_key do
|
132
|
+
desc <<-DESC
|
133
|
+
Sets the current local public key as an authorized user for the manager user.
|
134
|
+
|
135
|
+
If there is a `public_key` variable set, it will use that.
|
136
|
+
Otherwise, if `public_key` is not set, it will look in the default
|
137
|
+
`~/.ssh/id_rsa.pub` file.
|
138
|
+
DESC
|
139
|
+
task :authorize do
|
140
|
+
os.users.authorize_public_key_for_current_user
|
141
|
+
end
|
142
|
+
|
143
|
+
desc <<-DESC
|
144
|
+
Creates a public/private key pair set that can be used when logging into other systems.
|
145
|
+
|
146
|
+
* It will be installed at `/home/deploy/.ssh/id_rsa`.
|
147
|
+
* You will be prompted for a passphrase which will be attached to the key.
|
148
|
+
DESC
|
149
|
+
task :create do
|
150
|
+
os.users.create_key_pair_for_current_user
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
namespace :deploy do
|
156
|
+
desc <<-DESC
|
157
|
+
Creates the deployment user on the remote system.
|
158
|
+
|
159
|
+
If the user already exists, this task will fail.
|
160
|
+
DESC
|
161
|
+
task :create do
|
162
|
+
run "useradd #{deployment_username} --create-home --shell /bin/bash"
|
163
|
+
run "rm /home/#{deployment_username}/.bashrc"
|
164
|
+
end
|
165
|
+
|
166
|
+
desc <<-DESC
|
167
|
+
Switches Capistrano to use the deployment user for all subsequent SSH actions.
|
168
|
+
|
169
|
+
It will prompt for the deployment user's password the first time it's needed.
|
170
|
+
(If public key authentication is already installed, you will not be prompted.)
|
171
|
+
DESC
|
172
|
+
task :use do
|
173
|
+
set_user_to(deployment_username)
|
174
|
+
end
|
175
|
+
|
176
|
+
namespace :public_key do
|
177
|
+
desc <<-DESC
|
178
|
+
Sets the current local public key as an authorized user for the deployment user.
|
179
|
+
|
180
|
+
If there is a `public_key` variable set, it will use that.
|
181
|
+
Otherwise, if `public_key` is not set, it will look in the default
|
182
|
+
`~/.ssh/id_rsa.pub` file.
|
183
|
+
DESC
|
184
|
+
task :authorize do
|
185
|
+
os.users.authorize_public_key_for_current_user
|
186
|
+
end
|
187
|
+
|
188
|
+
desc <<-DESC
|
189
|
+
Creates a public/private key pair set that can be used when logging into other systems.
|
190
|
+
|
191
|
+
* It will be installed at `/home/deploy/.ssh/id_rsa`.
|
192
|
+
* You will be prompted for a passphrase which will be attached to the key.
|
193
|
+
DESC
|
194
|
+
task :create do
|
195
|
+
os.users.create_key_pair_for_current_user
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
namespace :package_manager do
|
202
|
+
desc <<-DESC
|
203
|
+
Runs the OS's package manager and updates its list of available packages.
|
204
|
+
|
205
|
+
This does NOT upgrade the installed packages.
|
206
|
+
DESC
|
207
|
+
task :update do
|
208
|
+
run "#{sudo} apt-get update"
|
209
|
+
end
|
210
|
+
|
211
|
+
desc <<-DESC
|
212
|
+
[internal] Uses the OS's built-in package manager to install a list of packages.
|
213
|
+
|
214
|
+
This task looks at the `dependencies` variable for an array of package names.
|
215
|
+
Once all packages are installed, the `dependencies` variable is unset.
|
216
|
+
DESC
|
217
|
+
task :install do
|
218
|
+
dependencies.each do |package|
|
219
|
+
run "#{sudo} apt-get install #{package} -y"
|
220
|
+
end
|
221
|
+
unset :dependencies
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
namespace :development_tools do
|
226
|
+
desc <<-DESC
|
227
|
+
Installs the development packages typically required for most deployments.
|
228
|
+
DESC
|
229
|
+
task :install_common do
|
230
|
+
set :dependencies, %w{libcurl4-openssl-dev build-essential debconf-utils libxslt-dev libxml2-dev}
|
231
|
+
os.package_manager.install
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|