vagrant-butcher 2.1.5 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3bcdc3aa88b5afc4dcc98716a69db4dce2a425d
4
- data.tar.gz: c14fcca2095d8f8a58e65fedaddc4f61c566bcb5
3
+ metadata.gz: f4a8b11cb3abd8531f40c129ea3303511cca1d36
4
+ data.tar.gz: c59e91ee9e005b49d3fe20b185822bba24a49190
5
5
  SHA512:
6
- metadata.gz: c472bb126b5787269ac34a6cf9c01f5283b5deb998a38fccf1b84171a8d43f5ed7af800b7774844e9e1e66d837495b6a52cd437eccb916260b444c37ba369e12
7
- data.tar.gz: 6de1168eefd9876c2b50f85454f0ee8883101612135a7096e6e5f2fca732207eecd5c6d4055a0b03bd338f434b75a9e43783080ca16b87bc726bcffd8c785885
6
+ metadata.gz: 26aca93443026d75878dee07702e3007ab59a8a632ffe0cc43ada62e3eb90c9e2d92d608e26083bc2899dc0f566e1af58b5aa7924b4576e381fb258d365c4618
7
+ data.tar.gz: c57a78095136fa45fd6fa28b5c8b1e92bbdc9ea07baa5fd2b74da414c82799e1259652d680f07fb49657fd940b2f5ab390622392da2b6c8c2ffc51ae626336a9
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
3
+ - 2.0.0
4
4
  script: bundle exec rspec spec/
data/Gemfile CHANGED
@@ -9,3 +9,7 @@ group :development do
9
9
  # Vagrant environment itself using `vagrant plugin`.
10
10
  gem "vagrant", :github => 'mitchellh/vagrant'
11
11
  end
12
+
13
+ group :plugins do
14
+ gem "vagrant-butcher", :path => "."
15
+ end
data/README.md CHANGED
@@ -48,6 +48,13 @@ Option | Default Value | Purpose
48
48
 
49
49
  ## Changelog
50
50
 
51
+ ### 2.2.0
52
+
53
+ * Removed compatibility with Vagrant < 1.5
54
+ * Fixes an issue with recent Vagrant versions where the butcher sequence would never run
55
+ * Sets default `guest_key_path` depending on OS
56
+ * Tested and confirmed working on Windows and Linux
57
+
51
58
  ### 2.0.0
52
59
 
53
60
  * No more option to point to `knife.rb`. Data is retrieved from the `Vagrantfile`'s `chef_client` provisioner
data/Vagrantfile CHANGED
@@ -4,8 +4,6 @@
4
4
  # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
5
  VAGRANTFILE_API_VERSION = "2"
6
6
 
7
- Vagrant.require_plugin "vagrant-butcher"
8
-
9
7
  orgname = ENV['CHEF_ORGNAME']
10
8
 
11
9
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@@ -10,7 +10,6 @@ module Vagrant
10
10
  module Butcher
11
11
  autoload :Action, 'vagrant-butcher/action'
12
12
  autoload :Config, 'vagrant-butcher/config'
13
- autoload :Env, 'vagrant-butcher/env'
14
13
  autoload :Helpers, 'vagrant-butcher/helpers'
15
14
  end
16
15
  end
@@ -6,23 +6,15 @@ module Vagrant
6
6
 
7
7
  def self.cleanup
8
8
  ::Vagrant::Action::Builder.new.tap do |b|
9
- b.use setup
10
9
  b.use Vagrant::Butcher::Action::Cleanup
11
10
  end
12
11
  end
13
12
 
14
13
  def self.copy_guest_key
15
14
  ::Vagrant::Action::Builder.new.tap do |b|
16
- b.use setup
17
15
  b.use Vagrant::Butcher::Action::CopyGuestKey
18
16
  end
19
17
  end
