vagrant-orchestrate 0.5.3 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e792cb68c033c004720ce8142c97148c62d3d3b3
4
- data.tar.gz: f923b195cde3ae62356f3acd78419f829859cb03
3
+ metadata.gz: daf8bdc44383203b8cc60e708fbd4ef931c88897
4
+ data.tar.gz: 2917a0107512412d3c210c78fd1ba0c10e895d19
5
5
  SHA512:
6
- metadata.gz: a4a923bbb339a50c8660a98b47e0622890f6a5857514ad93e262d0de7215cc6edda47a11b0732aea3499aca8160044b19081e4b5feeb456be80e10cbdd016ee4
7
- data.tar.gz: cc35054d935113db19f082744ac4a2d4eb720765ddcb55bde0dd098d021b1d2e98d3d7931a70750b9f50d48d7290b4e1b3117297e59a7243c90e10f99bc96d11
6
+ metadata.gz: 90e979ed582054c9f26c9458779103ca7f30230b5733843e57f46f4cae8932f8024abc00aa9eaf02c7042996761554842afeb99a04c7fe652c0a2f816b8db146
7
+ data.tar.gz: cf23917f10e5672b2372690dcf57ee61d6a1135ee44a503d709c8753475e4d944d6da01e7227b027612dfc15cb59152fd4b5c3b44b40f194af7861906c215f90
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ 0.6.0 (May 15th, 2015)
2
+
3
+ - Refactor the push command to compose middleware actions rather than performing
4
+ a bunch of work in the command itself. This means that a push using the `parallel`
5
+ strategy will truly be parallel per box, as opposed to the old implementation where
6
+ the `up`, `provision`, `upload_stats`, and `destroy` phases would each happen in
7
+ parallel, but the phases would be done in series.
8
+ - Change the `vagrant orchestrate status` command so that it will run in parallel.
9
+ - Add `vagrant-orchestrate` as a default required plugin. Someone will have to
10
+ install it "by hand" to access the init functionality, but other users pulling
11
+ down a repo with a committed Vagrantfile will not, making each repo more self-contained.
12
+
1
13
  0.5.3 (May 13th, 2015)
2
14
 
3
15
  - Fix a bug where the VAGRANT_ORCHESTRATE_USERNAME and VAGRANT_ORCHESTRATE_PASSWORD
data/README.md CHANGED
@@ -205,6 +205,8 @@ You'll need to bootstrap the target machine. The following script should get you
205
205
  winrm quickconfig
206
206
  winrm set winrm/config/service/auth @{Negotiate="true"}
207
207
  winrm set winrm/config/service @{AllowUnencrypted="false"}
208
+ winrm set winrm/config/winrs @{MaxShellsPerUser="25"}
209
+ winrm set winrm/config/winrs @{MaxConcurrentUsers="25"}
208
210
  sc config winrm start= auto
209
211
  sc config winrm type= own
