le1t0-deprec 2.1.6.056 → 2.1.6.057

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,10 @@
1
1
  # deprec changelog
2
2
 
3
+ = 2.1.6.057 (Aug 13, 2010)
4
+
5
+ * Updated dependency for capistrano
6
+ * add-multiple-recipe-configs-per-stage
7
+
3
8
  = 2.1.6.056 (Aug 12, 2010)
4
9
 
5
10
  * Updated dependency for capistrano
@@ -65,38 +65,48 @@ module Deprec2
65
65
  else
66
66
  template = ERB.new(IO.read(File.join(DEPREC_TEMPLATES_BASE, app.to_s, template)), nil, '-')
67
67
  end
68
- rendered_template = template.result(binding)
68
+ rendered_templates = {}
69
+ find_servers.collect { |server| server.host }.each do |host|
70
+ scope host do
71
+ rendered_templates[host] = template.result(binding)
72
+ end
73
+ end
69
74
 
70
75
  if remote
71
76
  # render to remote machine
72
77
  puts 'You need to specify a path to render the template to!' unless path
73
78
  exit unless path
74
79
  sudo "test -d #{File.dirname(path)} || #{sudo} mkdir -p #{File.dirname(path)}"
75
- std.su_put rendered_template, path, '/tmp/', :mode => mode
80
+ # First argument is empty string, since to be uploaded data is given by the Proc
81
+ std.su_put "", path, '/tmp/', :mode => mode, :proc => Proc.new { |from, host|
82
+ rendered_templates[host]
83
+ }
76
84
  sudo "chown #{owner} #{path}" if defined?(owner)
77
85
  elsif path
78
86
  # render to local file
79
- full_path = File.join('config', stage, app.to_s, path)
80
- path_dir = File.dirname(full_path)
81
- if File.exists?(full_path)
82
- if IO.read(full_path) == rendered_template
83
- puts "[skip] File exists and is identical (#{full_path})."
84
- return false
85
- elsif overwrite?(full_path, rendered_template)
86
- File.delete(full_path)
87
- else
88
- puts "[skip] Not overwriting #{full_path}"
89
- return false
87
+ find_servers.collect { |server| server.host }.each do |host|
88
+ full_path = File.join('config', stage, host, app.to_s, path)
89
+ path_dir = File.dirname(full_path)
90
+ if File.exists?(full_path)
91
+ if IO.read(full_path) == rendered_templates[host]
92
+ puts "[skip] File exists and is identical (#{full_path})."
93
+ next
94
+ elsif overwrite?(full_path, rendered_templates[host])
95
+ File.delete(full_path)
96
+ else
97
+ puts "[skip] Not overwriting #{full_path}"
98
+ next
99
+ end
90
100
  end
101
+ FileUtils.mkdir_p "#{path_dir}" if ! File.directory?(path_dir)
102
+ # added line above to make windows compatible
103
+ # system "mkdir -p #{path_dir}" if ! File.directory?(path_dir)
104
+ File.open(full_path, 'w'){|f| f.write rendered_templates[host] }
105
+ puts "[done] #{full_path} written"
91
106
  end
92
- FileUtils.mkdir_p "#{path_dir}" if ! File.directory?(path_dir)
93
- # added line above to make windows compatible
94
- # system "mkdir -p #{path_dir}" if ! File.directory?(path_dir)
95
- File.open(full_path, 'w'){|f| f.write rendered_template }
96
- puts "[done] #{full_path} written"
97
107
  else
98
108
  # render to string
99
- return rendered_template
109
+ return rendered_templates
100
110
  end
101
111
  end
102
112
 
@@ -146,10 +156,18 @@ module Deprec2
146
156
  template_name += '.conf' if File.extname(template_name) == '' # XXX this to be removed
147
157
 
148
158
  file = File.join(templates_dir, template_name)
149
- buffer = render :template => File.read(file)
159
+ buffers = {}
160
+ find_servers.collect { |server| server.host }.each do |host|
161
+ scope host do
162
+ buffers[host] = render :template => File.read(file)
163
+ end
164
+ end
150
165
 
151
166
  temporary_location = "/tmp/#{template_name}"
152
- put buffer, temporary_location
167
+ # First argument is empty string, since to be uploaded data is given by the Proc
168
+ put "", temporary_location, :proc => Proc.new { |from, host|
169
+ buffers[host]
170
+ }
153
171
  sudo "cp #{temporary_location} #{destination_file_name}"
154
172
  delete temporary_location
155
173
  end
@@ -161,8 +179,9 @@ module Deprec2
161
179
  stage = exists?(:stage) ? fetch(:stage).to_s : ''
162
180
 
163
181
  files.each do |file|
164
- full_local_path = File.join('config', stage, app, file[:path])
165
- if File.exists?(full_local_path)
182
+ full_local_paths = find_servers.collect { |server| File.join('config', stage, server.host, app, file[:path]) }
183
+ if full_local_paths.all? { |full_local_path| File.exists?(full_local_path) }
184
+ full_local_path_with_parameter = File.join('config', stage, '%{host}', app, file[:path])
166
185
  # If the file path is relative we will prepend a path to this projects
167
186
  # own config directory for this service.
168
187
  if file[:path][0,1] != '/'
@@ -171,7 +190,7 @@ module Deprec2
171
190
  full_remote_path = file[:path]
172
191
  end
173
192
  sudo "test -d #{File.dirname(full_remote_path)} || #{sudo} mkdir -p #{File.dirname(full_remote_path)}"
174
- std.su_put File.read(full_local_path), full_remote_path, '/tmp/', :mode=>file[:mode]
193
+ std.su_put full_local_path_with_parameter, full_remote_path, '/tmp/', :mode=>file[:mode]
175
194
  sudo "chown #{file[:owner]} #{full_remote_path}"
176
195
  else
177
196
  # Render directly to remote host.
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 2
7
7
  - 1
8
8
  - 6
9
- - 56
10
- version: 2.1.6.056
9
+ - 57
10
+ version: 2.1.6.057
11
11
  platform: ruby
12
12
  authors:
13
13
  - Le1t0
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-12 00:00:00 +02:00
18
+ date: 2010-08-13 00:00:00 +02:00
19
19
  default_executable: depify
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -29,8 +29,8 @@ dependencies:
29
29
  - 2
30
30
  - 5
31
31
  - 18
32
- - 16
33
- version: 2.5.18.016
32
+ - 17
33
+ version: 2.5.18.017
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  description: " This project provides libraries of Capistrano tasks and extensions to \n remove the repetative manual work associated with installing services \n on linux servers.\n"