20
-
21
- def self.setup
22
- @setup ||= ::Vagrant::Action::Builder.new.tap do |b|
23
- b.use ::Vagrant::Action::Builtin::EnvSet, butcher: Vagrant::Butcher::Env.new
24
- end
25
- end
26
18
  end
27
19
  end
28
20
  end
@@ -13,7 +13,7 @@ module Vagrant
13
13
  if butcher_config(machine(env)).enabled
14
14
  cleanup(env)
15
15
  else
16
- ui(env).warn "Vagrant::Butcher disabled, not cleaning up Chef server!"
16
+ env[:ui].warn "Vagrant::Butcher disabled, not cleaning up Chef server!"
17
17
  end
18
18
 
19
19
  @app.call(env)
@@ -1,6 +1,8 @@
1
1
  module Vagrant
2
2
  module Butcher
3
3
  class Config < ::Vagrant.plugin('2', :config)
4
+ include Helpers::Guest
5
+
4
6
  attr_accessor :enabled
5
7
  attr_accessor :guest_key_path
6
8
  attr_reader :cache_dir
@@ -26,7 +28,7 @@ module Vagrant
26
28
 
27
29
  def finalize!
28
30
  @enabled = true if @enabled == UNSET_VALUE
29
- @guest_key_path = '/etc/chef/client.pem' if @guest_key_path == UNSET_VALUE
31
+ @guest_key_path = :DEFAULT if @guest_key_path == UNSET_VALUE
30
32
  @verify_ssl = true if @verify_ssl == UNSET_VALUE
31
33
  @retries = 0 if @retries == UNSET_VALUE
32
34
  @retry_interval = 0 if @retry_interval == UNSET_VALUE
@@ -5,6 +5,7 @@ module Vagrant
5
5
  autoload :Action, 'vagrant-butcher/helpers/action'
6
6
  autoload :KeyFiles, 'vagrant-butcher/helpers/key_files'
7
7
  autoload :Connection, 'vagrant-butcher/helpers/connection'
8
+ autoload :Guest, 'vagrant-butcher/helpers/guest'
8
9
  end
9
10
  end
10
11
  end
@@ -4,10 +4,6 @@ module Vagrant
4
4
  module Action
5
5
  include Config
6
6
 
7
- def ui(env)
8
- @ui ||= env[:butcher].ui
9
- end
10
-
11
7
  def machine(env)
12
8
  @machine ||= env[:machine]
13
9
  end
@@ -23,18 +23,18 @@ module Vagrant
23
23
  proxy: butcher_config(env).proxy
24
24
  )
25
25
  rescue Ridley::Errors::ClientKeyFileNotFoundOrInvalid
26
- ui(env).error "Chef client key not found at #{client_key_path(env)}"
26
+ env[:ui].error "Chef client key not found at #{client_key_path(env)}"
27
27
  rescue Exception => e
28
- ui(env).error "Could not connect to Chef Server: #{e}"
28
+ env[:ui].error "Could not connect to Chef Server: #{e}"
29
29
  end
30
30
  end
31
31
 
32
32
  def delete_resource(resource, env)
33
33
  begin
34
34
  @conn.send(resource.to_sym).delete(victim(env))
35
- ui(env).success "Chef #{resource} '#{victim(env)}' successfully butchered from the server..."
35
+ env[:ui].success "Chef #{resource} '#{victim(env)}' successfully butchered from the server..."
36
36
  rescue Exception => e
37
- ui(env).warn "Could not butcher #{resource} #{victim(env)}: #{e.message}"
37
+ env[:ui].warn "Could not butcher #{resource} #{victim(env)}: #{e.message}"
38
38
  @failed_deletions ||= []
39
39
  @failed_deletions << resource
40
40
  end
