recap 1.0.12 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/recap/tasks/bootstrap.rb +7 -7
- data/lib/recap/tasks/foreman.rb +9 -4
- data/lib/recap/tasks/preflight.rb +1 -1
- data/lib/recap/version.rb +1 -1
- data/spec/tasks/foreman_spec.rb +41 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83721ec6476d41384eea2d9b1eaf90aa1f85db56
|
4
|
+
data.tar.gz: 45d5968cdcdc68bc37ff9ab3a7ad0213256a6090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20772b8733768f091517741501fab00f540e7331f2ffc78d17da02dbd0a9cbbc93fc7fb040d144388cd31b70764aaa6a00c775a40ae824415846edc132489119
|
7
|
+
data.tar.gz: 678bd37303fe05e240130e231f813df9e335c70c205a7241ed815f233fdda083ab3915bbf8aa3d2363c3b59f17c5b2cabe21d3dd950a8e50f01100675873d94f
|
@@ -40,18 +40,18 @@ module Recap::Tasks::Bootstrap
|
|
40
40
|
# `env:edit` tasks). The script loads the `.env` file in the users home folder, creates
|
41
41
|
# a new copy with `export ` prefixed to each line, and sources this new copy.
|
42
42
|
put_as_app %{
|
43
|
-
if [ -s
|
44
|
-
sed -e 's/\\r//g' -e 's/^/export /g'
|
45
|
-
.
|
43
|
+
if [ -s #{application_home}/.env ]; then
|
44
|
+
sed -e 's/\\r//g' -e 's/^/export /g' #{application_home}/.env > #{application_home}/.recap-env-export
|
45
|
+
. #{application_home}/.recap-env-export
|
46
46
|
fi
|
47
47
|
}, "#{application_home}/.recap"
|
48
48
|
|
49
49
|
# Finally, `.profile` needs to source the `.recap` script, so that the configuration environment is
|
50
50
|
# available whenever the environment is loaded.
|
51
|
-
as_app "touch .profile", "
|
51
|
+
as_app "touch .profile", "#{application_home}"
|
52
52
|
|
53
|
-
if exit_code("grep '\\.
|
54
|
-
as_app %{echo ".
|
53
|
+
if exit_code("grep '\\. #{application_home}/\\.recap' #{application_home}/.profile") != "0"
|
54
|
+
as_app %{echo ". #{application_home}/.recap" >> .profile}, "#{application_home}"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -67,7 +67,7 @@ fi
|
|
67
67
|
sudo "usermod --append -G #{application_group} #{remote_username}"
|
68
68
|
|
69
69
|
if repository.match /github\.com/
|
70
|
-
run "(mkdir -p
|
70
|
+
run "(mkdir -p #{application_home}/.ssh && touch #{application_home}/.ssh/known_hosts && ssh-keygen -f #{application_home}/.ssh/known_hosts -H -F github.com | grep 'github.com') || ssh-keyscan -H github.com > #{application_home}/.ssh/known_hosts"
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
data/lib/recap/tasks/foreman.rb
CHANGED
@@ -12,6 +12,11 @@ module Recap::Tasks::Foreman
|
|
12
12
|
# Foreman startup scripts are exported in `upstart` format by default.
|
13
13
|
set(:foreman_export_format, "upstart")
|
14
14
|
|
15
|
+
# Foreman startup scripts are generated based on the standard templates by default
|
16
|
+
set(:foreman_template, nil)
|
17
|
+
|
18
|
+
set(:foreman_template_option) { foreman_template ? "--template #{foreman_template}" : nil}
|
19
|
+
|
15
20
|
# Scripts are exported (as the the application user) to a temporary location first.
|
16
21
|
set(:foreman_tmp_location) { "#{deploy_to}/tmp/foreman" }
|
17
22
|
|
@@ -19,12 +24,12 @@ module Recap::Tasks::Foreman
|
|
19
24
|
set(:foreman_export_location, "/etc/init")
|
20
25
|
|
21
26
|
# The standard foreman export.
|
22
|
-
set(:foreman_export_command) { "./bin/foreman export #{foreman_export_format} #{foreman_tmp_location} --procfile #{procfile} --app #{application} --user #{application_user} --log #{deploy_to}/log" }
|
27
|
+
set(:foreman_export_command) { "./bin/foreman export #{foreman_export_format} #{foreman_tmp_location} --procfile #{procfile} --app #{application} --user #{application_user} --log #{deploy_to}/log #{foreman_template_option}" }
|
23
28
|
|
24
29
|
namespace :export do
|
25
|
-
# After each deployment, the startup scripts are exported if the `Procfile`
|
30
|
+
# After each deployment, the startup scripts are exported if either the `Procfile` or any custom Foreman templates have changed.
|
26
31
|
task :if_changed do
|
27
|
-
if trigger_update?(procfile)
|
32
|
+
if trigger_update?(procfile) || (foreman_template && trigger_update?(foreman_template))
|
28
33
|
top.foreman.export.default
|
29
34
|
end
|
30
35
|
end
|
@@ -71,4 +76,4 @@ module Recap::Tasks::Foreman
|
|
71
76
|
after 'deploy:update_code', 'foreman:export:if_changed'
|
72
77
|
after 'deploy:restart', 'foreman:restart'
|
73
78
|
end
|
74
|
-
end
|
79
|
+
end
|
data/lib/recap/version.rb
CHANGED
data/spec/tasks/foreman_spec.rb
CHANGED
@@ -38,6 +38,23 @@ describe Recap::Tasks::Foreman do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
describe '#foreman_template' do
|
42
|
+
it 'defaults to nil' do
|
43
|
+
config.foreman_template.should be_nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#foreman_template_option' do
|
48
|
+
it 'is nil if foreman_template is unset' do
|
49
|
+
config.foreman_template_option.should be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'points at the foreman_template if set' do
|
53
|
+
config.set :foreman_template, '/path/to/template'
|
54
|
+
config.foreman_template_option.should eql('--template /path/to/template')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
41
58
|
describe '#foreman_export_location' do
|
42
59
|
it 'defaults to /etc/init' do
|
43
60
|
config.foreman_export_location.should eql('/etc/init')
|
@@ -52,6 +69,7 @@ describe Recap::Tasks::Foreman do
|
|
52
69
|
|
53
70
|
describe '#foreman_export_command' do
|
54
71
|
before :each do
|
72
|
+
config.set :foreman_template_option, ''
|
55
73
|
config.set :foreman_export_format, '<export-format>'
|
56
74
|
config.set :foreman_tmp_location, '<tmp-location>'
|
57
75
|
end
|
@@ -79,11 +97,20 @@ describe Recap::Tasks::Foreman do
|
|
79
97
|
config.set :deploy_to, '/custom/deploy/location'
|
80
98
|
config.foreman_export_command.index("--log /custom/deploy/location/log").should_not be_nil
|
81
99
|
end
|
100
|
+
|
101
|
+
it 'includes --template option if set' do
|
102
|
+
config.set :foreman_template_option, '--template /path/to/template'
|
103
|
+
config.foreman_export_command.index("--template /path/to/template").should_not be_nil
|
104
|
+
end
|
82
105
|
end
|
83
106
|
end
|
84
107
|
|
85
108
|
describe 'Tasks' do
|
86
109
|
describe 'foreman:export:if_changed' do
|
110
|
+
before :each do
|
111
|
+
namespace.stubs(:trigger_update?).with(config.procfile).returns(false)
|
112
|
+
end
|
113
|
+
|
87
114
|
it 'calls foreman:export if the Procfile has changed' do
|
88
115
|
namespace.stubs(:trigger_update?).with(config.procfile).returns(true)
|
89
116
|
namespace.export.expects(:default)
|
@@ -91,10 +118,22 @@ describe Recap::Tasks::Foreman do
|
|
91
118
|
end
|
92
119
|
|
93
120
|
it 'skips foreman:export if the Procfile has not changed' do
|
94
|
-
namespace.stubs(:trigger_update?).with(config.procfile).returns(false)
|
95
121
|
namespace.export.expects(:default).never
|
96
122
|
config.find_and_execute_task('foreman:export:if_changed')
|
97
123
|
end
|
124
|
+
|
125
|
+
describe 'foreman_template is set' do
|
126
|
+
before :each do
|
127
|
+
config.set :foreman_template, 'config/foreman/upstart'
|
128
|
+
namespace.stubs(:trigger_update?).with(config.foreman_template).returns(false)
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'calls foreman:export if any of the templates have changed' do
|
132
|
+
namespace.stubs(:trigger_update?).with(config.foreman_template).returns(true)
|
133
|
+
namespace.export.expects(:default)
|
134
|
+
config.find_and_execute_task('foreman:export:if_changed')
|
135
|
+
end
|
136
|
+
end
|
98
137
|
end
|
99
138
|
|
100
139
|
describe 'foreman:export' do
|
@@ -158,4 +197,4 @@ describe Recap::Tasks::Foreman do
|
|
158
197
|
end
|
159
198
|
end
|
160
199
|
end
|
161
|
-
end
|
200
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Ward
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|