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 +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +4 -0
- data/README.md +7 -0
- data/Vagrantfile +0 -2
- data/lib/vagrant-butcher.rb +0 -1
- data/lib/vagrant-butcher/action.rb +0 -8
- data/lib/vagrant-butcher/action/cleanup.rb +1 -1
- data/lib/vagrant-butcher/config.rb +3 -1
- data/lib/vagrant-butcher/helpers.rb +1 -0
- data/lib/vagrant-butcher/helpers/action.rb +0 -4
- data/lib/vagrant-butcher/helpers/connection.rb +4 -4
- data/lib/vagrant-butcher/helpers/guest.rb +19 -0
- data/lib/vagrant-butcher/helpers/key_files.rb +9 -9
- data/lib/vagrant-butcher/plugin.rb +1 -1
- data/lib/vagrant-butcher/version.rb +1 -1
- data/spec/unit/vagrant_butcher/config_spec.rb +1 -1
- data/vagrant-butcher.gemspec +1 -1
- metadata +6 -8
- data/lib/vagrant-butcher/env.rb +0 -19
- data/spec/unit/vagrant_butcher/env_spec.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4a8b11cb3abd8531f40c129ea3303511cca1d36
|
4
|
+
data.tar.gz: c59e91ee9e005b49d3fe20b185822bba24a49190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26aca93443026d75878dee07702e3007ab59a8a632ffe0cc43ada62e3eb90c9e2d92d608e26083bc2899dc0f566e1af58b5aa7924b4576e381fb258d365c4618
|
7
|
+
data.tar.gz: c57a78095136fa45fd6fa28b5c8b1e92bbdc9ea07baa5fd2b74da414c82799e1259652d680f07fb49657fd940b2f5ab390622392da2b6c8c2ffc51ae626336a9
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
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
data/lib/vagrant-butcher.rb
CHANGED
@@ -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
|
@@ -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 =
|
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
|
@@ -23,18 +23,18 @@ module Vagrant
|
|
23
23
|
proxy: butcher_config(env).proxy
|
24
24
|
)
|
25
25
|
rescue Ridley::Errors::ClientKeyFileNotFoundOrInvalid
|
26
|
-
ui
|
26
|
+
env[:ui].error "Chef client key not found at #{client_key_path(env)}"
|
27
27
|
rescue Exception => e
|
28
|
-
ui
|
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
|
35
|
+
env[:ui].success "Chef #{resource} '#{victim(env)}' successfully butchered from the server..."
|
36
36
|
rescue Exception => e
|
37
|
-
ui
|
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 ||=
|
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
|
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
|
-
|
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
|
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
|
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
|
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.
|
21
|
+
hook.prepend(Vagrant::Butcher::Action.cleanup)
|
22
22
|
end
|
23
23
|
|
24
24
|
config("butcher") do
|
@@ -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(
|
40
|
+
subject.guest_key_path.should eql(:DEFAULT)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "sets cache dir path" do
|
data/vagrant-butcher.gemspec
CHANGED
@@ -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", ">=
|
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.
|
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-
|
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:
|
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:
|
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.
|
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
|
data/lib/vagrant-butcher/env.rb
DELETED
@@ -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
|