kali-chef-deploy 0.2.2.1 → 0.2.5.1
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/Rakefile +1 -1
- data/lib/chef-deploy/cached_deploy.rb +39 -13
- data/lib/chef-deploy/git.rb +3 -0
- metadata +6 -6
data/Rakefile
CHANGED
@@ -12,14 +12,7 @@ class CachedDeploy
|
|
12
12
|
@configuration[:revision] = source.query_revision(@configuration[:branch]) {|cmd| run_with_result "#{cmd}"}
|
13
13
|
end
|
14
14
|
|
15
|
-
if
|
16
|
-
Chef::Log.info "Revision is already deployed, running migrations if there are any"
|
17
|
-
callback(:before_migrate)
|
18
|
-
migrate
|
19
|
-
callback(:before_symlink)
|
20
|
-
symlink
|
21
|
-
return
|
22
|
-
end
|
15
|
+
return if check_current_revision_and_noop_if_same_and_deployed(@configuration[:revision])
|
23
16
|
|
24
17
|
Chef::Log.info "ensuring proper ownership"
|
25
18
|
chef_run(fix_ownership_command(user, group, @configuration[:deploy_to]))
|
@@ -30,6 +23,7 @@ class CachedDeploy
|
|
30
23
|
Chef::Log.info "copying the cached version to #{release_path}"
|
31
24
|
chef_run(copy_repository_cache)
|
32
25
|
install_gems
|
26
|
+
prepare_directories
|
33
27
|
|
34
28
|
chef_run(fix_ownership_command(user, group, @configuration[:deploy_to]))
|
35
29
|
|
@@ -41,17 +35,22 @@ class CachedDeploy
|
|
41
35
|
restart
|
42
36
|
callback(:after_restart)
|
43
37
|
cleanup
|
38
|
+
|
39
|
+
mark_deployed
|
40
|
+
@configuration[:new_resource].updated = true
|
44
41
|
end
|
45
42
|
|
46
43
|
def restart
|
47
44
|
unless @configuration[:restart_command].empty?
|
48
45
|
Chef::Log.info "restarting app: #{latest_release}"
|
49
|
-
chef_run("cd #{current_path} && sudo -u #{user} RAILS_ENV=#{@configuration[:environment]} RACK_ENV=#{@configuration[:environment]} MERB_ENV=#{@configuration[:environment]} #{@configuration[:restart_command]}")
|
46
|
+
chef_run("cd #{current_path} && sudo -u #{user} INLINEDIR=/tmp RAILS_ENV=#{@configuration[:environment]} RACK_ENV=#{@configuration[:environment]} MERB_ENV=#{@configuration[:environment]} #{@configuration[:restart_command]}")
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
53
|
-
def
|
54
|
-
IO.read("#{latest_release}/REVISION").chomp == newrev
|
50
|
+
def check_current_revision_and_noop_if_same_and_deployed(newrev)
|
51
|
+
IO.read("#{latest_release}/REVISION").chomp == newrev &&
|
52
|
+
IO.read("#{shared_path}/DEPLOYED_REVISION").chomp == newrev
|
53
|
+
|
55
54
|
rescue
|
56
55
|
false
|
57
56
|
end
|
@@ -96,6 +95,8 @@ class CachedDeploy
|
|
96
95
|
FileUtils.rm_rf latest_release
|
97
96
|
Chef::Log.info "restarting with previous release"
|
98
97
|
restart
|
98
|
+
|
99
|
+
@configuration[:new_resource].updated = true
|
99
100
|
end
|
100
101
|
|
101
102
|
def fix_ownership_command(user, group, path)
|
@@ -105,6 +106,7 @@ class CachedDeploy
|
|
105
106
|
def migrate
|
106
107
|
if @configuration[:migrate]
|
107
108
|
chef_run "ln -nfs #{shared_path}/config/database.yml #{latest_release}/config/database.yml"
|
109
|
+
chef_run "ln -nfs #{shared_path}/log #{latest_release}/log"
|
108
110
|
Chef::Log.info "Migrating: cd #{latest_release} && sudo -u #{user} RAILS_ENV=#{@configuration[:environment]} RACK_ENV=#{@configuration[:environment]} MERB_ENV=#{@configuration[:environment]} #{@configuration[:migration_command]}"
|
109
111
|
chef_run(fix_ownership_command(user, group, latest_release))
|
110
112
|
chef_run("cd #{latest_release} && sudo -u #{user} RAILS_ENV=#{@configuration[:environment]} RACK_ENV=#{@configuration[:environment]} MERB_ENV=#{@configuration[:environment]} #{@configuration[:migration_command]}")
|
@@ -218,7 +220,7 @@ class CachedDeploy
|
|
218
220
|
next if has_gem?(g[:name], g[:version])
|
219
221
|
r = Chef::Resource::GemPackage.new(g[:name], nil, @configuration[:node])
|
220
222
|
r.version g[:version]
|
221
|
-
r.source "http://gems.github.com"
|
223
|
+
r.source(g.has_key?(:source) ? g[:source] : "http://gems.github.com")
|
222
224
|
resources << r
|
223
225
|
end
|
224
226
|
resources.each do |r|
|
@@ -231,6 +233,25 @@ class CachedDeploy
|
|
231
233
|
end
|
232
234
|
end
|
233
235
|
end
|
236
|
+
|
237
|
+
def prepare_directories
|
238
|
+
resources = []
|
239
|
+
%w( log system pids config ).each do |shared_subdir|
|
240
|
+
r = Chef::Resource::Directory.new("#{shared_path}/#{shared_subdir}", nil, @configuration[:node])
|
241
|
+
r.owner user
|
242
|
+
r.group group
|
243
|
+
r.mode 0775
|
244
|
+
resources << r
|
245
|
+
end
|
246
|
+
resources.each do |r|
|
247
|
+
begin
|
248
|
+
r.run_action(:create)
|
249
|
+
rescue Chef::Exception::Exec => e
|
250
|
+
Chef::Log.info("Error creating directory #{r.path}")
|
251
|
+
raise e
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
234
255
|
|
235
256
|
def has_gem?(name, version=nil)
|
236
257
|
if !$GEM_LIST_DEPLOY
|
@@ -259,7 +280,8 @@ class CachedDeploy
|
|
259
280
|
end
|
260
281
|
|
261
282
|
def update_repository_cache
|
262
|
-
command = "if [ -d #{repository_cache} ]
|
283
|
+
command = "if [ -d #{repository_cache} ] &&" +
|
284
|
+
"git --git-dir #{repository_cache}/.git/ remote -v | grep -q #{configuration[:repository]}; then " +
|
263
285
|
"#{source.sync(revision, repository_cache)}; " +
|
264
286
|
"else #{source.checkout(revision, repository_cache)}; fi"
|
265
287
|
command
|
@@ -281,6 +303,10 @@ class CachedDeploy
|
|
281
303
|
def mark
|
282
304
|
"(echo #{revision} > #{release_path}/REVISION)"
|
283
305
|
end
|
306
|
+
|
307
|
+
def mark_deployed
|
308
|
+
chef_run("echo #{revision} > #{shared_path}/DEPLOYED_REVISION")
|
309
|
+
end
|
284
310
|
|
285
311
|
def copy_exclude
|
286
312
|
@copy_exclude ||= Array(configuration.fetch(:copy_exclude, []))
|
data/lib/chef-deploy/git.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kali-chef-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezra Zygmuntowicz
|
@@ -9,7 +9,7 @@ autorequire: chef-deploy
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-29 00:00:00
|
12
|
+
date: 2009-07-29 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -28,14 +28,14 @@ files:
|
|
28
28
|
- README.rdoc
|
29
29
|
- Rakefile
|
30
30
|
- TODO
|
31
|
-
- lib/chef-deploy
|
32
31
|
- lib/chef-deploy/cached_deploy.rb
|
33
32
|
- lib/chef-deploy/git.rb
|
34
33
|
- lib/chef-deploy/subversion.rb
|
35
34
|
- lib/chef-deploy.rb
|
36
|
-
has_rdoc:
|
35
|
+
has_rdoc: true
|
37
36
|
homepage: http://example.com
|
38
|
-
licenses:
|
37
|
+
licenses: []
|
38
|
+
|
39
39
|
post_install_message:
|
40
40
|
rdoc_options: []
|
41
41
|
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements: []
|
57
57
|
|
58
58
|
rubyforge_project:
|
59
|
-
rubygems_version: 1.3.
|
59
|
+
rubygems_version: 1.3.4
|
60
60
|
signing_key:
|
61
61
|
specification_version: 3
|
62
62
|
summary: A gem that provides...
|