prun-ops 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -10
- data/lib/capistrano/all.rake +11 -15
- data/lib/capistrano/config/app.rake +32 -0
- data/lib/capistrano/config/config.rake +11 -0
- data/lib/capistrano/config/mysql.rake +49 -0
- data/lib/capistrano/config/nginx.rake +42 -0
- data/lib/capistrano/config/nodejs.rake +14 -0
- data/lib/capistrano/config/postgres.rake +42 -0
- data/lib/capistrano/config/rails.rake +15 -0
- data/lib/capistrano/config/ruby.rake +12 -0
- data/lib/capistrano/config/templates/app_init.sh.erb +27 -0
- data/lib/capistrano/config/templates/vhost.conf.erb +26 -0
- data/lib/capistrano/config/templates/vhost_ssl.conf.erb +47 -0
- data/lib/capistrano/config/ubuntu.rake +15 -0
- data/lib/capistrano/prun-ops.rb +10 -1
- data/lib/prun-ops/version.rb +1 -1
- data/prun-ops.gemspec +4 -3
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fa149a50805a9dd853c00afe0bc120200091e9c
|
4
|
+
data.tar.gz: 76fb64a75dcdc544bd1e3ad3e2f4b5607737ed60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a8236ff360b1713e7c9543b759f08f913a19dd1ee34fe04e3680a560109b02c19f93619e3e9d8308cc8f94e656d468cb74c04cf6f1862454f64925944eeb05b
|
7
|
+
data.tar.gz: 640239f6a2d0271af6ec2b7e51da9f466f6b117584040e082cbb6c6ce139ecc19b044d6a703ec0f6011cd122821d3407e375704bee14c54a4d853696a83bf1ad
|
data/README.md
CHANGED
@@ -2,16 +2,12 @@
|
|
2
2
|
|
3
3
|
Covers all Deployment and maintainance Operations in a Ruby on Rails Application server:
|
4
4
|
|
5
|
-
1.
|
5
|
+
1. CONFIGURATION: Capistrano tasks to configure servers.
|
6
|
+
1. DEPLOYMENT: Capistrano tasks to deploy your rails Apps.
|
6
7
|
1. DIAGNOSIS: Capistrano diagnosis tools to guet your Apps status on real time.
|
7
8
|
1. RELEASE: Rake tasks to manage and tag version number in your Apps (X.Y.Z).
|
8
9
|
1. BACKUP: Backup policy for database and files in your Apps, using git as storage.
|
9
10
|
|
10
|
-
Based on:
|
11
|
-
|
12
|
-
* [PRUN Docker image](https://registry.hub.docker.com/u/jlebrijo/prun/).
|
13
|
-
* [PRUN Chef recipe](https://github.com/jlebrijo/prun-cfg).
|
14
|
-
|
15
11
|
## Installation
|
16
12
|
|
17
13
|
Add this line to your application's Gemfile:
|
@@ -58,9 +54,32 @@ server "example.com", user: 'root', roles: %w{web app db}, port: 2222
|
|
58
54
|
|
59
55
|
Note: Remember change this line in production.rb file: `config.assets.compile = true`
|
60
56
|
|
57
|
+
### Configuration
|
58
|
+
|
59
|
+
Main task is `cap [stg] config`
|
60
|
+
|
61
|
+
Secondary tasks:
|
62
|
+
|
63
|
+
* `cap [stg] ubuntu:install` initial ubuntu dependencies
|
64
|
+
* `cap [stg] ruby:install` install ruby on .ruby-version version
|
65
|
+
* `cap [stg] rails:prepare` install rails dependencies
|
66
|
+
* `cap [stg] postgres:install` install and configure postgres
|
67
|
+
* `cap [stg] postgres:[start|stop|restart]` start/stop postgres
|
68
|
+
* `cap [stg] nginx:install` install and configure nginx
|
69
|
+
* `cap [stg] nginx:[start|stop|restart]` start/stop nginx
|
70
|
+
* `cap [stg] nodejs:install` install node
|
71
|
+
* `cap [stg] app:prepare` create init scripts
|
72
|
+
* `cap [stg] app:db_prepare` database first load
|
73
|
+
* `cap [stg] nginx:cert` create SSL certificates with [Let's Encrypt](https://letsencrypt.org/)
|
74
|
+
* `cap [stg] nginx:ssl` configure nginx with SSL certificates
|
75
|
+
|
61
76
|
### Deployment
|
62
77
|
|
63
|
-
|
78
|
+
Main task is `cap [stg] deploy`
|
79
|
+
|
80
|
+
Secondary tasks:
|
81
|
+
|
82
|
+
* `cap [stg] deploy:upload_linked_files` uploads configuration files defined as linked_files
|
64
83
|
* `cap [stg] deploy` deploy your app as usual
|
65
84
|
* `cap [stg] deploy:restart` restart thin server of this application
|
66
85
|
* `cap [stg] deploy:stop` stop thin server
|
@@ -129,8 +148,6 @@ Some capistrano commands useful to connect to server and help with the problem s
|
|
129
148
|
|
130
149
|
### Monitoring
|
131
150
|
|
132
|
-
Recommend to configure your Rails server with [PRUN Chef recipe](https://github.com/jlebrijo/prun-cfg).
|
133
|
-
|
134
151
|
At this moment we are implementing [NewRelic](http://newrelic.com/) monitoring, including as dependency ['newrelic_rpm'](https://github.com/newrelic/rpm) gem. To configure yourproject you just need to create an account at [NewRelic](http://newrelic.com/) and follow the instructions (creating a 'config/newrelic.yml file with your license_key).
|
135
152
|
|
136
153
|
### TODO: Configuration management
|
@@ -221,4 +238,8 @@ require 'capistrano/prun-ops'
|
|
221
238
|
|
222
239
|
### v0.1.6
|
223
240
|
|
224
|
-
* Add `cap stage rake[db:create]` to execute a rake task in remote server.
|
241
|
+
* Add `cap stage rake[db:create]` to execute a rake task in remote server.
|
242
|
+
|
243
|
+
### v0.2.0
|
244
|
+
|
245
|
+
* Configuration tasks: Add `cap stage config` and other tasks.
|
data/lib/capistrano/all.rake
CHANGED
@@ -16,23 +16,19 @@ namespace :deploy do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
invoke 'deploy:db_reset' # This replaces deploy:migrations
|
28
|
-
invoke 'deploy:compile_assets'
|
29
|
-
invoke 'deploy:normalize_assets'
|
30
|
-
invoke 'deploy:publishing'
|
31
|
-
invoke 'deploy:published'
|
32
|
-
invoke 'deploy:finishing'
|
33
|
-
invoke 'deploy:finished'
|
19
|
+
task :upload_linked_files do
|
20
|
+
on roles :app do
|
21
|
+
shared = "/var/www/#{fetch :application}/shared"
|
22
|
+
fetch(:linked_files).each do |f|
|
23
|
+
execute "mkdir -p #{shared}/#{File.dirname f}"
|
24
|
+
upload! f, "#{shared}/#{f}"
|
25
|
+
end
|
26
|
+
end
|
34
27
|
end
|
35
28
|
|
29
|
+
after :publishing, :upload_linked_files
|
30
|
+
after :publishing, :restart
|
31
|
+
|
36
32
|
desc 'Create database'
|
37
33
|
task :db_create do
|
38
34
|
on roles(:db) do
|
@@ -0,0 +1,32 @@
|
|
1
|
+
namespace :app do
|
2
|
+
|
3
|
+
task :prepare do
|
4
|
+
on roles :web do
|
5
|
+
template 'app_init.sh', "/etc/init.d/#{fetch :application}"
|
6
|
+
execute <<-EOBLOCK
|
7
|
+
sudo thin config -C /etc/thin/#{fetch :application}.yml -c /var/www/#{fetch :application}/current -l log/thin.log -e #{fetch :stage} --servers 1 --port 3000
|
8
|
+
sudo chmod a+x /etc/init.d/#{fetch :application}
|
9
|
+
sudo update-rc.d #{fetch :application} defaults
|
10
|
+
sudo systemctl daemon-reload
|
11
|
+
EOBLOCK
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
task :db_prepare do
|
16
|
+
invoke 'deploy:starting'
|
17
|
+
invoke 'deploy:started'
|
18
|
+
invoke 'deploy:updating'
|
19
|
+
invoke 'bundler:install'
|
20
|
+
if Rails.application.config.respond_to? :backup_repo
|
21
|
+
invoke 'backup:restore'
|
22
|
+
else
|
23
|
+
invoke 'deploy:db_create'
|
24
|
+
invoke 'deploy:migrate'
|
25
|
+
invoke 'deploy:db_seed'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
task :test do
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
task :config do
|
2
|
+
invoke 'ubuntu:install'
|
3
|
+
invoke 'ruby:install'
|
4
|
+
invoke 'rails:prepare'
|
5
|
+
invoke 'postgres:install'
|
6
|
+
invoke 'nginx:install'
|
7
|
+
invoke 'nodejs:install'
|
8
|
+
invoke 'app:prepare'
|
9
|
+
invoke 'deploy:upload_linked_files'
|
10
|
+
invoke 'app:db_prepare'
|
11
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
namespace :mysql do
|
2
|
+
task :install do
|
3
|
+
on roles :db do
|
4
|
+
not_if 'which mysql' do
|
5
|
+
execute <<-EOBLOCK
|
6
|
+
debconf-set-selections <<< 'mysql-server mysql-server/root_password password #{fetch :my_pass}'
|
7
|
+
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password #{fetch :my_pass}'
|
8
|
+
apt-get install -y mysql-server mysql-client libmysqlclient-dev
|
9
|
+
EOBLOCK
|
10
|
+
end
|
11
|
+
|
12
|
+
not_if "mysql --user='root' --password='#{fetch :my_pass}' --execute='show databases;' | grep #{fetch :application}" do
|
13
|
+
execute <<-EOBLOCK
|
14
|
+
mysql --user='root' --password='#{fetch :my_pass}' --execute='create database #{fetch :application};'
|
15
|
+
mysql --user='root' --password='#{fetch :my_pass}' --execute="grant all on #{fetch :application}.* to #{fetch :my_user}@'%' identified by '#{fetch :my_pass}';"
|
16
|
+
EOBLOCK
|
17
|
+
end
|
18
|
+
|
19
|
+
invoke 'mysql:restart'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
task :test do
|
25
|
+
on roles :db do
|
26
|
+
not_if "echo ''" do
|
27
|
+
p 'executing ......'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
%w(start stop restart).each do |action|
|
34
|
+
desc "MySQL"
|
35
|
+
task :"#{action}" do
|
36
|
+
on roles(:app) do
|
37
|
+
execute "sudo service mysql #{action}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def not_if(command)
|
44
|
+
begin
|
45
|
+
yield unless execute command
|
46
|
+
rescue Exception
|
47
|
+
yield
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
namespace :nginx do
|
2
|
+
task :install do
|
3
|
+
on roles :web do
|
4
|
+
execute 'sudo apt-get install -y nginx'
|
5
|
+
execute 'sed -i "s/# server_names_hash_bucket_size 64/server_names_hash_bucket_size 64/" /etc/nginx/nginx.conf'
|
6
|
+
template 'vhost.conf', '/etc/nginx/conf.d/vhost.conf'
|
7
|
+
|
8
|
+
invoke 'nginx:restart'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
task :cert do
|
13
|
+
on roles(:web) do |host|
|
14
|
+
run_locally do
|
15
|
+
run_in host, <<-EOBLOCK
|
16
|
+
cd /usr/local/sbin
|
17
|
+
sudo wget https://dl.eff.org/certbot-auto
|
18
|
+
sudo chmod a+x /usr/local/sbin/certbot-auto
|
19
|
+
mkdir /var/www/#{fetch :application}/current/public/.well-known
|
20
|
+
sudo certbot-auto certonly -a webroot --webroot-path=/var/www/#{fetch :application}/current/public -d #{host.hostname}
|
21
|
+
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
|
22
|
+
EOBLOCK
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
task :ssl do
|
28
|
+
on roles(:web) do |host|
|
29
|
+
template 'vhost_ssl.conf', '/etc/nginx/conf.d/vhost.conf'
|
30
|
+
invoke 'nginx:restart'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
%w(start stop restart status).each do |action|
|
35
|
+
desc "Nginx"
|
36
|
+
task :"#{action}" do
|
37
|
+
on roles(:app) do
|
38
|
+
execute "sudo service nginx #{action}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
namespace :nodejs do
|
2
|
+
task :install do
|
3
|
+
on roles :app do
|
4
|
+
execute 'curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash'
|
5
|
+
#sed -i "s/[ -z "$PS1" ] && return/# [ -z "$PS1" ] && return/g" /root/.bashrc
|
6
|
+
execute <<-EOBLOCK
|
7
|
+
export NVM_DIR="$HOME/.nvm"
|
8
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
9
|
+
nvm install node
|
10
|
+
npm install -g bower
|
11
|
+
EOBLOCK
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
namespace :postgres do
|
2
|
+
task :install do
|
3
|
+
stage = fetch(:stage).to_s
|
4
|
+
config = Rails.configuration.database_configuration
|
5
|
+
version = config[stage]["version"]
|
6
|
+
username = config[stage]["username"]
|
7
|
+
password = config[stage]["password"]
|
8
|
+
|
9
|
+
on roles :db do
|
10
|
+
execute <<-EOBLOCK
|
11
|
+
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
|
12
|
+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
13
|
+
sudo apt-get update
|
14
|
+
export LANGUAGE=en_US.UTF-8
|
15
|
+
sudo apt-get -y install postgresql-#{version} libpq-dev
|
16
|
+
EOBLOCK
|
17
|
+
|
18
|
+
execute <<-EOBLOCK
|
19
|
+
sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = 'localhost'/" /etc/postgresql/#{version}/main/postgresql.conf
|
20
|
+
sudo sed -i "s/local all all peer/local all all md5/" /etc/postgresql/#{version}/main/pg_hba.conf
|
21
|
+
sudo sed -i "s/ssl = true/ssl = false/" /etc/postgresql/#{version}/main/postgresql.conf
|
22
|
+
sudo service postgresql restart
|
23
|
+
EOBLOCK
|
24
|
+
|
25
|
+
## Rewrite postgres password:
|
26
|
+
execute <<-EOBLOCK
|
27
|
+
sudo -u postgres psql -c "ALTER USER #{username} WITH PASSWORD '#{password}';"
|
28
|
+
EOBLOCK
|
29
|
+
|
30
|
+
invoke 'postgres:restart'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
%w(start stop restart).each do |action|
|
35
|
+
desc "PostgreSQL"
|
36
|
+
task :"#{action}" do
|
37
|
+
on roles(:app) do
|
38
|
+
execute "sudo service postgresql #{action}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
namespace :rails do
|
2
|
+
task :prepare do
|
3
|
+
on roles :app do
|
4
|
+
execute <<-EOBLOCK
|
5
|
+
echo gem: --no-ri --no-rdoc > /root/.gemrc
|
6
|
+
gem install bundler
|
7
|
+
gem install rack -v 1.6.0
|
8
|
+
gem install thin -v 1.6.3
|
9
|
+
thin install
|
10
|
+
/usr/sbin/update-rc.d -f thin defaults
|
11
|
+
EOBLOCK
|
12
|
+
execute 'apt-get install -y imagemagick libmagickwand-dev'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace :ruby do
|
2
|
+
task :install do
|
3
|
+
ruby_version = File.read('.ruby-version').strip[/\Aruby-(.*)\.\d\Z/,1]
|
4
|
+
on roles :app do
|
5
|
+
execute <<-EOBLOCK
|
6
|
+
sudo apt-add-repository -y ppa:brightbox/ruby-ng
|
7
|
+
apt-get update
|
8
|
+
sudo apt-get install -y ruby#{ruby_version} ruby#{ruby_version}-dev
|
9
|
+
EOBLOCK
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Starts and stops $APP
|
3
|
+
# Adding a Service to Default runlevels
|
4
|
+
# update-rc.d $APP defaults
|
5
|
+
#
|
6
|
+
|
7
|
+
APP=<%= fetch :application%>
|
8
|
+
ENV=<%= fetch :stage%>
|
9
|
+
|
10
|
+
case "$1" in
|
11
|
+
start)
|
12
|
+
cd /var/www/$APP/current && RAILS_ENV=$ENV bundle exec thin start -C /etc/thin/$APP.yml
|
13
|
+
;;
|
14
|
+
|
15
|
+
stop)
|
16
|
+
cd /var/www/$APP/current && RAILS_ENV=$ENV bundle exec thin stop -C /etc/thin/$APP.yml
|
17
|
+
;;
|
18
|
+
|
19
|
+
restart)
|
20
|
+
$0 stop
|
21
|
+
$0 start
|
22
|
+
;;
|
23
|
+
|
24
|
+
*)
|
25
|
+
echo "Usage: $0 {start|stop|restart|status}"
|
26
|
+
exit 1
|
27
|
+
esac
|
@@ -0,0 +1,26 @@
|
|
1
|
+
upstream <%= fetch :application%> {
|
2
|
+
server localhost:3000;
|
3
|
+
}
|
4
|
+
|
5
|
+
|
6
|
+
server {
|
7
|
+
server_name <%= host.hostname %>;
|
8
|
+
root /var/www/<%= fetch :application%>/current/public;
|
9
|
+
|
10
|
+
location @<%= fetch :application%> {
|
11
|
+
proxy_pass http://<%= fetch :application%>;
|
12
|
+
proxy_set_header Host $host;
|
13
|
+
proxy_set_header X-Real-IP $remote_addr;
|
14
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
15
|
+
proxy_read_timeout 90;
|
16
|
+
}
|
17
|
+
location / {
|
18
|
+
try_files $uri @<%= fetch :application%> ;
|
19
|
+
index index.html index.htm index.php;
|
20
|
+
}
|
21
|
+
location /status {
|
22
|
+
stub_status on;
|
23
|
+
allow all;
|
24
|
+
}
|
25
|
+
|
26
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
upstream <%= fetch :application%> {
|
2
|
+
server localhost:3000;
|
3
|
+
}
|
4
|
+
|
5
|
+
|
6
|
+
server {
|
7
|
+
listen 443 ssl;
|
8
|
+
server_name <%= host.hostname %>;
|
9
|
+
root /var/www/<%= fetch :application%>/current/public;
|
10
|
+
|
11
|
+
ssl_certificate /etc/letsencrypt/live/<%= host.hostname %>/fullchain.pem;
|
12
|
+
ssl_certificate_key /etc/letsencrypt/live/<%= host.hostname %>/privkey.pem;
|
13
|
+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
14
|
+
ssl_prefer_server_ciphers on;
|
15
|
+
ssl_dhparam /etc/ssl/certs/dhparam.pem;
|
16
|
+
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
|
17
|
+
ssl_session_timeout 1d;
|
18
|
+
ssl_session_cache shared:SSL:50m;
|
19
|
+
ssl_stapling on;
|
20
|
+
ssl_stapling_verify on;
|
21
|
+
add_header Strict-Transport-Security max-age=15768000;
|
22
|
+
|
23
|
+
location @<%= fetch :application%> {
|
24
|
+
proxy_pass http://<%= fetch :application%>;
|
25
|
+
proxy_set_header Host $host;
|
26
|
+
proxy_set_header X-Real-IP $remote_addr;
|
27
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
28
|
+
proxy_read_timeout 90;
|
29
|
+
}
|
30
|
+
location / {
|
31
|
+
try_files $uri @<%= fetch :application%> ;
|
32
|
+
index index.html index.htm index.php;
|
33
|
+
}
|
34
|
+
location /status {
|
35
|
+
stub_status on;
|
36
|
+
allow all;
|
37
|
+
}
|
38
|
+
location ~ /.well-known {
|
39
|
+
allow all;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
server {
|
44
|
+
listen 80;
|
45
|
+
server_name <%= host.hostname %>;
|
46
|
+
return 301 https://$host$request_uri;
|
47
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
namespace :ubuntu do
|
2
|
+
task :install do
|
3
|
+
on roles :app do
|
4
|
+
execute 'apt-get -y update'
|
5
|
+
# Pre-requirements
|
6
|
+
execute <<-EOBLOCK
|
7
|
+
apt-get install -y git build-essential libsqlite3-dev libssl-dev gawk g++ vim
|
8
|
+
apt-get install -y libreadline6-dev libyaml-dev sqlite3 autoconf libgdbm-dev
|
9
|
+
apt-get install -y libcurl3 libcurl3-gnutls libcurl4-openssl-dev
|
10
|
+
apt-get install -y libncurses5-dev automake libtool bison pkg-config libffi-dev
|
11
|
+
apt-get install -y software-properties-common
|
12
|
+
EOBLOCK
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/capistrano/prun-ops.rb
CHANGED
@@ -1 +1,10 @@
|
|
1
|
-
Dir.glob("#{File.dirname(__FILE__)}/*.rake").each { |r| load r }
|
1
|
+
Dir.glob("#{File.dirname(__FILE__)}/*.rake").each { |r| load r }
|
2
|
+
Dir.glob("#{File.dirname(__FILE__)}/config/*.rake").each { |r| load r }
|
3
|
+
|
4
|
+
## Common libraries
|
5
|
+
def template(template_name, target_path)
|
6
|
+
file = File.read("#{File.dirname(__FILE__)}/config/templates/#{template_name}.erb")
|
7
|
+
template = ERB.new file, nil, "%"
|
8
|
+
rendered = template.result(binding)
|
9
|
+
upload! StringIO.new(rendered), target_path
|
10
|
+
end
|
data/lib/prun-ops/version.rb
CHANGED
data/prun-ops.gemspec
CHANGED
@@ -20,7 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_development_dependency "bundler", "~> 1.6"
|
21
21
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
22
|
|
23
|
-
spec.add_runtime_dependency
|
24
|
-
spec.add_runtime_dependency
|
25
|
-
spec.add_runtime_dependency
|
23
|
+
spec.add_runtime_dependency 'capistrano', '~> 3.8'
|
24
|
+
spec.add_runtime_dependency 'capistrano-rails'
|
25
|
+
spec.add_runtime_dependency 'thin'
|
26
|
+
spec.add_runtime_dependency 'newrelic_rpm'
|
26
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prun-ops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Lebrijo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: capistrano
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.8'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.8'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: capistrano-rails
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,6 +110,18 @@ files:
|
|
96
110
|
- Rakefile
|
97
111
|
- lib/capistrano/all.rake
|
98
112
|
- lib/capistrano/backup.rake
|
113
|
+
- lib/capistrano/config/app.rake
|
114
|
+
- lib/capistrano/config/config.rake
|
115
|
+
- lib/capistrano/config/mysql.rake
|
116
|
+
- lib/capistrano/config/nginx.rake
|
117
|
+
- lib/capistrano/config/nodejs.rake
|
118
|
+
- lib/capistrano/config/postgres.rake
|
119
|
+
- lib/capistrano/config/rails.rake
|
120
|
+
- lib/capistrano/config/ruby.rake
|
121
|
+
- lib/capistrano/config/templates/app_init.sh.erb
|
122
|
+
- lib/capistrano/config/templates/vhost.conf.erb
|
123
|
+
- lib/capistrano/config/templates/vhost_ssl.conf.erb
|
124
|
+
- lib/capistrano/config/ubuntu.rake
|
99
125
|
- lib/capistrano/diagnosis.rake
|
100
126
|
- lib/capistrano/git.rake
|
101
127
|
- lib/capistrano/prun-ops.rb
|