210
212
  ```
@@ -0,0 +1,31 @@
1
+ # It is useful to be able to call up, provision, reload, and destroy as a single
2
+ # unit - it makes things like parallel provisioning more seamless and provides
3
+ # a useful action hook for the push command.
4
+ module VagrantPlugins
5
+ module ManagedServers
6
+ module Action
7
+ include Vagrant::Action::Builtin
8
+
9
+ def self.action_push
10
+ Vagrant::Action::Builder.new.tap do |b|
11
+ b.use action_up
12
+ b.use Call, action_provision do |env, b2|
13
+ if env[:reboot]
14
+ b2.use Call, action_reload do |_env, _b3|
15
+ end
16
+ end
17
+ end
18
+ b.use UploadStatus
19
+ b.use action_destroy
20
+ end
21
+ end
22
+
23
+ def self.action_download_status
24
+ Vagrant::Action::Builder.new.tap do |b|
25
+ b.use ConfigValidate
26
+ b.use DownloadStatus
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,38 @@
1
+ require "log4r"
2
+
3
+ module VagrantPlugins
4
+ module ManagedServers
5
+ module Action
6
+ class DownloadStatus
7
+ def initialize(app, _env)
8
+ @app = app
9
+ @logger = Log4r::Logger.new("vagrant_managed_servers::action::print_status")
10
+ end
11
+
12
+ def call(env)
13
+ download_status(env[:machine], env[:local_file_path], env[:remote_file_path], env[:ui])
14
+
15
+ @app.call(env)
16
+ end
17
+
18
+ def download_status(machine, local, remote, ui)
19
+ machine.communicate.wait_for_ready(5)
20
+ @logger.debug("Downloading orchestrate status for #{machine.name}")
21
+ @logger.debug(" remote file: #{remote}")
22
+ @logger.debug(" local file: #{local}")
23
+ machine.communicate.download(remote, local)
24
+ content = File.read(local)
25
+ @logger.debug("File content:")
26
+ @logger.debug(content)
27
+ status = JSON.parse(content)
28
+ ENV["VAGRANT_ORCHESTRATE_STATUS"] += machine.name.to_s + " " + status["last_sync"] + \
29
+ " " + status["ref"] + " " + status["user"] + "\n"
30
+ rescue => ex
31
+ ui.warn("Error downloading status for #{machine.name}.")
32
+ ui.warn(ex.message)
33
+ ENV["VAGRANT_ORCHESTRATE_STATUS"] += machine.name.to_s + " Status unavailable.\n"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ require "log4r"
2
+
3
+ module VagrantPlugins
4
+ module ManagedServers
5
+ module Action
6
+ class UploadStatus
7
+ def initialize(app, _env)
8
+ @app = app
9
+ @logger = Log4r::Logger.new("vagrant_managed_servers::action::upload_status")
10
+ end
11
+
12
+ def call(env)
13
+ upload_status(env[:status], env[:machine], env[:ui])
14
+
15
+ @app.call(env)
16
+ end
17
+
18
+ def upload_status(status, machine, ui)
19
+ source = status.local_path
20
+ destination = status.remote_path(machine.config.vm.communicator)
21
+ parent_folder = File.split(destination)[0]
22
+ machine.communicate.wait_for_ready(5)
23
+ @logger.debug("Ensuring vagrant_orchestrate status directory exists")
24
+ machine.communicate.sudo("mkdir -p #{parent_folder}")
25
+ machine.communicate.sudo("chmod 777 #{parent_folder}")
26
+ ui.info("Uploading vagrant orchestrate status")
27
+ @logger.debug("Uploading vagrant_orchestrate status")
28
+ @logger.debug(" source: #{source}")
29
+ @logger.debug(" dest: #{destination}")
30
+ machine.communicate.upload(source, destination)
31
+ @logger.debug("Setting uploaded file world-writable")
32
+ machine.communicate.sudo("chmod 777 #{destination}")
33
+ rescue => ex
34
+ @logger.error(ex)
35
+ ui.warn("An error occurred when trying to upload status to #{machine.name}. Continuing")
36
+ ui.warn(ex.message)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -13,7 +13,7 @@ module VagrantPlugins
13
13
  DEFAULT_WINRM_PASSWORD = "{{YOUR_WINRM_PASSWORD}}"
14
14
  DEFAULT_SSH_USERNAME = "{{YOUR_SSH_USERNAME}}"
15
15
  DEFAULT_SSH_PRIVATE_KEY_PATH = "{{YOUR_SSH_PRIVATE_KEY_PATH}}"
16
- DEFAULT_PLUGINS = ["vagrant-managed-servers"]
16
+ DEFAULT_PLUGINS = ["vagrant-orchestrate", "vagrant-managed-servers"]
17
17
 
18
18
  # rubocop:disable Metrics/AbcSize, MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
19
19
  def execute
@@ -1,6 +1,8 @@
1
1
  require "English"
2
2
  require "optparse"
3
3
  require "vagrant"
4
+ require "vagrant-managed-servers/action/upload_status"
5
+ require_relative "../../vagrant-managed-servers/action"
4
6
  require "vagrant-orchestrate/action/setcredentials"
5
7
  require "vagrant-orchestrate/repo_status"
6
8
  require_relative "command_mixins"
@@ -60,6 +62,12 @@ module VagrantPlugins
60
62
 
61
63
  retrieve_creds(machines) if @env.vagrantfile.config.orchestrate.credentials
62
64
 
65
+ # Write the status file to disk so that it can be used as part of the
66
+ # push action.
67
+ status = RepoStatus.new
68
+ status.write(@env.tmp_path)
69
+ options[:status] = status
70
+
63
71
  options[:parallel] = true
64
72
  strategy = options[:strategy] || @env.vagrantfile.config.orchestrate.strategy
65
73
  @env.ui.info("Pushing to managed servers using #{strategy} strategy.")
@@ -115,13 +123,11 @@ module VagrantPlugins
115
123
  end
116
124
  ENV["VAGRANT_ORCHESTRATE_COMMAND"] = "PUSH"
117
125
  begin
118
- batchify(machines, :up, options)
119
- batchify(machines, :provision, options) if options[:provision]
120
- upload_status_all(machines)
121
- batchify(machines, :reload, options) if options[:reboot]
126
+ batchify(machines, :push, options)
122
127
  ensure
123
- batchify(machines, :destroy, options)
124
128
  @logger.debug("Finished orchestrating push to group number #{index + 1} of #{groups.size}.")
129
+ status_source = options[:status].local_path
130
+ super_delete(status_source) if File.exist?(status_source)
125
131
  ENV.delete "VAGRANT_ORCHESTRATE_COMMAND"
126
132
  end
127
133
 
@@ -147,6 +153,9 @@ module VagrantPlugins
147
153
  def batchify(machines, action, options)
148
154
  @env.batch(options[:parallel]) do |batch|
149
155
  machines.each do |machine|
156
+ # This is necessary to disable the low level provisioning in the
157
+ # Vagrant builtin provisioner.
158
+ options[:provision_enabled] = false unless options[:provision]
150
159
  batch.action(machine, action, options)
151
160
  end
152
161
  end
@@ -170,36 +179,6 @@ module VagrantPlugins
170
179
  message = "ERROR!\nThere are files that need to be committed first."
171
180
  RepoStatus.clean? && RepoStatus.committed? && !RepoStatus.untracked? || abort(message)
172
181
  end
173
-
174
- def upload_status_all(machines)
175
- status = RepoStatus.new
176
- source = File.join(@env.tmp_path, "vagrant_orchestrate_status")
177
- File.write(source, status.to_json)
178
- machines.each do |machine|
179
- upload_status_one(source, status, machine)
180
- end
181
- ensure
182
- super_delete(source) if File.exist?(source)
183
- end
184
-
185
- def upload_status_one(source, status, machine)
186
- destination = status.remote_path(machine.config.vm.communicator)
187
- parent_folder = File.split(destination)[0]
188
- machine.communicate.wait_for_ready(5)
189
- @logger.debug("Ensuring vagrant_orchestrate status directory exists")
190
- machine.communicate.sudo("mkdir -p #{parent_folder}")
191
- machine.communicate.sudo("chmod 777 #{parent_folder}")
192
- @logger.debug("Uploading vagrant_orchestrate status file")
193
- @logger.debug(" source: #{source}")
194
- @logger.debug(" dest: #{destination}")
195
- machine.communicate.upload(source, destination)
196
- @logger.debug("Setting uploaded file world-writable")
197
- machine.communicate.sudo("chmod 777 #{destination}")
198
- rescue => ex
199
- @logger.error(ex)
200
- @env.ui.warn("An error occurred when trying to upload status to #{machine.name}. Continuing")
201
- @env.ui.warn(ex.message)
202
- end
203
182
  end
204
183
  end
205
184
  end
@@ -1,6 +1,8 @@
1
1
  require "json"
2
2
  require "optparse"
3
3
  require "vagrant"
4
+ require "vagrant-managed-servers/action/download_status"
5
+ require_relative "../../vagrant-managed-servers/action"
4
6
  require "vagrant-orchestrate/repo_status"
5
7
  require_relative "command_mixins"
6
8
 
@@ -32,36 +34,26 @@ module VagrantPlugins
32
34
  # There is some detail output fromt he communicator.download that I
33
35
  # don't want to suppress, but I also don't want it to be interspersed
34
36
  # with the actual status information. Let's buffer the status output.
35
- output = []
37
+ ENV["VAGRANT_ORCHESTRATE_STATUS"] = ""
36
38
  @logger.debug("About to download machine status")
37
- machines.each do |machine|
38
- output << get_status(RepoStatus.new.remote_path(machine.config.vm.communicator), machine)
39
+ options = {}
40
+ parallel = true
41
+ local_files = []
42
+ @env.batch(parallel) do |batch|
43
+ machines.each do |machine|
44
+ options[:remote_file_path] = RepoStatus.new.remote_path(machine.config.vm.communicator)
45
+ options[:local_file_path] = File.join(@env.tmp_path, "#{machine.name}_status")
46
+ local_files << options[:local_file_path]
47
+ batch.action(machine, :download_status, options)
48
+ end
39
49
  end
40
50
  @env.ui.info("Current managed server states:")
41
51
  @env.ui.info("")
42
- output.each do |line|
43
- @env.ui.info line
44
- end
45
- end
46
-
47
- def get_status(remote, machine)
48
- machine.communicate.wait_for_ready(5)
49
- local = File.join(@env.tmp_path, "#{machine.name}_status")
50
- @logger.debug("Downloading orchestrate status for #{machine.name}")
51
- @logger.debug(" remote file: #{remote}")
52
- @logger.debug(" local file: #{local}")
53
- machine.communicate.download(remote, local)
54
- content = File.read(local)
55
- @logger.debug("File content:")
56
- @logger.debug(content)
57
- status = JSON.parse(content)
58
- return machine.name.to_s + " " + status["last_sync"] + " " + status["ref"] + " " + status["user"]
59
- rescue => ex
60
- @env.ui.warn("Error downloading status for #{machine.name}.")
61
- @env.ui.warn(ex.message)
62
- return machine.name.to_s + " Status unavailable."
52
+ @env.ui.info(ENV["VAGRANT_ORCHESTRATE_STATUS"].split("\n").sort.join("\n"))
63
53
  ensure
64
- super_delete(local) if File.exist?(local)
54
+ local_files.each do |local|
55
+ super_delete(local) if File.exist?(local)
56
+ end
65
57
  end
66
58
  end
67
59
  end
@@ -4,9 +4,11 @@ module VagrantPlugins
4
4
  module Orchestrate
5
5
  class RepoStatus
6
6
  attr_reader :last_sync
7
+ attr_accessor :local_path
7
8
 
8
9
  def initialize
9
10
  @last_sync = Time.now.utc # Managed servers could be in different timezones
11
+ @local_path = nil
10
12
  end
11
13
 
12
14
  def ref
@@ -47,6 +49,11 @@ module VagrantPlugins
47
49
  JSON.pretty_generate(contents)
48
50
  end
49
51
 
52
+ def write(tmp_path)
53
+ @local_path = File.join(tmp_path, "vagrant_orchestrate_status")
54
+ File.write(@local_path, to_json)
55
+ end
56
+
50
57
  # The path to where this should be stored on a remote machine, inclusive
51
58
  # of the file name.
52
59
  def remote_path(communicator)
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Orchestrate
3
- VERSION = "0.5.3"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
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.5.3
4
+ version: 0.6.0
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-05-13 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,6 +97,9 @@ files:
97
97
  - docs/puppet.md
98
98
  - docs/strategy.md
99
99
  - dummy.box
100
+ - lib/vagrant-managed-servers/action.rb
101
+ - lib/vagrant-managed-servers/action/download_status.rb
102
+ - lib/vagrant-managed-servers/action/upload_status.rb
100
103
  - lib/vagrant-orchestrate.rb
101
104
  - lib/vagrant-orchestrate/action/filtermanaged.rb
102
105
  - lib/vagrant-orchestrate/action/setcredentials.rb