@@ -0,0 +1,19 @@
1
+ module Vagrant
2
+ module Butcher
3
+ module Helpers
4
+ module Guest
5
+
6
+ def windows?(env)
7
+ machine(env).guest.capability_host_chain.last.first == :windows
8
+ end
9
+
10
+ def get_guest_key_path(env)
11
+ return butcher_config(env).guest_key_path unless butcher_config(env).guest_key_path == :DEFAULT
12
+ return 'c:\etc\chef\client.pem' if windows?(env)
13
+ return '/etc/chef/client.pem'
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -4,13 +4,14 @@ module Vagrant
4
4
  module Butcher
5
5
  module Helpers
6
6
  module KeyFiles
7
+ include ::Vagrant::Butcher::Helpers::Guest
7
8
 
8
9
  def cache_dir(env)
9
10
  @cache_dir ||= File.expand_path(File.join(root_path(env), butcher_config(env).cache_dir))
10
11
  end
11
12
 
12
13
  def guest_key_path(env)
13
- @guest_key_path ||= butcher_config(env).guest_key_path
14
+ @guest_key_path ||= get_guest_key_path(env)
14
15
  end
15
16
 
16
17
  def key_filename(env)
@@ -23,19 +24,18 @@ module Vagrant
23
24
 
24
25
  def create_cache_dir(env)
25
26
  unless File.exists?(cache_dir(env))
26
- ui(env).info "Creating #{cache_dir(env)}"
27
+ env[:ui].info "Creating #{cache_dir(env)} ..."
27
28
  FileUtils.mkdir_p(cache_dir(env))
28
29
  end
29
30
  end
30
31
 
31
32
  def grab_key_from_guest(env)
32
33
  create_cache_dir(env)
33
-
34
- machine(env).communicate.execute("cat #{guest_key_path(env)}", sudo: true) do |type,data|
35
- File.open("#{cache_dir(env)}/#{key_filename(env)}", "w") { |f| f << data } if type == :stdout
34
+ unless windows?(env)
35
+ machine(env).communicate.execute "chmod 0644 #{guest_key_path(env)}", :sudo => true
36
36
  end
37
-
38
- ui(env).info "Saved client key to #{cache_dir(env)}/#{key_filename(env)}"
37
+ machine(env).communicate.download(guest_key_path(env), "#{cache_dir(env)}/#{key_filename(env)}")
38
+ env[:ui].info "Saved client key to #{cache_dir(env)}/#{key_filename(env)}"
39
39
  end
40
40
 
41
41
  def cleanup_cache_dir(env)
@@ -44,7 +44,7 @@ module Vagrant
44
44
  File.delete(key_file) if File.exists?(key_file)
45
45
  Dir.delete(cache_dir(env)) if (Dir.entries(cache_dir(env)) - %w{ . .. }).empty?
46
46
  else
47
- ui(env).warn "#{@failed_deletions} not butchered from the Chef Server. Client key was left at #{client_key_path(env)}"
47
+ env[:ui].warn "#{@failed_deletions} not butchered from the Chef Server. Client key was left at #{client_key_path(env)}"
48
48
  end
49
49
  end
50
50
 
@@ -52,7 +52,7 @@ module Vagrant
52
52
  begin
53
53
  grab_key_from_guest(env)
54
54
  rescue ::Vagrant::Errors::VagrantError => e
55
- ui(env).error "Failed to create #{cache_dir(env)}/#{key_filename(env)}: #{e.class} - #{e}"
55
+ env[:ui].error "Failed to create #{cache_dir(env)}/#{key_filename(env)}: #{e.class} - #{e}"
56
56
  end
57
57
  end
58
58
 
@@ -18,7 +18,7 @@ module Vagrant
18
18
  action_hook(:vagrant_butcher_copy_guest_key, :machine_action_provision, &method(:provision))
19
19
 
20
20
  action_hook(:vagrant_butcher_cleanup, :machine_action_destroy) do |hook|
21
- hook.after(::Vagrant::Action::Builtin::ConfigValidate, Vagrant::Butcher::Action.cleanup)
21
+ hook.prepend(Vagrant::Butcher::Action.cleanup)
22
22
  end
