avodeploy 0.4.2 → 0.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG +20 -0
- data/README.md +1 -1
- data/avodeploy.gemspec +16 -14
- data/bin/avo +101 -104
- data/lib/avodeploy.rb +1 -0
- data/lib/avodeploy/bootstrap.rb +65 -73
- data/lib/avodeploy/command_execution_result.rb +6 -6
- data/lib/avodeploy/config.rb +120 -99
- data/lib/avodeploy/core_ext/string_colors.rb +9 -9
- data/lib/avodeploy/deployment.rb +43 -46
- data/lib/avodeploy/multi_io.rb +11 -11
- data/lib/avodeploy/scm_provider/bzr_scm_provider.rb +111 -0
- data/lib/avodeploy/scm_provider/git_scm_provider.rb +66 -45
- data/lib/avodeploy/scm_provider/scm_provider.rb +57 -43
- data/lib/avodeploy/skel/manifest_template.rb.erb +127 -116
- data/lib/avodeploy/strategy/base.rb +7 -7
- data/lib/avodeploy/strategy/local_copy.rb +99 -79
- data/lib/avodeploy/strategy/local_copy_partial.rb +86 -0
- data/lib/avodeploy/target.rb +32 -31
- data/lib/avodeploy/task/local_task_execution_environment.rb +112 -107
- data/lib/avodeploy/task/remote_task_execution_environment.rb +90 -94
- data/lib/avodeploy/task/task.rb +53 -42
- data/lib/avodeploy/task/task_dependency.rb +5 -5
- data/lib/avodeploy/task/task_execution_environment.rb +70 -59
- data/lib/avodeploy/task/task_manager.rb +187 -165
- data/lib/avodeploy/version.rb +1 -1
- metadata +7 -5
@@ -17,169 +17,191 @@
|
|
17
17
|
=end
|
18
18
|
|
19
19
|
module AvoDeploy
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
20
|
+
module Task
|
21
|
+
class TaskManager
|
22
|
+
|
23
|
+
attr_reader :dependencies
|
24
|
+
attr_reader :chains
|
25
|
+
|
26
|
+
# Initializes the task manager
|
27
|
+
def initialize
|
28
|
+
@chains = []
|
29
|
+
@remote_env = nil
|
30
|
+
@local_env = nil
|
31
|
+
end
|
32
|
+
|
33
|
+
# Adds a task to the task manager
|
34
|
+
#
|
35
|
+
# @param name [Symbol] task name
|
36
|
+
# @param options [Hash] task options
|
37
|
+
# @param block [Block] code of the task
|
38
|
+
def add_task(name, options, &block)
|
39
|
+
position = :after
|
40
|
+
standalone = true
|
41
|
+
|
42
|
+
if options.has_key?(:before)
|
43
|
+
position = :before
|
44
|
+
end
|
45
|
+
|
46
|
+
key = name
|
47
|
+
|
48
|
+
if options.has_key?(:before)
|
49
|
+
key = options[:before]
|
50
|
+
standalone = false
|
51
|
+
elsif options.has_key?(:after)
|
52
|
+
key = options[:after]
|
53
|
+
standalone = false
|
54
|
+
end
|
55
|
+
|
56
|
+
if standalone == false
|
57
|
+
idx = find_chain_index_containing(key)
|
58
|
+
|
59
|
+
@chains[idx].delete(name)
|
60
|
+
@chains[idx].insert_at(position, key, [name, Task.from_task_block(name, options, &block)])
|
61
|
+
|
62
|
+
else
|
63
|
+
chain = {}
|
64
|
+
chain[name] = Task.from_task_block(name, options, &block)
|
65
|
+
@chains << chain
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Finds a task by its name
|
70
|
+
#
|
71
|
+
# @param name [Symbol] name of the task
|
72
|
+
# @return [Task] the task if found
|
73
|
+
def task_by_name(name)
|
74
|
+
name = name.to_sym if name.is_a?(String)
|
75
|
+
|
76
|
+
cidx = find_chain_index_containing(name)
|
77
|
+
@chains[cidx][name]
|
78
|
+
end
|
79
|
+
|
80
|
+
# Finds the chain containing a specifc task
|
81
|
+
#
|
82
|
+
# @param name [Symbol] task name
|
83
|
+
# @param [Integer] chain index
|
84
|
+
def find_chain_index_containing(name)
|
85
|
+
@chains.each_with_index do |chain, idx|
|
86
|
+
if chain.has_key?(name)
|
87
|
+
return idx
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
raise RuntimeError, "could not find a chain containing task #{name}"
|
92
|
+
end
|
93
|
+
|
94
|
+
# Invokes a task without dependencies
|
95
|
+
#
|
96
|
+
# @param task_name [Symbol] the task name
|
97
|
+
# @param options [Hash] a hash contining additional options
|
98
|
+
def invoke_task_oneshot(task_name, options = {})
|
99
|
+
task_name = task_name.to_sym if task_name.is_a?(String)
|
100
|
+
|
101
|
+
cidx = find_chain_index_containing(task_name)
|
102
|
+
|
103
|
+
begin
|
104
|
+
invoke_task(@chains[cidx][task_name], options)
|
105
|
+
rescue Exception => e
|
106
|
+
AvoDeploy::Deployment.instance.handle_abort(e)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Invokes the task chain, that contains the requested task
|
111
|
+
#
|
112
|
+
# @param task_name [Symbol] the task name
|
113
|
+
# @param options [Hash] a hash contining additional options
|
114
|
+
def invoke_task_chain_containing(task_name, options = {})
|
115
|
+
task_name = task_name.to_sym if task_name.is_a?(String)
|
116
|
+
|
117
|
+
cidx = find_chain_index_containing(task_name)
|
118
|
+
|
119
|
+
begin
|
120
|
+
@chains[cidx].each_pair do |name, task|
|
121
|
+
invoke_task(task, options)
|
122
|
+
end
|
123
|
+
rescue Exception => e
|
124
|
+
AvoDeploy::Deployment.instance.handle_abort(e)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Executes a task for all defined targets
|
129
|
+
#
|
130
|
+
# @param task [Task] the task to start
|
131
|
+
# @param env [RemoteTaskExecutionEnvironment] the environment
|
132
|
+
def execute_for_each_target(task, env)
|
133
|
+
raise ArgumentError, 'task must be a task' unless task.kind_of?(Task)
|
134
|
+
raise ArgumentError, 'env must be a RemoteTaskExecutionEnvironment' unless env.kind_of?(RemoteTaskExecutionEnvironment)
|
135
|
+
|
136
|
+
avo = AvoDeploy::Deployment.instance
|
137
|
+
|
138
|
+
avo.config.targets.each_pair do |key, target|
|
139
|
+
# 'only' check
|
140
|
+
next if task.remote_only.nil? == false && ((task.remote_only.is_a?(Array) && task.remote_only.include?(target.name) == false) || (task.remote_only.is_a?(Symbol) && task.remote_only != target.name))
|
141
|
+
|
142
|
+
# 'except' check
|
143
|
+
next if task.remote_except.nil? == false && ((task.remote_except.is_a?(Array) && task.remote_except.include?(target.name)) || (task.remote_except.is_a?(Symbol) && task.remote_except == target.name))
|
144
|
+
|
145
|
+
avo.log.debug "invoking task #{task.name} for target #{target.name}..."
|
146
|
+
|
147
|
+
env.config.merge!(target.config)
|
148
|
+
env.establish_connection
|
149
|
+
|
150
|
+
task.invoke(env)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Invokes a task
|
155
|
+
#
|
156
|
+
# @param task [Task] the task
|
157
|
+
# @param options [Hash] a hash contining additional options
|
158
|
+
def invoke_task(task, options = {})
|
159
|
+
raise ArgumentError, 'task must be a task' unless task.kind_of?(Task)
|
160
|
+
|
161
|
+
avo = AvoDeploy::Deployment.instance
|
162
|
+
env = nil
|
163
|
+
|
164
|
+
if task.scope == :remote
|
165
|
+
if @remote_env.nil?
|
166
|
+
@remote_env = RemoteTaskExecutionEnvironment.new(avo.config.config)
|
167
|
+
end
|
168
|
+
|
169
|
+
env = @remote_env
|
170
|
+
elsif task.scope == :local
|
171
|
+
if @local_env.nil?
|
172
|
+
@local_env = LocalTaskExecutionEnvironment.new(avo.config.config)
|
173
|
+
end
|
174
|
+
|
175
|
+
env = @local_env
|
176
|
+
else
|
177
|
+
raise RuntimeError, 'scope must either be remote or local'
|
178
|
+
end
|
179
|
+
|
180
|
+
# @todo this does not belong here
|
181
|
+
env.scm = nil
|
182
|
+
|
183
|
+
if avo.config.get(:scm) == :git
|
184
|
+
env.scm = AvoDeploy::ScmProvider::GitScmProvider.new(env)
|
185
|
+
elsif avo.config.get(:scm) == :bzr
|
186
|
+
env.scm = AvoDeploy::ScmProvider::BzrScmProvider.new(env)
|
187
|
+
end
|
188
|
+
|
189
|
+
if env.scm.nil?
|
190
|
+
raise RuntimeError, 'No ScmProvider was instantiated'
|
191
|
+
end
|
192
|
+
|
193
|
+
if options.empty? == false
|
194
|
+
env.options = options
|
195
|
+
end
|
196
|
+
|
197
|
+
# if remote task -> execute for each target
|
198
|
+
if task.scope == :remote
|
199
|
+
execute_for_each_target(task, env)
|
200
|
+
else
|
201
|
+
task.invoke(env)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
end
|
185
207
|
end
|
data/lib/avodeploy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avodeploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Prandzioch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
version: 0.19.1
|
97
97
|
description: ''
|
98
98
|
email:
|
99
|
-
-
|
99
|
+
- kontakt@davidprandzioch.de
|
100
100
|
executables:
|
101
101
|
- avo
|
102
102
|
extensions: []
|
@@ -118,11 +118,13 @@ files:
|
|
118
118
|
- lib/avodeploy/core_ext/string_colors.rb
|
119
119
|
- lib/avodeploy/deployment.rb
|
120
120
|
- lib/avodeploy/multi_io.rb
|
121
|
+
- lib/avodeploy/scm_provider/bzr_scm_provider.rb
|
121
122
|
- lib/avodeploy/scm_provider/git_scm_provider.rb
|
122
123
|
- lib/avodeploy/scm_provider/scm_provider.rb
|
123
124
|
- lib/avodeploy/skel/manifest_template.rb.erb
|
124
125
|
- lib/avodeploy/strategy/base.rb
|
125
126
|
- lib/avodeploy/strategy/local_copy.rb
|
127
|
+
- lib/avodeploy/strategy/local_copy_partial.rb
|
126
128
|
- lib/avodeploy/target.rb
|
127
129
|
- lib/avodeploy/task/local_task_execution_environment.rb
|
128
130
|
- lib/avodeploy/task/remote_task_execution_environment.rb
|
@@ -143,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
145
|
requirements:
|
144
146
|
- - '>='
|
145
147
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
148
|
+
version: 2.0.0
|
147
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
150
|
requirements:
|
149
151
|
- - '>='
|
@@ -151,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
153
|
version: '0'
|
152
154
|
requirements: []
|
153
155
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.0.14
|
155
157
|
signing_key:
|
156
158
|
specification_version: 4
|
157
159
|
summary: Avocado is a flexible deployment framework for web applications.
|