vagrant-orchestrate 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/README.md +1 -1
- data/docs/strategy.md +35 -30
- data/lib/vagrant-orchestrate/command/push.rb +28 -13
- data/lib/vagrant-orchestrate/version.rb +1 -1
- 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: aa8ac72aee45a656c1a9e60a575c995075ddb053
|
4
|
+
data.tar.gz: a242a2fbad92acb639515f796ca8543989f07f05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6f36cc9190db80c3f91676533aa0e0f3856e0547dc88b62fda842ad3a413d0a4ca1389104bf2aa764d9946753e1b1bb895a76ee0d20a36255ef30a94ec3ea29
|
7
|
+
data.tar.gz: 303e98568405ab411a3e405d35c0b7aee9c1144480385afbc48f726ee05f0343ea50b95fbebd7c262f296415b71e40d73a282012690d943ecaf2304b0bf28ceb
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -262,7 +262,7 @@ The push command is currently limited by convention to vagrant machines that use
|
|
262
262
|
|
263
263
|
#### Deployment Strategy
|
264
264
|
|
265
|
-
Vagrant Orchestrate supports several deployment [strategies](docs/
|
265
|
+
Vagrant Orchestrate supports several deployment [strategies](docs/strategy.md) including parallel, canary and
|
266
266
|
blue-green.
|
267
267
|
|
268
268
|
You can push changes to all of your servers in parallel with
|
data/docs/strategy.md
CHANGED
@@ -1,29 +1,13 @@
|
|
1
1
|
# Deployment Strategies
|
2
2
|
|
3
|
-
Vagrant Orchestrate supports several deployment strategies
|
3
|
+
Vagrant Orchestrate supports several deployment strategies including parallel and
|
4
4
|
blue-green. Here we'll cover how to use the various strategies as well as describing
|
5
5
|
situations when each might be useful.
|
6
6
|
|
7
|
-
## Specifying a strategy
|
8
|
-
|
9
|
-
### Command line
|
10
|
-
|
11
|
-
Strategies can be passed on the command line with the `--strategy` parameter
|
12
|
-
|
13
|
-
$ vagrant orchestrate push --strategy parallel
|
14
|
-
|
15
|
-
### Vagrantfile configuration
|
16
|
-
|
17
|
-
Alternatively, you can specify the deployment strategy in your Vagrantfile
|
18
|
-
|
19
|
-
config.orchestrate.strategy = :parallel
|
20
|
-
|
21
|
-
Command line parameters take precedence over Vagrantfile set configuration values.
|
22
|
-
|
23
7
|
## Strategies
|
24
8
|
|
25
9
|
### Serial (default)
|
26
|
-
|
10
|
+
Deploy to the target servers one at a time. This can be useful if you
|
27
11
|
have a small number servers, or if you need to keep the majority of your servers
|
28
12
|
online in order to support your application's load.
|
29
13
|
|
@@ -33,8 +17,8 @@ online in order to support your application's load.
|
|
33
17
|
|
34
18
|
|
35
19
|
### Parallel
|
36
|
-
|
37
|
-
useful if you want to minimize the amount of time that an
|
20
|
+
Deploy to all of the target servers at the same time. This is
|
21
|
+
useful if you want to minimize the total amount of time that an deployment takes.
|
38
22
|
Depending on how you've written your provisioners, this could cause downtime for
|
39
23
|
the application that is being deployed.
|
40
24
|
|
@@ -43,8 +27,7 @@ the application that is being deployed.
|
|
43
27
|
config.orchestrate.strategy = :parallel
|
44
28
|
|
45
29
|
### Canary
|
46
|
-
|
47
|
-
test the deployed server, and then deploy the remainder of the servers in parallel.
|
30
|
+
Deploy to a single server, pause to allow for testing, and then deploy the remainder of the servers in parallel.
|
48
31
|
This is a great opportunity to test one node of your cluster before blasting your
|
49
32
|
changes out to them all. This can be particularly useful when combined with post
|
50
33
|
provision [trigger](https://github.com/emyl/vagrant-triggers) to run a smoke test.
|
@@ -56,36 +39,58 @@ provision [trigger](https://github.com/emyl/vagrant-triggers) to run a smoke tes
|
|
56
39
|
### Blue Green
|
57
40
|
The [Blue Green](http://martinfowler.com/bliki/BlueGreenDeployment.html) deployment
|
58
41
|
strategy deploys to half of the cluster in parallel, then the other half, with
|
59
|
-
a pause in between. This
|
60
|
-
|
42
|
+
a pause in between. This won't manage any of your load balancing or networking
|
43
|
+
configuration for you, but if your application has a healthcheck that your load
|
61
44
|
balancer respects, it should be easy to turn it off at the start of your provisioning
|
62
45
|
and back on at the end. If your application can serve the load on half of its nodes
|
63
46
|
then this will be the best blend of getting the deployment done quickly and maintaining
|
64
|
-
a
|
47
|
+
a running application. If the total number of target servers is odd then the smaller
|
48
|
+
number will be deployed to first.
|
65
49
|
|
66
50
|
$ vagrant orchestrate push --strategy blue_green
|
67
51
|
|
68
52
|
config.orchestrate.strategy = :blue_green
|
69
53
|
|
70
54
|
### Canary Blue Green
|
71
|
-
|
72
|
-
server, pausing, then to half the cluster in parallel, pausing, and then the
|
73
|
-
also in parallel.
|
55
|
+
Combines the two immediately above - deploying to a single
|
56
|
+
server, pausing, then to half of the remaining cluster in parallel, pausing, and then the other half,
|
57
|
+
also in parallel. This is good if you have a large number of servers and want to do a
|
74
58
|
smoke test of a single server before committing to pushing to half of your farm.
|
75
59
|
|
76
60
|
$ vagrant orchestrate push --strategy canary_blue_green
|
77
61
|
|
78
62
|
config.orchestrate.strategy = :canary_blue_green
|
79
63
|
|
64
|
+
## Specifying a strategy
|
65
|
+
|
66
|
+
### Command line
|
67
|
+
|
68
|
+
Strategies can be passed on the command line with the `--strategy` parameter
|
69
|
+
|
70
|
+
$ vagrant orchestrate push --strategy parallel
|
71
|
+
|
72
|
+
### Vagrantfile configuration
|
73
|
+
|
74
|
+
Alternatively, you can specify the deployment strategy in your Vagrantfile
|
75
|
+
|
76
|
+
config.orchestrate.strategy = :parallel
|
77
|
+
|
78
|
+
Command line parameters take precedence over configuration values set in the Vagrantfile.
|
79
|
+
|
80
|
+
|
80
81
|
## Suppressing Prompts
|
81
82
|
In order to automate the deployment process, it can be very useful to suppress
|
82
83
|
prompts. You can achieve that in two ways:
|
83
84
|
|
84
|
-
From the command line, add the `--force` or `-f`
|
85
|
+
From the command line, add the `--force` or `-f` parameters
|
85
86
|
|
86
87
|
$ vagrant orchestrate push --strategy canary -f
|
87
88
|
|
88
89
|
|
89
|
-
Within your
|
90
|
+
Within your Vagrantfile, set the `force_push` setting to true
|
90
91
|
|
91
92
|
config.orchestrate.force_push = true
|
93
|
+
|
94
|
+
## Support for other strategies
|
95
|
+
If you have ideas for other strategies that you think would be broadly useful,
|
96
|
+
open an issue and we'll discuss.
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "optparse"
|
2
2
|
require "vagrant"
|
3
3
|
|
4
|
+
# Borrowed from http://stackoverflow.com/questions/12374645/splitting-an-array-into-equal-parts-in-ruby
|
4
5
|
class Array
|
5
6
|
def in_groups(num_groups)
|
6
7
|
return [] if num_groups == 0
|
@@ -39,7 +40,6 @@ module VagrantPlugins
|
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
# Parse the options
|
43
43
|
argv = parse_options(opts)
|
44
44
|
return unless argv
|
45
45
|
|
@@ -54,16 +54,17 @@ module VagrantPlugins
|
|
54
54
|
|
55
55
|
if machines.empty?
|
56
56
|
@env.ui.info("No servers with :managed provider found. Skipping.")
|
57
|
-
return
|
57
|
+
return 0
|
58
58
|
end
|
59
59
|
|
60
|
-
# This environment variable is used as a signal to the filtermanaged
|
61
|
-
# action so that we don't filter managed commands that are really just
|
62
|
-
# the implementation of a push action.
|
63
|
-
|
64
60
|
options[:parallel] = true
|
65
61
|
strategy = options[:strategy] || @env.vagrantfile.config.orchestrate.strategy
|
66
62
|
@env.ui.info("Pushing to managed servers using #{strategy} strategy.")
|
63
|
+
|
64
|
+
# Handle a couple of them more tricky edges.
|
65
|
+
strategy = :serial if machines.size == 1
|
66
|
+
strategy = :blue_green if strategy.to_sym == :canary_blue_green && machines.size == 2
|
67
|
+
|
67
68
|
case strategy.to_sym
|
68
69
|
when :serial
|
69
70
|
options[:parallel] = false
|
@@ -75,12 +76,12 @@ module VagrantPlugins
|
|
75
76
|
result = deploy(options, machines.take(1), machines.drop(1))
|
76
77
|
when :blue_green
|
77
78
|
# Split into two (almost) equal groups
|
78
|
-
groups = machines
|
79
|
+
groups = split(machines)
|
79
80
|
result = deploy(options, groups.first, groups.last)
|
80
81
|
when :canary_blue_green
|
81
82
|
# A single canary and then two equal groups
|
82
83
|
canary = machines.take(1)
|
83
|
-
groups = machines.drop(1)
|
84
|
+
groups = split(machines.drop(1))
|
84
85
|
result = deploy(options, canary, groups.first, groups.last)
|
85
86
|
else
|
86
87
|
@env.ui.error("Invalid deployment strategy specified")
|
@@ -90,12 +91,23 @@ module VagrantPlugins
|
|
90
91
|
return 1 unless result
|
91
92
|
0
|
92
93
|
end
|
93
|
-
|
94
|
+
|
95
|
+
def split(machines)
|
96
|
+
groups = machines.in_groups(2)
|
97
|
+
# Move an item from the first to second group if they are unbalanced so that
|
98
|
+
# the smaller group is pushed to first.
|
99
|
+
groups.last.unshift(groups.first.pop) if groups.any? && groups.first.size > groups.last.size
|
100
|
+
groups
|
101
|
+
end
|
94
102
|
|
95
103
|
def deploy(options, *groups)
|
104
|
+
groups.select! { |g| g.size > 0 }
|
96
105
|
groups.each_with_index do |machines, index|
|
97
|
-
|
98
|
-
|
106
|
+
next if machines.empty?
|
107
|
+
if groups.size > 1
|
108
|
+
@env.ui.info("Orchestrating push to group number #{index + 1} of #{groups.size}.")
|
109
|
+
@env.ui.info(" -- Hosts: #{machines.collect { |m| m.name.to_s }.join(',')}")
|
110
|
+
end
|
99
111
|
ENV["VAGRANT_ORCHESTRATE_COMMAND"] = "PUSH"
|
100
112
|
begin
|
101
113
|
batchify(machines, :up, options)
|
@@ -108,16 +120,19 @@ module VagrantPlugins
|
|
108
120
|
end
|
109
121
|
|
110
122
|
# Don't prompt on the last group, that would be annoying
|
111
|
-
|
123
|
+
if index == groups.size - 1 || options[:force]
|
124
|
+
@logger.debug("Suppressing prompt because --force specified.") if options[:force]
|
125
|
+
else
|
112
126
|
return false unless prompt_for_continue
|
113
127
|
end
|
114
128
|
end
|
115
129
|
end
|
130
|
+
# rubocop:enable Metrics/AbcSize, MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
116
131
|
|
117
132
|
def prompt_for_continue
|
118
133
|
result = @env.ui.ask("Deployment paused for manual review. Would you like to continue? (y/n)")
|
119
134
|
if result.upcase != "Y"
|
120
|
-
@env.ui.info("Deployment push action by user")
|
135
|
+
@env.ui.info("Deployment push action cancelled by user")
|
121
136
|
return false
|
122
137
|
end
|
123
138
|
true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-orchestrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
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-03-
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|