23
23
 
24
24
  config("butcher") do
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Butcher
3
- VERSION = "2.1.5"
3
+ VERSION = "2.2.0"
4
4
  end
5
5
  end
@@ -37,7 +37,7 @@ describe Vagrant::Butcher::Config do
37
37
 
38
38
  it "sets guest chef client pem default path" do
39
39
  subject.finalize!
40
- subject.guest_key_path.should eql('/etc/chef/client.pem')
40
+ subject.guest_key_path.should eql(:DEFAULT)
41
41
  end
42
42
 
43
43
  it "sets cache dir path" do
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency "ridley", ">= 1.5.3"
21
+ gem.add_dependency "ridley", ">= 4.0.0"
22
22
 
23
23
  gem.add_development_dependency "rspec"
24
24
  gem.add_development_dependency "pry-debugger"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-butcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cassiano Leal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ridley
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.3
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.5.3
26
+ version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -85,18 +85,17 @@ files:
85
85
  - lib/vagrant-butcher/action/cleanup.rb
86
86
  - lib/vagrant-butcher/action/copy_guest_key.rb
87
87
  - lib/vagrant-butcher/config.rb
88
- - lib/vagrant-butcher/env.rb
89
88
  - lib/vagrant-butcher/errors.rb
90
89
  - lib/vagrant-butcher/helpers.rb
91
90
  - lib/vagrant-butcher/helpers/action.rb
92
91
  - lib/vagrant-butcher/helpers/config.rb
93
92
  - lib/vagrant-butcher/helpers/connection.rb
93
+ - lib/vagrant-butcher/helpers/guest.rb
94
94
  - lib/vagrant-butcher/helpers/key_files.rb
95
95
  - lib/vagrant-butcher/plugin.rb
96
96
  - lib/vagrant-butcher/version.rb
97
97
  - spec/spec_helper.rb
98
98
  - spec/unit/vagrant_butcher/config_spec.rb
99
- - spec/unit/vagrant_butcher/env_spec.rb
100
99
  - spec/unit/vagrant_butcher_spec.rb
101
100
  - vagrant-butcher.gemspec
102
101
  homepage: https://github.com/cassianoleal/vagrant-butcher
@@ -119,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
118
  version: '0'
120
119
  requirements: []
121
120
  rubyforge_project:
122
- rubygems_version: 2.0.3
121
+ rubygems_version: 2.2.2
123
122
  signing_key:
124
123
  specification_version: 4
125
124
  summary: When a Vagrant VM that was spun up using Chef-Client is destroyed, it leaves
@@ -128,5 +127,4 @@ summary: When a Vagrant VM that was spun up using Chef-Client is destroyed, it l
128
127
  test_files:
129
128
  - spec/spec_helper.rb
130
129
  - spec/unit/vagrant_butcher/config_spec.rb
131
- - spec/unit/vagrant_butcher/env_spec.rb
132
130
  - spec/unit/vagrant_butcher_spec.rb
@@ -1,19 +0,0 @@
1
- module Vagrant
2
- module Butcher
3
- class Env
4
- attr_accessor :ui
5
-
6
- def initialize
7
- vagrant_version = Gem::Version.new(::Vagrant::VERSION)
8
- if vagrant_version >= Gem::Version.new("1.5")
9
- @ui = ::Vagrant::UI::Colored.new
10
- @ui.opts[:target] = 'Butcher'
11
- elsif vagrant_version >= Gem::Version.new("1.2")
12
- @ui = ::Vagrant::UI::Colored.new.scope('Butcher')
13
- else
14
- @ui = ::Vagrant::UI::Colored.new('Butcher')
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe Vagrant::Butcher::Env do
4
- subject { described_class.new }
5
-
6
- it "is a valid Vagrant UI object" do
7
- subject.ui.should be_a Vagrant::UI::BasicScope
8
- end
9
- end