vagrant-orchestrate 0.6.2 → 0.6.3

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: 80b84f5db56bf4767530fe1403673e231e82fd16
4
- data.tar.gz: 00b853143e5e3bf505b5837b7b1b6915fd5a304c
3
+ metadata.gz: cc6337e73b1299cc2a5ddfbd7bc634f910c22613
4
+ data.tar.gz: c40465611605716c68d8e0a7f547a8471ffe85ea
5
5
  SHA512:
6
- metadata.gz: 77a0d874b43a58ffbc7191cee88e52ce1c4cafaa972b853e93af2381863e5fc5132e958005befddc8d7136a688ac98cccd63aae7e53c8edee1934e7389b87e9f
7
- data.tar.gz: af691174d2a81c8fe780ecfb16433e1126d625bbfc10cc1e75c37ea44c43ae7d0c35964b454a75c14fe74dfb6ed43a195f19f4820313a23415bbfa261aaea97b
6
+ metadata.gz: 3b72416ac1cb3ed860aedf7ecb872df81d57942ad8e5ec90b4802e5e6a4b6e0801fff9c1e0eb573b64ebb816822d504d3285d46aeecd5916c86e603aed3f70d5
7
+ data.tar.gz: 4ebd44c1049d983ac78d56458f61d30d4bfbe86f6447a3486c9de35765ef633222e25e4a64164d7b3493cd0a3bf5d152a4be3a07632a32f53a000d51e28869b1
data/.rubocop.yml CHANGED
@@ -1,7 +1,3 @@
1
- AllCops:
2
- Exclude:
3
- - '*.gemspec'
4
-
5
1
  Metrics/LineLength:
6
2
  Max: 120
7
3
 
@@ -22,3 +18,6 @@ Style/FileName:
22
18
 
23
19
  Metrics/AbcSize:
24
20
  Max: 100
