easy-deployment 0.5.3 → 0.6.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.
- data/CHANGELOG.md +11 -0
- data/README.md +22 -2
- data/lib/easy-deployment/version.rb +1 -1
- data/lib/easy/deployment/capistrano.rb +29 -0
- data/lib/easy/deployment/dbreference.rb +1 -1
- data/lib/easy/deployment/nginx.rb +35 -0
- data/lib/easy/generators/stage_generator.rb +1 -0
- data/lib/easy/generators/templates/stage/nginx.conf.tt +28 -0
- metadata +4 -2
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changelog for easy-deployment
|
2
2
|
|
3
|
+
## 0.6.0 (2013-11-05)
|
4
|
+
|
5
|
+
Features:
|
6
|
+
|
7
|
+
* Clearer error message, by checking and raises an exception if you haven't added an ssh-key as an identity (`ssh-add -L`) since this is a pre-requisite for ssh-agent forwarding.
|
8
|
+
* Support for using nginx - intended to be along with a stand-alone ruby application server.
|
9
|
+
|
10
|
+
Bugfixes:
|
11
|
+
|
12
|
+
* Using builting `easy-reference` gem support now works with a custom bundler path if set.
|
13
|
+
|
3
14
|
## 0.5.3 (2013-09-05)
|
4
15
|
|
5
16
|
Bugfixes:
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Replace any missing configuration lines, and don't forget to remove the TODO tex
|
|
31
31
|
|
32
32
|
## Integration
|
33
33
|
|
34
|
-
### Apache
|
34
|
+
### Apache (via Passenger)
|
35
35
|
|
36
36
|
Automatically setup an Apache V-Host, and reload apache2:
|
37
37
|
|
@@ -43,7 +43,7 @@ Add to deploy.rb
|
|
43
43
|
|
44
44
|
require "easy/deployment/apache"
|
45
45
|
|
46
|
-
Customise the vhost file within `config/deploy/<stage>/apache
|
46
|
+
Customise the vhost file within `config/deploy/<stage>/apache.conf`
|
47
47
|
If necessary, you can set the path to the apache2ctl binary via:
|
48
48
|
|
49
49
|
set :apachectl_bin, "/usr/sbin/apachectl"
|
@@ -56,6 +56,26 @@ This assumes your deploy user has access to run the apachectl command with sudo
|
|
56
56
|
|
57
57
|
Read more about passenger configuration on our wiki at https://github.com/AbleTech/easy-deployment/wiki/Common-passenger-config
|
58
58
|
|
59
|
+
### Nginx (for use with standalone ruby app server)
|
60
|
+
|
61
|
+
Add to deploy.rb
|
62
|
+
|
63
|
+
require "easy/deployment/nginx"
|
64
|
+
|
65
|
+
Customise the site configuration within `config/deploy/<stage>/nginx.conf`
|
66
|
+
Alter the paths used if required:
|
67
|
+
|
68
|
+
set :nginx_bin, "/etc/init.d/nginx" # This is the default, change if necessary
|
69
|
+
set :nginx_dir, "/etc/nginx" # This is the default, change if necessary
|
70
|
+
|
71
|
+
Like the apache integration, this requires sudo privileges to reload nginx:
|
72
|
+
|
73
|
+
This example shows setting a passwordless sudo for a single user `deploy` for a limited set of commands controlling nginx
|
74
|
+
|
75
|
+
# Example sudoers file entries to grant deploy user passwordless sudo privileges to only these commands
|
76
|
+
deploy ALL=(ALL) NOPASSWD:/etc/init.d/nginx reload
|
77
|
+
deploy ALL=(ALL) NOPASSWD:/etc/init.d/nginx configtest
|
78
|
+
|
59
79
|
### Logrotate
|
60
80
|
|
61
81
|
Automatically configure logrotate for your application logfile:
|
@@ -61,6 +61,29 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
61
61
|
puts "Skipping copying of config/deploy/#{stage}/database.yml as the file is not present"
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
desc "[internal] Check ssh-key is added. ssh key forwarding deployments will fail without it"
|
66
|
+
# To disable this check set the variable `set :ignore_ssh_keys, true`
|
67
|
+
task :preflight_environment_check do
|
68
|
+
if fetch(:disable_agent_check, false) || !ssh_options[:forward_agent]
|
69
|
+
return true # Don't run the check if not using ssh agent forwarding
|
70
|
+
end
|
71
|
+
keys, status = run_local("ssh-add -L")
|
72
|
+
if fetch(:ignore_ssh_keys, false) || status != 0 || !(any_keys_registered = keys.chomp.split("\n").select {|line| line =~ /^ssh\-/ }.size > 0)
|
73
|
+
cmd_to_run = case RUBY_PLATFORM
|
74
|
+
when /darwin/
|
75
|
+
"ssh-add -K"
|
76
|
+
else
|
77
|
+
"ssh-add"
|
78
|
+
end
|
79
|
+
Capistrano::CLI.ui.say("<%= color('Error, no ssh-keys registered to be forwarded', :red) %>")
|
80
|
+
Capistrano::CLI.ui.say("<%= color('Run the following command to register your ssh-key then try again:', :red) %> #{cmd_to_run}")
|
81
|
+
Capistrano::CLI.ui.say("If you do not use ssh-agent-forwarding, put `set :disable_agent_check, true` in deploy.rb to disable this check")
|
82
|
+
exit(1)
|
83
|
+
else
|
84
|
+
Capistrano::CLI.ui.say("<%= color('ssh-keys are good to go captain!', :cyan) %>") if ENV['DEBUG']
|
85
|
+
end
|
86
|
+
end
|
64
87
|
end
|
65
88
|
|
66
89
|
namespace :tail do
|
@@ -91,9 +114,15 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
91
114
|
run %Q(printf "#{version_info}" > #{release_path}/version.txt)
|
92
115
|
end
|
93
116
|
|
117
|
+
before "deploy:update", "deploy:preflight_environment_check"
|
94
118
|
after "deploy:update", "tag_release"
|
95
119
|
after "deploy:update", "annotate_release"
|
96
120
|
|
121
|
+
def run_local(cmd, verbose = false)
|
122
|
+
result = `#{cmd}`
|
123
|
+
puts(result) if verbose
|
124
|
+
return [result, $?.exitstatus]
|
125
|
+
end
|
97
126
|
|
98
127
|
# Helper function to stream output colorized by host
|
99
128
|
def stream_output_from_command(cmd, continuous = false)
|
@@ -11,7 +11,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
11
11
|
else raise ArgumentError, "unknown migration target #{migrate_target.inspect}"
|
12
12
|
end
|
13
13
|
|
14
|
-
run "cd #{directory} && RAILS_ENV=#{rails_env} bundle exec rake reference:load"
|
14
|
+
run "cd #{directory} && RAILS_ENV=#{rails_env} #{fetch(:bundle_cmd, 'bundle')} exec rake reference:load"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Define some defaults for Capistrano deploys.
|
2
|
+
# To load this Capistrano configuration, require 'easy/deployment/nginx' from deploy.rb
|
3
|
+
|
4
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
5
|
+
def remote_file_exists?(full_path)
|
6
|
+
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
|
7
|
+
end
|
8
|
+
|
9
|
+
set :nginx_bin, "/etc/init.d/nginx"
|
10
|
+
set :nginx_dir, "/etc/nginx"
|
11
|
+
|
12
|
+
namespace :nginx do
|
13
|
+
desc "Configure this site, test the configuration & gracefully reload the Nginx configuration"
|
14
|
+
task :configure_and_reload, :roles => :web, :except => { :no_release => true } do
|
15
|
+
configure
|
16
|
+
configtest
|
17
|
+
reload
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Configure this site with config/deploy/nginx.conf)"
|
21
|
+
task :configure, :roles => :web, :except => { :no_release => true } do
|
22
|
+
run "cp -f #{current_path}/config/deploy/#{stage}/nginx.conf #{nginx_dir}/sites-available/#{application}"
|
23
|
+
run "ln -fs #{nginx_dir}/sites-available/#{application} #{nginx_dir}/sites-enabled/#{application}"
|
24
|
+
end
|
25
|
+
|
26
|
+
[:stop, :start, :restart, :reload, :configtest].each do |action|
|
27
|
+
desc "#{action.to_s.capitalize} Nginx"
|
28
|
+
task action, :roles => :web do
|
29
|
+
run "sudo #{nginx_bin} #{action.to_s}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
before 'deploy:start', 'nginx:configure_and_reload'
|
35
|
+
end
|
@@ -10,6 +10,7 @@ module Easy
|
|
10
10
|
directory("stage", "config/deploy/#{name}")
|
11
11
|
template("stage.rb.tt", "config/deploy/#{name}.rb")
|
12
12
|
template("stage/apache.conf.tt", "config/deploy/#{name}/apache.conf")
|
13
|
+
template("stage/nginx.conf.tt", "config/deploy/#{name}/nginx.conf")
|
13
14
|
|
14
15
|
# Ensure we have a config/environments/<env-name>.rb
|
15
16
|
dest = "config/environments/#{name}.rb"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
upstream <%= application_name %> {
|
2
|
+
server unix:///var/apps/<%= application_name %>/shared/sockets/<%= application_name %>.sock;
|
3
|
+
}
|
4
|
+
|
5
|
+
server {
|
6
|
+
listen 80;
|
7
|
+
server_name <%= name %>.<%= application_name %>.co.nz;
|
8
|
+
root /var/apps/<%= application_name %>/current/public;
|
9
|
+
|
10
|
+
location / {
|
11
|
+
proxy_pass http://<%= application_name %>; # match the name of upstream directive which is defined above
|
12
|
+
proxy_set_header Host $host;
|
13
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
14
|
+
}
|
15
|
+
|
16
|
+
location ~* ^/assets/ {
|
17
|
+
# Per RFC2616 - 1 year maximum expiry
|
18
|
+
expires 1y;
|
19
|
+
add_header Cache-Control public;
|
20
|
+
|
21
|
+
# Some browsers still send conditional-GET requests if there's a
|
22
|
+
# Last-Modified header or an ETag header even if they haven't
|
23
|
+
# reached the expiry date sent in the Expires header.
|
24
|
+
add_header Last-Modified "";
|
25
|
+
add_header ETag "";
|
26
|
+
break;
|
27
|
+
}
|
28
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy-deployment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-
|
15
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/easy/deployment/dbreference.rb
|
105
105
|
- lib/easy/deployment/logrotate.rb
|
106
106
|
- lib/easy/deployment/nfs.rb
|
107
|
+
- lib/easy/deployment/nginx.rb
|
107
108
|
- lib/easy/deployment/niet.rb
|
108
109
|
- lib/easy/deployment/performance.rb
|
109
110
|
- lib/easy/deployment/whenever.rb
|
@@ -119,6 +120,7 @@ files:
|
|
119
120
|
- lib/easy/generators/templates/stage.rb.tt
|
120
121
|
- lib/easy/generators/templates/stage/apache.conf.tt
|
121
122
|
- lib/easy/generators/templates/stage/logrotate.conf.tt
|
123
|
+
- lib/easy/generators/templates/stage/nginx.conf.tt
|
122
124
|
- spec/easy_deployment_spec.rb
|
123
125
|
- spec/spec_helper.rb
|
124
126
|
homepage: https://github.com/AbleTech/easy-deployment
|