vagrant-orchestrate 0.6.5 → 0.7.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +9 -0
- data/docs/deployment_tracker.md +91 -0
- data/lib/vagrant-managed-servers/action/init_deployment_tracker.rb +23 -0
- data/lib/vagrant-managed-servers/action/track_deployment_end.rb +36 -0
- data/lib/vagrant-managed-servers/action/track_deployment_start.rb +42 -0
- data/lib/vagrant-managed-servers/action/track_server_deployment_end.rb +40 -0
- data/lib/vagrant-managed-servers/action/track_server_deployment_start.rb +39 -0
- data/lib/vagrant-managed-servers/action.rb +9 -0
- data/lib/vagrant-orchestrate/action/filtermanaged.rb +0 -2
- data/lib/vagrant-orchestrate/command/init.rb +8 -4
- data/lib/vagrant-orchestrate/command/push.rb +40 -24
- data/lib/vagrant-orchestrate/config.rb +5 -0
- data/lib/vagrant-orchestrate/plugin.rb +2 -0
- data/lib/vagrant-orchestrate/repo_status.rb +6 -0
- data/lib/vagrant-orchestrate/version.rb +1 -1
- data/spec/vagrant-orchestrate/command/init_spec.rb +10 -0
- data/templates/vagrant/Vagrantfile.erb +3 -0
- data/vagrant-orchestrate.gemspec +2 -0
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 921a92c606deeae0ba52e3a9d4a74512ed069b89
|
4
|
+
data.tar.gz: e585d48a159257465a5819999c98427987056c28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8329f4d0cf7dae21563386624a3a46dd899b73cd6788ec6a608a67ff97aeae13746060ef3412e0317ef35bfa91565a4ebeb5bad805a7dbdad8416dae21a4ac8d
|
7
|
+
data.tar.gz: 88748c419d926f918064971eb42faf5e5dac2d8ba1702bc769aeb8d74b06fa7fb99dc9ba7763e26feeb7c5c0736a4707a8c53a235a821d374f5b222aea7a2aea
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.7.0 (Unreleased)
|
2
|
+
|
3
|
+
- Add support for tracking deployments with [deployment-tracker](https://github.com/Cimpress-MCP/deployment-tracker).
|
4
|
+
Add configuration option `config.orchestrate.tracker_host = 'deploymenttracker.mydomain.com'`
|
5
|
+
|
1
6
|
0.6.5 (June 27th, 2015)
|
2
7
|
|
3
8
|
- Split GIT_BRANCH environment variable on slash and take the last element, since
|
data/README.md
CHANGED
@@ -204,6 +204,15 @@ managed-3 Status unavailable.
|
|
204
204
|
managed-4 2015-04-19 00:43:07 UTC e983dddd8041c5db77494266328f1d266430f57d cbaldauf
|
205
205
|
```
|
206
206
|
|
207
|
+
### Tracking Deployment metadata
|
208
|
+
|
209
|
+
Vagrant Orchestrate has support for integrating with [deployment-tracker](https://github.com/Cimpress-MCP/deployment-tracker),
|
210
|
+
which can collect and record metadata about deployments, including summary records, metrics, and logs.
|
211
|
+
|
212
|
+
config.orchestrate.tracker_host = "deploymenttracker.mydomain.com"
|
213
|
+
|
214
|
+
See more info on [deployment tracker integration](docs/deployment_tracker.md).
|
215
|
+
|
207
216
|
## Windows
|
208
217
|
|
209
218
|
### Host
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# Deployment Tracker Integration
|
2
|
+
|
3
|
+
[Deployment tracker](http://github.com/Cimpress-MCP/deployment-tracker) is a lightweight node REST service that can aggregate
|
4
|
+
deployment metadata across your organization. You can record deployment execution times and outcomes using Vagrant Orchestrate
|
5
|
+
whether you're deploying from your laptop to a cloud instance or from a build slave to a hardware box.
|
6
|
+
|
7
|
+
## What is actually tracked?
|
8
|
+
|
9
|
+
1. Deployments starting
|
10
|
+
2. Deployment starting on a server
|
11
|
+
3. Deployment completing on a server
|
12
|
+
4. Vagrant log messages, including console output
|
13
|
+
5. Deployment completion
|
14
|
+
|
15
|
+
The summary record for a successful deployment to 4 servers using the half_half strategy is recorded as follows:
|
16
|
+
|
17
|
+
```
|
18
|
+
curl http://deploymenttracker.mydomain.com/v1/deployments/120c7b1c-73bc-4626-bef8-be1983785562
|
19
|
+
{
|
20
|
+
"deployment_id": "120c7b1c-73bc-4626-bef8-be1983785562",
|
21
|
+
"engine": "vagrant_orchestrate",
|
22
|
+
"engine_version": "0.7.0",
|
23
|
+
"host": "mypc.local",
|
24
|
+
"user": "cbaldauf",
|
25
|
+
"environment": "deployment_tracker",
|
26
|
+
"package": "vagrant-orchestrate",
|
27
|
+
"package_url": "https://github.com/Cimpress-MCP/vagrant-orchestrate.git",
|
28
|
+
"version": "c3ede86e0a0b1a0c3cf6952906a914fdb3832f87",
|
29
|
+
"arguments": "--strategy half_half",
|
30
|
+
"createdAt": "2015-07-07T17:34:12.008Z",
|
31
|
+
"updatedAt": "2015-07-07T17:34:12.008Z",
|
32
|
+
"servers": [
|
33
|
+
{
|
34
|
+
"hostname": "192.168.10.81",
|
35
|
+
"deployment_id": "120c7b1c-73bc-4626-bef8-be1983785562",
|
36
|
+
"result": "success",
|
37
|
+
"elapsed_seconds": 3,
|
38
|
+
"createdAt": "2015-07-07 17:34:12.075 +00:00",
|
39
|
+
"updatedAt": "2015-07-07 17:34:15.730 +00:00"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"hostname": "192.168.10.80",
|
43
|
+
"deployment_id": "120c7b1c-73bc-4626-bef8-be1983785562",
|
44
|
+
"result": "success",
|
45
|
+
"elapsed_seconds": 3,
|
46
|
+
"createdAt": "2015-07-07 17:34:12.281 +00:00",
|
47
|
+
"updatedAt": "2015-07-07 17:34:16.044 +00:00"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"hostname": "192.168.10.83",
|
51
|
+
"deployment_id": "120c7b1c-73bc-4626-bef8-be1983785562",
|
52
|
+
"result": "success",
|
53
|
+
"elapsed_seconds": 3,
|
54
|
+
"createdAt": "2015-07-07 17:34:26.113 +00:00",
|
55
|
+
"updatedAt": "2015-07-07 17:34:29.477 +00:00"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"hostname": "192.168.10.82",
|
59
|
+
"deployment_id": "120c7b1c-73bc-4626-bef8-be1983785562",
|
60
|
+
"result": "success",
|
61
|
+
"elapsed_seconds": 20,
|
62
|
+
"createdAt": "2015-07-07 17:34:26.316 +00:00",
|
63
|
+
"updatedAt": "2015-07-07 17:34:46.475 +00:00"
|
64
|
+
}
|
65
|
+
]
|
66
|
+
}
|
67
|
+
|
68
|
+
```
|
69
|
+
|
70
|
+
### Field Values
|
71
|
+
|
72
|
+
If you are using the Vagrant Orchestrate git integration, which is highly recommended, the following
|
73
|
+
field values will be assigned automatically:
|
74
|
+
|
75
|
+
1. deployment_id - UUID generated by Vagrant Orchestrate
|
76
|
+
2. environment - git branch name
|
77
|
+
3. package - git repo name
|
78
|
+
4. package_url - git remote origin url
|
79
|
+
5. version - git SHA
|
80
|
+
|
81
|
+
|
82
|
+
## Configuration
|
83
|
+
|
84
|
+
Add the following configuration option to your Vagrantfile
|
85
|
+
|
86
|
+
config.orchestrate.tracker_host = "http://deploymenttracker.mydomain.com"
|
87
|
+
|
88
|
+
|
89
|
+
## Initialization
|
90
|
+
|
91
|
+
vagrant orchestrate init --deployment-tracker-host http://deploymenttracker.mydomain.com
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ManagedServers
|
5
|
+
module Action
|
6
|
+
class InitDeploymentTracker
|
7
|
+
def initialize(app, _env)
|
8
|
+
@app = app
|
9
|
+
@logger = Log4r::Logger.new("vagrant_managed_servers::action::init_deployment_tracker")
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
host = env[:tracker_host]
|
14
|
+
return unless host
|
15
|
+
SwaggerClient::Swagger.configure do |config|
|
16
|
+
config.host = host
|
17
|
+
end
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ManagedServers
|
5
|
+
module Action
|
6
|
+
class TrackDeploymentEnd
|
7
|
+
def initialize(app, _env)
|
8
|
+
@app = app
|
9
|
+
@logger = Log4r::Logger.new("vagrant_managed_servers::action::track_deployment_end")
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
track_deployment_end(env[:tracker_host], env[:start_time], env[:success], env[:ui])
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
def track_deployment_end(host, start, success, ui)
|
18
|
+
return unless host
|
19
|
+
@logger.debug("Tracking deployment end to #{host}.")
|
20
|
+
id = VagrantPlugins::Orchestrate::DEPLOYMENT_ID
|
21
|
+
result = success ? "success" : "failure"
|
22
|
+
elapsed_seconds = (Time.now - start).to_i
|
23
|
+
deployment = { deployment_id: id,
|
24
|
+
result: result,
|
25
|
+
assert_empty_server_result: true,
|
26
|
+
elapsed_seconds: elapsed_seconds }
|
27
|
+
DeploymentTrackerClient::DefaultApi.put_deployment(id, deployment)
|
28
|
+
rescue => ex
|
29
|
+
ui.warn("There was an error notifying deployment tracker. See error log for details.")
|
30
|
+
@logger.warn("Error tracking deployment end for deployment #{id}")
|
31
|
+
@logger.warn(ex)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ManagedServers
|
5
|
+
module Action
|
6
|
+
class TrackDeploymentStart
|
7
|
+
def initialize(app, _env)
|
8
|
+
@app = app
|
9
|
+
@logger = Log4r::Logger.new("vagrant_managed_servers::action::track_deployment_start")
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
track_deployment_start(env[:tracker_host], env[:status], env[:ui], env[:args])
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
def track_deployment_start(host, status, ui, args)
|
18
|
+
return unless host
|
19
|
+
@logger.debug("Tracking deployment start to #{host}.")
|
20
|
+
id = VagrantPlugins::Orchestrate::DEPLOYMENT_ID
|
21
|
+
hostname = `hostname`.chomp
|
22
|
+
deployment = {
|
23
|
+
deployment_id: id,
|
24
|
+
engine: "vagrant_orchestrate",
|
25
|
+
engine_version: VagrantPlugins::Orchestrate::VERSION,
|
26
|
+
user: status.user, host: hostname,
|
27
|
+
environment: status.branch,
|
28
|
+
package: status.repo,
|
29
|
+
package_url: status.remote_origin_url,
|
30
|
+
version: status.ref,
|
31
|
+
arguments: args
|
32
|
+
}
|
33
|
+
DeploymentTrackerClient::DefaultApi.post_deployment(id, deployment)
|
34
|
+
rescue => ex
|
35
|
+
ui.warn("There was an error notifying deployment tracker. See error log for details.")
|
36
|
+
@logger.warn("Error tracking deployment start for deployment #{id}")
|
37
|
+
@logger.warn(ex)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ManagedServers
|
5
|
+
module Action
|
6
|
+
class TrackServerDeploymentEnd
|
7
|
+
def initialize(app, _env)
|
8
|
+
@app = app
|
9
|
+
@logger = Log4r::Logger.new("vagrant_managed_servers::action::track_server_deployment_start")
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
machine = env[:machine]
|
14
|
+
track_deployment_end(machine, env[:ui], env[:start_times][machine.name])
|
15
|
+
@app.call(env)
|
16
|
+
end
|
17
|
+
|
18
|
+
def track_deployment_end(machine, ui, start_time)
|
19
|
+
host = machine.config.orchestrate.tracker_host
|
20
|
+
return unless host
|
21
|
+
@logger.debug("Tracking deployment server end to #{host}.")
|
22
|
+
id = VagrantPlugins::Orchestrate::DEPLOYMENT_ID
|
23
|
+
server = {
|
24
|
+
deployment_id: id,
|
25
|
+
hostname: machine.provider_config.server,
|
26
|
+
result: "success",
|
27
|
+
elapsed_seconds: (Time.now - start_time).to_i
|
28
|
+
}
|
29
|
+
DeploymentTrackerClient::DefaultApi.put_server(id, server)
|
30
|
+
rescue => ex
|
31
|
+
ui.warn("There was an error notifying deployment tracker of server end. See error log for details.")
|
32
|
+
ui.warn(ex.message)
|
33
|
+
pp ex
|
34
|
+
@logger.warn("Error tracking deployment server end for deployment #{id}")
|
35
|
+
@logger.warn(ex)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ManagedServers
|
5
|
+
module Action
|
6
|
+
class TrackServerDeploymentStart
|
7
|
+
def initialize(app, _env)
|
8
|
+
@app = app
|
9
|
+
@logger = Log4r::Logger.new("vagrant_managed_servers::action::track_server_deployment_start")
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
machine = env[:machine]
|
14
|
+
env[:start_times] ||= {}
|
15
|
+
env[:start_times][machine.name] = Time.now
|
16
|
+
track_deployment_start(machine, env[:ui])
|
17
|
+
@app.call(env)
|
18
|
+
end
|
19
|
+
|
20
|
+
def track_deployment_start(machine, ui)
|
21
|
+
host = machine.config.orchestrate.tracker_host
|
22
|
+
return unless host
|
23
|
+
@logger.debug("Tracking deployment server start to #{host}.")
|
24
|
+
id = VagrantPlugins::Orchestrate::DEPLOYMENT_ID
|
25
|
+
server = {
|
26
|
+
deployment_id: id,
|
27
|
+
hostname: machine.provider_config.server
|
28
|
+
}
|
29
|
+
DeploymentTrackerClient::DefaultApi.post_server(id, server)
|
30
|
+
rescue => ex
|
31
|
+
ui.warn("There was an error notifying deployment tracker of server start. See error log for details.")
|
32
|
+
ui.warn(ex.message)
|
33
|
+
@logger.warn("Error tracking deployment server start for deployment #{id}")
|
34
|
+
@logger.warn(ex)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,3 +1,10 @@
|
|
1
|
+
require "vagrant-managed-servers/action/upload_status"
|
2
|
+
require "vagrant-managed-servers/action/init_deployment_tracker"
|
3
|
+
require "vagrant-managed-servers/action/track_deployment_start"
|
4
|
+
require "vagrant-managed-servers/action/track_deployment_end"
|
5
|
+
require "vagrant-managed-servers/action/track_server_deployment_start"
|
6
|
+
require "vagrant-managed-servers/action/track_server_deployment_end"
|
7
|
+
|
1
8
|
# It is useful to be able to call up, provision, reload, and destroy as a single
|
2
9
|
# unit - it makes things like parallel provisioning more seamless and provides
|
3
10
|
# a useful action hook for the push command.
|
@@ -8,6 +15,7 @@ module VagrantPlugins
|
|
8
15
|
|
9
16
|
def self.action_push
|
10
17
|
Vagrant::Action::Builder.new.tap do |b|
|
18
|
+
b.use TrackServerDeploymentStart
|
11
19
|
b.use action_up
|
12
20
|
b.use Call, action_provision do |env, b2|
|
13
21
|
if env[:reboot]
|
@@ -17,6 +25,7 @@ module VagrantPlugins
|
|
17
25
|
end
|
18
26
|
b.use UploadStatus
|
19
27
|
b.use action_destroy
|
28
|
+
b.use TrackServerDeploymentEnd
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
@@ -6,7 +6,6 @@ module VagrantPlugins
|
|
6
6
|
@app = app
|
7
7
|
end
|
8
8
|
|
9
|
-
# rubocop:disable Metrics/AbcSize
|
10
9
|
def call(env)
|
11
10
|
machine = env[:machine]
|
12
11
|
if machine.provider_name == :managed
|
@@ -20,7 +19,6 @@ module VagrantPlugins
|
|
20
19
|
@app.call(env)
|
21
20
|
end
|
22
21
|
end
|
23
|
-
# rubocop:enable Metrics/AbcSize
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -15,7 +15,7 @@ module VagrantPlugins
|
|
15
15
|
DEFAULT_SSH_PRIVATE_KEY_PATH = "{{YOUR_SSH_PRIVATE_KEY_PATH}}"
|
16
16
|
DEFAULT_PLUGINS = ["vagrant-orchestrate", "vagrant-managed-servers"]
|
17
17
|
|
18
|
-
# rubocop:disable
|
18
|
+
# rubocop:disable MethodLength
|
19
19
|
def execute
|
20
20
|
options = {}
|
21
21
|
|
@@ -114,6 +114,10 @@ module VagrantPlugins
|
|
114
114
|
o.on("--credentials-file-path FILEPATH", String, cfpmsg) do |file_path|
|
115
115
|
options[:creds_file_path] = file_path
|
116
116
|
end
|
117
|
+
|
118
|
+
o.on("--deployment-tracker-host host", String, "Fully qualified URL of deployment-tracker instance") do |t|
|
119
|
+
options[:tracker_host] = t
|
120
|
+
end
|
117
121
|
end
|
118
122
|
|
119
123
|
argv = parse_options(opts)
|
@@ -135,7 +139,7 @@ module VagrantPlugins
|
|
135
139
|
# Success, exit status 0
|
136
140
|
0
|
137
141
|
end
|
138
|
-
# rubocop:enable
|
142
|
+
# rubocop:enable MethodLength
|
139
143
|
|
140
144
|
private
|
141
145
|
|
@@ -191,8 +195,8 @@ module VagrantPlugins
|
|
191
195
|
winrm_password: options[:winrm_password],
|
192
196
|
ssh_username: options[:ssh_username], ssh_password: options[:ssh_password],
|
193
197
|
ssh_private_key_path: options[:ssh_private_key_path],
|
194
|
-
servers: options[:servers],
|
195
|
-
|
198
|
+
servers: options[:servers], environments: options[:environments],
|
199
|
+
creds_prompt: options[:creds_prompt], tracker_host: options[:tracker_host]
|
196
200
|
)
|
197
201
|
write_file("Vagrantfile", contents, options)
|
198
202
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "English"
|
2
2
|
require "optparse"
|
3
3
|
require "vagrant"
|
4
|
-
require "vagrant-managed-servers/action/upload_status"
|
5
4
|
require_relative "../../vagrant-managed-servers/action"
|
6
5
|
require "vagrant-orchestrate/action/setcredentials"
|
7
6
|
require "vagrant-orchestrate/repo_status"
|
8
7
|
require_relative "command_mixins"
|
8
|
+
require "deployment-tracker-client"
|
9
9
|
|
10
10
|
# Borrowed from http://stackoverflow.com/questions/12374645/splitting-an-array-into-equal-parts-in-ruby
|
11
11
|
class Array
|
@@ -25,7 +25,7 @@ module VagrantPlugins
|
|
25
25
|
|
26
26
|
@logger = Log4r::Logger.new("vagrant_orchestrate::command::push")
|
27
27
|
|
28
|
-
# rubocop:disable
|
28
|
+
# rubocop:disable MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
29
29
|
def execute
|
30
30
|
options = {}
|
31
31
|
options[:force] = @env.vagrantfile.config.orchestrate.force_push
|
@@ -60,6 +60,8 @@ module VagrantPlugins
|
|
60
60
|
machines = filter_unmanaged(argv)
|
61
61
|
return 0 if machines.empty?
|
62
62
|
|
63
|
+
@start_time = Time.now
|
64
|
+
|
63
65
|
retrieve_creds(machines) if @env.vagrantfile.config.orchestrate.credentials
|
64
66
|
|
65
67
|
# Write the status file to disk so that it can be used as part of the
|
@@ -68,6 +70,13 @@ module VagrantPlugins
|
|
68
70
|
status.write(@env.tmp_path)
|
69
71
|
options[:status] = status
|
70
72
|
|
73
|
+
@env.action_runner.run(VagrantPlugins::ManagedServers::Action::InitDeploymentTracker,
|
74
|
+
tracker_host: @env.vagrantfile.config.orchestrate.tracker_host)
|
75
|
+
@env.action_runner.run(VagrantPlugins::ManagedServers::Action::TrackDeploymentStart,
|
76
|
+
tracker_host: @env.vagrantfile.config.orchestrate.tracker_host,
|
77
|
+
status: status,
|
78
|
+
args: ARGV.drop(2).join(" "))
|
79
|
+
|
71
80
|
options[:parallel] = true
|
72
81
|
strategy = options[:strategy] || @env.vagrantfile.config.orchestrate.strategy
|
73
82
|
@env.ui.info("Pushing to managed servers using #{strategy} strategy.")
|
@@ -76,33 +85,40 @@ module VagrantPlugins
|
|
76
85
|
strategy = :serial if machines.size == 1
|
77
86
|
strategy = :half_half if strategy.to_sym == :canary_half_half && machines.size == 2
|
78
87
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
88
|
+
begin
|
89
|
+
case strategy.to_sym
|
90
|
+
when :serial
|
91
|
+
options[:parallel] = false
|
92
|
+
result = deploy(options, machines)
|
93
|
+
when :parallel
|
94
|
+
result = deploy(options, machines)
|
95
|
+
when :canary
|
96
|
+
# A single canary server and then the rest
|
97
|
+
result = deploy(options, machines.take(1), machines.drop(1))
|
98
|
+
when :half_half
|
99
|
+
# Split into two (almost) equal groups
|
100
|
+
groups = split(machines)
|
101
|
+
result = deploy(options, groups.first, groups.last)
|
102
|
+
when :canary_half_half
|
103
|
+
# A single canary and then two equal groups
|
104
|
+
canary = machines.take(1)
|
105
|
+
groups = split(machines.drop(1))
|
106
|
+
result = deploy(options, canary, groups.first, groups.last)
|
107
|
+
else
|
108
|
+
@env.ui.error("Invalid deployment strategy specified")
|
109
|
+
result = false
|
110
|
+
end
|
111
|
+
ensure
|
112
|
+
@env.action_runner.run(VagrantPlugins::ManagedServers::Action::TrackDeploymentEnd,
|
113
|
+
tracker_host: @env.vagrantfile.config.orchestrate.tracker_host,
|
114
|
+
start_time: @start_time,
|
115
|
+
success: result)
|
100
116
|
end
|
101
117
|
|
102
118
|
return 1 unless result
|
103
119
|
0
|
104
120
|
end
|
105
|
-
# rubocop:enable
|
121
|
+
# rubocop:enable MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
106
122
|
|
107
123
|
def split(machines)
|
108
124
|
groups = machines.in_groups(2)
|
@@ -7,12 +7,14 @@ module VagrantPlugins
|
|
7
7
|
attr_accessor :filter_managed_commands
|
8
8
|
attr_accessor :strategy
|
9
9
|
attr_accessor :force_push
|
10
|
+
attr_accessor :tracker_host
|
10
11
|
attr_accessor :credentials
|
11
12
|
|
12
13
|
def initialize
|
13
14
|
@filter_managed_commands = UNSET_VALUE
|
14
15
|
@strategy = UNSET_VALUE
|
15
16
|
@force_push = UNSET_VALUE
|
17
|
+
@tracker_host = UNSET_VALUE
|
16
18
|
@credentials = Credentials.new
|
17
19
|
end
|
18
20
|
|
@@ -36,13 +38,16 @@ module VagrantPlugins
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
41
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
39
42
|
def finalize!
|
40
43
|
@filter_managed_commands = false if @filter_managed_commands == UNSET_VALUE
|
41
44
|
@strategy = :serial if @strategy == UNSET_VALUE
|
42
45
|
@force_push = false if @force_push == UNSET_VALUE
|
46
|
+
@tracker_host = nil if @tracker_host == UNSET_VALUE
|
43
47
|
@credentials = nil if @credentials.unset?
|
44
48
|
@credentials.finalize! if @credentials
|
45
49
|
end
|
50
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
46
51
|
|
47
52
|
class Credentials
|
48
53
|
# Same as Vagrant does to distinguish uninitialized variables and intentional assignments
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "vagrant-orchestrate/action/filtermanaged"
|
2
2
|
require "vagrant-orchestrate/action/setcredentials"
|
3
|
+
require "securerandom"
|
3
4
|
|
4
5
|
begin
|
5
6
|
require "vagrant"
|
@@ -15,6 +16,7 @@ end
|
|
15
16
|
|
16
17
|
module VagrantPlugins
|
17
18
|
module Orchestrate
|
19
|
+
DEPLOYMENT_ID = SecureRandom.uuid
|
18
20
|
class Plugin < Vagrant.plugin("2")
|
19
21
|
name "Orchestrate"
|
20
22
|
description <<-DESC
|
@@ -35,6 +35,12 @@ module VagrantPlugins
|
|
35
35
|
@repo
|
36
36
|
end
|
37
37
|
|
38
|
+
def branch
|
39
|
+
@branch ||= ENV["VAGRANT_ORCHESTRATE_STATUS_TEST_BRANCH"]
|
40
|
+
@branch ||= `git rev-parse --abbrev-ref HEAD`.chomp
|
41
|
+
@branch
|
42
|
+
end
|
43
|
+
|
38
44
|
def user
|
39
45
|
user = ENV["USER"] || ENV["USERNAME"] || "unknown"
|
40
46
|
user = ENV["USERDOMAIN"] + "\\" + user if ENV["USERDOMAIN"]
|
@@ -339,4 +339,14 @@ describe VagrantPlugins::Orchestrate::Command::Init do
|
|
339
339
|
end
|
340
340
|
end
|
341
341
|
end
|
342
|
+
|
343
|
+
context "deployment tracker" do
|
344
|
+
describe "deployment tracker host is specified" do
|
345
|
+
let(:argv) { ["--deployment-tracker-host", "http://deploymenttracker.io"] }
|
346
|
+
it "should be set in the Vagrantfile" do
|
347
|
+
subject.execute
|
348
|
+
expect(iso_env.vagrantfile.config.orchestrate.tracker_host).to eq("http://deploymenttracker.io")
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
342
352
|
end
|
@@ -14,6 +14,9 @@ Vagrant.configure("2") do |config|
|
|
14
14
|
<% if creds_file_path -%>
|
15
15
|
config.orchestrate.credentials.file_path = "<%= creds_file_path%>"
|
16
16
|
<% end -%>
|
17
|
+
<% if tracker_host -%>
|
18
|
+
config.orchestrate.tracker_host = "<%= tracker_host%>"
|
19
|
+
<% end -%>
|
17
20
|
|
18
21
|
<% if provisioners.include? "shell" -%>
|
19
22
|
<% shell_paths.each do |path| -%>
|
data/vagrant-orchestrate.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.add_runtime_dependency "deployment-tracker-client", "~> 0.1"
|
21
|
+
|
20
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
21
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
24
|
spec.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-orchestrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Baldauf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: deployment-tracker-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,12 +108,18 @@ files:
|
|
94
108
|
- acceptance/support-skeletons/prompt/dummy.box
|
95
109
|
- acceptance/support-skeletons/provision/Vagrantfile
|
96
110
|
- acceptance/support-skeletons/provision/dummy.box
|
111
|
+
- docs/deployment_tracker.md
|
97
112
|
- docs/environments.md
|
98
113
|
- docs/puppet.md
|
99
114
|
- docs/strategy.md
|
100
115
|
- dummy.box
|
101
116
|
- lib/vagrant-managed-servers/action.rb
|
102
117
|
- lib/vagrant-managed-servers/action/download_status.rb
|
118
|
+
- lib/vagrant-managed-servers/action/init_deployment_tracker.rb
|
119
|
+
- lib/vagrant-managed-servers/action/track_deployment_end.rb
|
120
|
+
- lib/vagrant-managed-servers/action/track_deployment_start.rb
|
121
|
+
- lib/vagrant-managed-servers/action/track_server_deployment_end.rb
|
122
|
+
- lib/vagrant-managed-servers/action/track_server_deployment_start.rb
|
103
123
|
- lib/vagrant-managed-servers/action/upload_status.rb
|
104
124
|
- lib/vagrant-orchestrate.rb
|
105
125
|
- lib/vagrant-orchestrate/action/filtermanaged.rb
|
@@ -141,9 +161,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
161
|
version: '0'
|
142
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
163
|
requirements:
|
144
|
-
- - '
|
164
|
+
- - '>'
|
145
165
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
166
|
+
version: 1.3.1
|
147
167
|
requirements: []
|
148
168
|
rubyforge_project:
|
149
169
|
rubygems_version: 2.0.14
|