21
+
22
+ RegexpLiteral:
23
+ MaxSlashes: 0
data/.vagrantplugins ADDED
@@ -0,0 +1,22 @@
1
+ required_plugins = {}
2
+ # Example usage:
3
+ # required_plugins["plugin-name"] = { version: "1.2.3", source: "https://rubygems.org" }
4
+ required_plugins["vagrant-orchestrate"] = {}
5
+ required_plugins["vagrant-managed-servers"] = {}
6
+
7
+ needs_restart = false
8
+ required_plugins.each do |plugin, options|
9
+ version = options[:version]
10
+
11
+ unless Vagrant.has_plugin?(plugin, version)
12
+ command = "vagrant plugin install #{plugin}"
13
+ command += " --plugin-version #{version}" if version
14
+ command += " --plugin-source #{options[:source]}" if options[:source]
15
+ system command
16
+ needs_restart = true
17
+ end
18
+ end
19
+
20
+ if needs_restart
21
+ exec "vagrant #{ARGV.join' '}"
22
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ 0.6.3 (May 26th, 2015)
2
+
3
+ - Extract the `required_plugins` definition and installation logic from the
4
+ `Vagrantfile` to a new `.vagrantplugins` file per https://github.com/mitchellh/vagrant/issues/4347
5
+ - Change required_plugins from array to hash[plugin-name] = {options}. This allows specifying specific versions of plugins to be installed as well as alternate gem sources, which is useful for internally hosted gems.
6
+ - Fall back to the Vagrant environment's `root_path` if the working directory is
7
+ not a git repo. Fixes [#34](https://github.com/Cimpress-MCP/vagrant-orchestrate/issues/34)
8
+
1
9
  0.6.2 (May 25th, 2015)
2
10
 
3
11
  - Change the implementation of the `RepoStatus.repo` method from relying on a
data/README.md CHANGED
@@ -56,10 +56,6 @@ Which produces a simple default Vagrantfile that can push to managed servers:
56
56
  ```ruby
57
57
  managed_servers = %w( )
58
58
 
59
- required_plugins = %w( vagrant-managed-servers )
60
- required_plugins.each do |plugin|
61
- system "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
62
- end
63
59
  Vagrant.configure("2") do |config|
64
60
  # This disables up, provision, reload, and destroy for managed servers. Use
65
61
  # `vagrant orchestrate push` to communicate with managed servers.
@@ -111,12 +107,26 @@ This works for Windows managed servers using WinRM as well
111
107
 
112
108
  #### Plugins
113
109
 
114
- This also supports a portable and repeatable way to install plugins, just list them in the required_plugins section
110
+ This also supports a portable and repeatable way to install plugins, just list them in the .vagrantplugins file.
111
+ `version` and `source` are the supported values in the options hash, but neither is required.
115
112
 
116
113
  ```ruby
117
- required_plugins = %w( vagrant-managed-servers vagrant-hostsupdater )
114
+ required_plugins = {}
115
+ required_plugins["vagrant-orchestrate"] = {}
116
+ required_plugins["vagrant-managed-servers"] = { version: "0.7.0" }
118
117
  ```
119
118
 
119
+ If you are executing in a shared environment, like a build slave, you can create your own
120
+ own plugin install directory by setting the `VAGRANT_HOME` variable to something relative
121
+ to the current directory.
122
+
123
+ $ VAGRANT_HOME=./.vagrant.d vagrant orchestrate push
124
+
125
+ or
126
+
127
+ > SET VAGRANT_HOME=./.vagrant.d
128
+ > vagrant orchestrate push
129
+
120
130
  #### Working with multiple environments
121
131
 
122
132
  Vagrant Orchestrate offers a way to manage multiple environments using a combination of a single servers.json file and the name of the current git branch as an indicator of the current environment.
@@ -6,7 +6,7 @@ describe "vagrant orchestrate status", component: "orchestrate/status" do
6
6
 
7
7
  TEST_REF = "050bfd9c686b06c292a9614662b0ab1bbf652db3"
8
8
  TEST_REMOTE_ORIGIN_URL = "http://github.com/Cimpress-MCP/vagrant-orchestrate.git"
9
- TEST_REPO = "/users/cbaldauf/dev/vagrant-orchestrate"
9
+ TEST_REPO = "vagrant-orchestrate"
10
10
 
11
11
  before do
12
12
  environment.skeleton("basic")
@@ -14,7 +14,8 @@ describe "vagrant orchestrate status", component: "orchestrate/status" do
14
14
 
15
15
  it "handles no status file gracefully" do
16
16
  # Make sure we're starting from a clean slate, rspec order isn't guaranteed.
17
- execute("vagrant", "ssh", "-c", "\"rm -rf /var/state/vagrant_orchestrate\" managed-1")
17
+ execute("vagrant", "up", "managed-1")
18
+ execute("vagrant", "ssh", "-c", "\"sudo rm -rf /var/state/vagrant_orchestrate\"", "managed-1")
18
19
  # All commands are executed against a single machine to reduce variability
19
20
  result = execute("vagrant", "orchestrate", "status", "/managed-1/")
20
21
  expect(result.stdout).to include("Status unavailable.")
@@ -30,7 +31,7 @@ describe "vagrant orchestrate status", component: "orchestrate/status" do
30
31
  ENV["VAGRANT_ORCHESTRATE_NO_GUARD_CLEAN"] = "true"
31
32
  execute("vagrant", "orchestrate", "push", "/managed-1/")
32
33
  result = execute("vagrant", "orchestrate", "status", "/managed-1/")
33
- status = VagrantPlugins::Orchestrate::RepoStatus.new
34
+ status = VagrantPlugins::Orchestrate::RepoStatus.new(TEST_REPO)
34
35
  # Punting on date. Can always add it later if needed
35
36
  expect(result.stdout).to include(status.ref)
36
37
  expect(result.stdout).to include(status.user)
@@ -18,6 +18,7 @@ module VagrantPlugins
18
18
  def download_status(machine, local, remote, ui)
19
19
  machine.communicate.wait_for_ready(5)
20
20
  @logger.debug("Downloading orchestrate status for #{machine.name}")
21
+ ui.info("Downloading orchestrate status from #{remote}")
21
22
  @logger.debug(" remote file: #{remote}")
22
23
  @logger.debug(" local file: #{local}")
23
24
  machine.communicate.download(remote, local)
@@ -23,7 +23,7 @@ module VagrantPlugins
23
23
  @logger.debug("Ensuring vagrant_orchestrate status directory exists")
24
24
  machine.communicate.sudo("mkdir -p #{parent_folder}")
25
25
  machine.communicate.sudo("chmod 777 #{parent_folder}")
26
- ui.info("Uploading vagrant orchestrate status")
26
+ ui.info("Uploading vagrant orchestrate status to #{destination}")
27
27
  @logger.debug("Uploading vagrant_orchestrate status")
28
28
  @logger.debug(" source: #{source}")
29
29
  @logger.debug(" dest: #{destination}")
@@ -126,34 +126,39 @@ module VagrantPlugins
126
126
  options[:ssh_username] ||= DEFAULT_SSH_USERNAME
127
127
  options[:ssh_private_key_path] ||= DEFAULT_SSH_PRIVATE_KEY_PATH unless options[:ssh_password]
128
128
 
129
+ write_vagrant_files(options)
130
+ @env.ui.info(I18n.t("vagrant.commands.init.success"), prefix: false)
131
+
132
+ # Success, exit status 0
133
+ 0
134
+ end
135
+ # rubocop:enable Metrics/AbcSize, MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
136
+
137
+ private
138
+
139
+ def write_vagrant_files(options)
129
140
  contents = TemplateRenderer.render(Orchestrate.source_root.join("templates/vagrant/Vagrantfile"),
130
- provisioners: options[:provisioners],
131
- shell_paths: options[:shell_paths],
141
+ provisioners: options[:provisioners], shell_paths: options[:shell_paths],
132
142
  shell_inline: options[:shell_inline],
133
143
  puppet_librarian_puppet: options[:puppet_librarian_puppet],
134
- puppet_hiera: options[:puppet_hiera],
135
- communicator: options[:communicator],
144
+ puppet_hiera: options[:puppet_hiera], communicator: options[:communicator],
136
145
  winrm_username: options[:winrm_username],
137
146
  winrm_password: options[:winrm_password],
138
- ssh_username: options[:ssh_username],
139
- ssh_password: options[:ssh_password],
147
+ ssh_username: options[:ssh_username], ssh_password: options[:ssh_password],
140
148
  ssh_private_key_path: options[:ssh_private_key_path],
141
149
  servers: options[:servers],
142
- environments: options[:environments],
143
- plugins: options[:plugins],
144
- creds_prompt: options[:creds_prompt]
150
+ environments: options[:environments], creds_prompt: options[:creds_prompt]
145
151
  )
146
152
  write_file("Vagrantfile", contents, options)
153
+
154
+ contents = TemplateRenderer.render(Orchestrate.source_root.join("templates/vagrant/.vagrantplugins"),
155
+ plugins: options[:plugins]
156
+ )
157
+ write_file(".vagrantplugins", contents, options)
158
+
147
159
  FileUtils.cp(Orchestrate.source_root.join("templates", "vagrant", "dummy.box"),
148
160
  File.join(@env.cwd, "dummy.box"))
149
- @env.ui.info(I18n.t("vagrant.commands.init.success"), prefix: false)
150
-
151
- # Success, exit status 0
152
- 0
153
161
  end
154
- # rubocop:enable Metrics/AbcSize, MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
155
-
156
- private
157
162
 
158
163
  def init_puppet(options)
159
164
  return unless options[:provisioners].include? "puppet"
@@ -64,7 +64,7 @@ module VagrantPlugins
64
64
 
65
65
  # Write the status file to disk so that it can be used as part of the
66
66
  # push action.
67
- status = RepoStatus.new
67
+ status = RepoStatus.new(@env.root_path)
68
68
  status.write(@env.tmp_path)
69
69
  options[:status] = status
70
70
 
@@ -41,14 +41,14 @@ module VagrantPlugins
41
41
  local_files = []
42
42
  @env.batch(parallel) do |batch|
43
43
  machines.each do |machine|
44
- options[:remote_file_path] = RepoStatus.new.remote_path(machine.config.vm.communicator)
44
+ status = RepoStatus.new(@env.root_path)
45
+ options[:remote_file_path] = status.remote_path(machine.config.vm.communicator)
45
46
  options[:local_file_path] = File.join(@env.tmp_path, "#{machine.name}_status")
46
47
  local_files << options[:local_file_path]
47
48
  batch.action(machine, :download_status, options)
48
49
  end
49
50
  end
50
- @env.ui.info("Current managed server states:")
51
- @env.ui.info("")
51
+ @env.ui.info("Current managed server states:\n")
52
52
  @env.ui.info(ENV["VAGRANT_ORCHESTRATE_STATUS"].split("\n").sort.join("\n"))
53
53
  ensure
54
54
  local_files.each do |local|
@@ -3,12 +3,14 @@ require "json"
3
3
  module VagrantPlugins
4
4
  module Orchestrate
5
5
  class RepoStatus
6
- attr_reader :last_sync
6
+ attr_reader :last_sync, :root_path
7
7
  attr_accessor :local_path
8
8
 
9
- def initialize
9
+ def initialize(root_path)
10
10
  @last_sync = Time.now.utc # Managed servers could be in different timezones
11
11
  @local_path = nil
12
+ # The fully qualified path to the root of the repo
13
+ @root_path = root_path
12
14
  end
13
15
 
14
16
  def ref
@@ -21,13 +23,15 @@ module VagrantPlugins
21
23
 
22
24
  def remote_origin_url
23
25
  @remote_origin_url ||= ENV["VAGRANT_ORCHESTRATE_STATUS_TEST_REMOTE_ORIGIN_URL"]
24
- @remote_origin_url ||= `git config --get remote.origin.url`.chomp
26
+ @remote_origin_url ||= `git config --get remote.origin.url 2>#{File::NULL}`.chomp
25
27
  @remote_origin_url
26
28
  end
27
29
 
28
30
  def repo
29
31
  @repo ||= ENV["VAGRANT_ORCHESTRATE_STATUS_TEST_REPO"]
30
- @repo ||= File.basename(`git rev-parse --show-toplevel`.chomp)
32
+ @repo ||= File.basename(`git rev-parse --show-toplevel 2>#{File::NULL}`.chomp)
33
+ # This might not be a git repo, and that should still be supported.
34
+ @repo = File.basename(root_path) if @repo.nil? || @repo.empty?
31
35
  @repo
32
36
  end
33
37
 
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Orchestrate
3
- VERSION = "0.6.2"
3
+ VERSION = "0.6.3"
4
4
  end
5
5
  end
@@ -119,8 +119,8 @@ describe VagrantPlugins::Orchestrate::Command::Init do
119
119
 
120
120
  it "contains the plugin" do
121
121
  subject.execute
122
- vagrantfile = File.readlines(File.join(iso_env.cwd, "Vagrantfile")).join
123
- expect(vagrantfile).to include("vagrant-librarian-puppet")
122
+ pluginsfile = File.readlines(File.join(iso_env.cwd, ".vagrantplugins")).join
123
+ expect(pluginsfile).to include("vagrant-librarian-puppet")
124
124
  end
125
125
 
126
126
  describe "negative" do
@@ -186,8 +186,8 @@ describe VagrantPlugins::Orchestrate::Command::Init do
186
186
  let(:argv) { ["--winrm"] }
187
187
  it "includes the vagrant-winrm-s plugin"do
188
188
  subject.execute
189
- vagrantfile = File.readlines(File.join(iso_env.cwd, "Vagrantfile")).join
190
- expect(vagrantfile).to include("vagrant-winrm-s")
189
+ pluginsfile = File.readlines(File.join(iso_env.cwd, ".vagrantplugins")).join
190
+ expect(pluginsfile).to include("vagrant-winrm-s")
191
191
  end
192
192
  end
193
193
 
@@ -246,12 +246,14 @@ describe VagrantPlugins::Orchestrate::Command::Init do
246
246
 
247
247
  context "plugins" do
248
248
  describe "default" do
249
- it "has default plugins in vagrantfile" do
249
+ it "has default plugins in .vagrantplugins" do
250
250
  subject.execute
251
251
  # Since the plugin stuff isn't part of the actual Vagrantfile spec, we'll
252
252
  # just peek at the text of the file
253
- vagrantfile = File.readlines(File.join(iso_env.cwd, "Vagrantfile")).join
254
- expect(vagrantfile).to include("required_plugins = %w( #{described_class::DEFAULT_PLUGINS.join(' ')} )")
253
+ pluginsfile = File.readlines(File.join(iso_env.cwd, ".vagrantplugins")).join
254
+ described_class::DEFAULT_PLUGINS.each do |plugin|
255
+ expect(pluginsfile).to include("required_plugins[\"#{plugin}\"]")
256
+ end
255
257
  end
256
258
  end
257
259
 
@@ -259,9 +261,9 @@ describe VagrantPlugins::Orchestrate::Command::Init do
259
261
  let(:argv) { ["--plugins", "plugin1,plugin2"] }
260
262
  it "are required" do
261
263
  subject.execute
262
- expected = "required_plugins = %w( #{described_class::DEFAULT_PLUGINS.join(' ')} plugin1 plugin2 )"
263
- vagrantfile = File.readlines(File.join(iso_env.cwd, "Vagrantfile")).join
264
- expect(vagrantfile).to include(expected)
264
+ pluginsfile = File.readlines(File.join(iso_env.cwd, ".vagrantplugins")).join
265
+ expect(pluginsfile).to include("required_plugins[\"plugin1\"]")
266
+ expect(pluginsfile).to include("required_plugins[\"plugin2\"]")
265
267
  end
266
268
  end
267
269
  end
@@ -0,0 +1,23 @@
1
+ required_plugins = {}
2
+ # Example usage:
3
+ # required_plugins["plugin-name"] = { version: "1.2.3", source: "https://rubygems.org" }
4
+ <% plugins.each do |p| -%>
5
+ required_plugins["<%= p %>"] = {}
6
+ <% end -%>
7
+
8
+ needs_restart = false
9
+ required_plugins.each do |plugin, options|
10
+ version = options[:version]
11
+
12
+ unless Vagrant.has_plugin?(plugin, version)
13
+ command = "vagrant plugin install #{plugin}"
14
+ command += " --plugin-version #{version}" if version
15
+ command += " --plugin-source #{options[:source]}" if options[:source]
16
+ system command
17
+ needs_restart = true
18
+ end
19
+ end
20
+
21
+ if needs_restart
22
+ exec "vagrant #{ARGV.join' '}"
23
+ end
@@ -4,12 +4,6 @@ managed_servers = VagrantPlugins::Orchestrate::Plugin.load_servers_for_branch
4
4
  managed_servers = %w( <% servers.each do |s| -%><%= s %> <% end -%>)
5
5
  <% end -%>
6
6
 
7
- <% if plugins.any? -%>
8
- required_plugins = %w( <% plugins.each do |p| -%><%= p %> <% end -%>)
9
- required_plugins.each do |plugin|
10
- system "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
11
- end
12
- <% end %>
13
7
  Vagrant.configure("2") do |config|
14
8
  # This disables up, provision, reload, and destroy for managed servers. Use
15
9
  # `vagrant orchestrate push` to communicate with managed servers.
@@ -1,26 +1,26 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'vagrant-orchestrate/version'
4
+ require "vagrant-orchestrate/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'vagrant-orchestrate'
7
+ spec.name = "vagrant-orchestrate"
8
8
  spec.version = VagrantPlugins::Orchestrate::VERSION
9
- spec.authors = ['Christopher Baldauf']
10
- spec.email = ['cbaldauf@cimpress.com']
11
- spec.summary = 'Vagrant plugin to orchestrate the deployment of managed servers.'
12
- spec.homepage = 'https://github.com/Cimpress-MCP/vagrant-orchestrate'
13
- spec.license = 'Apache 2.0'
9
+ spec.authors = ["Christopher Baldauf"]
10
+ spec.email = ["cbaldauf@cimpress.com"]
11
+ spec.summary = "Vagrant plugin to orchestrate the deployment of managed servers."
12
+ spec.homepage = "https://github.com/Cimpress-MCP/vagrant-orchestrate"
13
+ spec.license = "Apache 2.0"
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ['lib']
18
+ spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency 'bundler', '~> 1.6'
21
- spec.add_development_dependency 'rake', '~> 10.0'
22
- spec.add_development_dependency 'rspec'
23
- spec.add_development_dependency 'rubocop', '~> 0.28'
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "rubocop", "~> 0.28"
24
24
  # See Gemfile for additional development dependencies that were not available
25
25
  # on rubygems (or another gem source), but needed to be downloaded from git.
26
26
  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.6.2
4
+ version: 0.6.3
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-25 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,6 +77,7 @@ files:
77
77
  - .rspec
78
78
  - .rubocop.yml
79
79
  - .travis.yml
80
+ - .vagrantplugins
80
81
  - CHANGELOG.md
81
82
  - Gemfile
82
83
  - LICENSE
@@ -112,9 +113,7 @@ files:
112
113
  - lib/vagrant-orchestrate/plugin.rb
113
114
  - lib/vagrant-orchestrate/repo_status.rb
114
115
  - lib/vagrant-orchestrate/version.rb
115
- - lib/vms.save
116
116
  - locales/en.yml
117
- - mytestfile
118
117
  - spec/spec_helper.rb
119
118
  - spec/vagrant-orchestrate/command/init_spec.rb
120
119
  - spec/vagrant-orchestrate/command/root_spec.rb
@@ -122,6 +121,7 @@ files:
122
121
  - templates/puppet/Puppetfile.erb
123
122
  - templates/puppet/hiera.yaml.erb
124
123
  - templates/puppet/hiera/common.yaml.erb
124
+ - templates/vagrant/.vagrantplugins.erb
125
125
  - templates/vagrant/Vagrantfile.erb
126
126
  - templates/vagrant/dummy.box
127
127
  - vagrant-orchestrate.gemspec
data/lib/vms.save DELETED
@@ -1,24 +0,0 @@
1
- # R&D work that may be used in a future version, but can be ignored for now.
2
- module ManagedServers
3
- module Action
4
- include Vagrant::Action::Builtin
5
- def self.action_push
6
- Vagrant::Action::Builder.new.tap do |b|
7
- b.use HandleBox
8
- b.use ConfigValidate
9
- b.use WarnNetworks
10
- b.use Call, IsLinked do |env, b2|
11
- if env[:result]
12
- b2.use MessageAlreadyLinked
13
- next
14
- end
15
-
16
- b2.use LinkServer
17
- end
18
- b.use Provision
19
- b.use SyncFolders
20
- b.use UnlinkServer
21
- end
22
- end
23
- end
24
- end
data/mytestfile DELETED
File without changes