vagrant-butcher 2.1.2 → 2.1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 179d7410197d7530eec83448494a0b51944d3b16
|
4
|
+
data.tar.gz: 9807b4d078972eacf729e064651e3056e4b9b940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2319cc363933b06ef5bb69529b4c0fcfca61a8523a1256357a49f0d0467ff6082c84708bc813260425c1a59f88d245491f59b7cd31ded7a29b8ea7471224d39
|
7
|
+
data.tar.gz: 76f86e961f9e835d0572e837494f75067b46c84d720a06b1b129de09cd601a025887fbf7a7e44ca3a89c31f5fff3900aedc25527ef0f0569a1fb42de0f27dce9
|
@@ -3,7 +3,7 @@ module Vagrant
|
|
3
3
|
class Config < ::Vagrant.plugin('2', :config)
|
4
4
|
attr_accessor :enabled
|
5
5
|
attr_accessor :guest_key_path
|
6
|
-
|
6
|
+
attr_reader :cache_dir
|
7
7
|
attr_accessor :verify_ssl
|
8
8
|
attr_accessor :retries
|
9
9
|
attr_accessor :retry_interval
|
@@ -15,7 +15,7 @@ module Vagrant
|
|
15
15
|
super
|
16
16
|
@enabled = UNSET_VALUE
|
17
17
|
@guest_key_path = UNSET_VALUE
|
18
|
-
@cache_dir =
|
18
|
+
@cache_dir = ".vagrant/butcher"
|
19
19
|
@verify_ssl = UNSET_VALUE
|
20
20
|
@retries = UNSET_VALUE
|
21
21
|
@retry_interval = UNSET_VALUE
|
@@ -24,14 +24,9 @@ module Vagrant
|
|
24
24
|
@client_key = UNSET_VALUE
|
25
25
|
end
|
26
26
|
|
27
|
-
def cache_dir=(value)
|
28
|
-
@cache_dir = File.expand_path(value)
|
29
|
-
end
|
30
|
-
|
31
27
|
def finalize!
|
32
28
|
@enabled = true if @enabled == UNSET_VALUE
|
33
29
|
@guest_key_path = '/etc/chef/client.pem' if @guest_key_path == UNSET_VALUE
|
34
|
-
@cache_dir = File.expand_path ".vagrant/butcher" if @cache_dir == UNSET_VALUE
|
35
30
|
@verify_ssl = true if @verify_ssl == UNSET_VALUE
|
36
31
|
@retries = 0 if @retries == UNSET_VALUE
|
37
32
|
@retry_interval = 0 if @retry_interval == UNSET_VALUE
|
@@ -10,26 +10,23 @@ module Vagrant
|
|
10
10
|
include ::Vagrant::Butcher::Helpers::KeyFiles
|
11
11
|
|
12
12
|
def setup_connection(env)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
ui(env).error "Could not connect to Chef Server: #{e}"
|
30
|
-
end
|
13
|
+
begin
|
14
|
+
@conn = ::Ridley.new(
|
15
|
+
server_url: chef_provisioner(env).chef_server_url,
|
16
|
+
client_name: client_name(env),
|
17
|
+
client_key: client_key_path(env),
|
18
|
+
ssl: {
|
19
|
+
verify: butcher_config(env).verify_ssl
|
20
|
+
},
|
21
|
+
retries: butcher_config(env).retries,
|
22
|
+
retry_interval: butcher_config(env).retry_interval,
|
23
|
+
proxy: butcher_config(env).proxy
|
24
|
+
)
|
25
|
+
rescue Ridley::Errors::ClientKeyFileNotFoundOrInvalid
|
26
|
+
ui(env).error "Chef client key not found at #{client_key_path(env)}"
|
27
|
+
rescue Exception => e
|
28
|
+
ui(env).error "Could not connect to Chef Server: #{e}"
|
31
29
|
end
|
32
|
-
@conn
|
33
30
|
end
|
34
31
|
|
35
32
|
def delete_resource(resource, env)
|
@@ -6,53 +6,19 @@ module Vagrant
|
|
6
6
|
module KeyFiles
|
7
7
|
|
8
8
|
def cache_dir(env)
|
9
|
-
@cache_dir ||= butcher_config(env).cache_dir
|
10
|
-
end
|
11
|
-
|
12
|
-
def cache_dir_mapping(env)
|
13
|
-
unless @cache_dir_mapping
|
14
|
-
# Grab all enabled synced_folders
|
15
|
-
synced_folders = vm_config(env).synced_folders.values.find_all { |f| !f[:disabled] }
|
16
|
-
|
17
|
-
# Expand the hostpath of each folder
|
18
|
-
synced_folders.each { |f| f[:hostpath] = File.expand_path(f[:hostpath]) }
|
19
|
-
|
20
|
-
# Select the folder wherein the cache_dir is contained
|
21
|
-
cache_dir_mappings = synced_folders.select { |f| cache_dir(env) =~ /^#{f[:hostpath]}/ }
|
22
|
-
@cache_dir_mapping = cache_dir_mappings.first if cache_dir_mappings.any?
|
23
|
-
end
|
24
|
-
@cache_dir_mapping
|
25
|
-
end
|
26
|
-
|
27
|
-
def guest_cache_dir(env)
|
28
|
-
unless @guest_cache_dir
|
29
|
-
if cache_dir_mapping(env)
|
30
|
-
# Return the path to the cache dir inside the VM
|
31
|
-
@guest_cache_dir = cache_dir(env).gsub(cache_dir_mapping(env)[:hostpath], cache_dir_mapping(env)[:guestpath])
|
32
|
-
ui(env).info "Guest cache dir at #{@guest_cache_dir}"
|
33
|
-
else
|
34
|
-
ui(env).error "We couldn't find a synced folder to access the cache dir on the guest."
|
35
|
-
ui(env).error "Did you disable the /vagrant folder or set a butcher.cache_path that isn't shared with the guest?"
|
36
|
-
raise ::Vagrant::Butcher::Errors::NoSyncedFolder
|
37
|
-
end
|
38
|
-
end
|
39
|
-
@guest_cache_dir
|
9
|
+
@cache_dir ||= File.expand_path(File.join(root_path(env), butcher_config(env).cache_dir))
|
40
10
|
end
|
41
11
|
|
42
12
|
def guest_key_path(env)
|
43
13
|
@guest_key_path ||= butcher_config(env).guest_key_path
|
44
14
|
end
|
45
15
|
|
46
|
-
def
|
47
|
-
@
|
48
|
-
end
|
49
|
-
|
50
|
-
def guest_cache_key_path(env)
|
51
|
-
@guest_cache_key_path ||= "#{guest_cache_dir(env)}/#{guest_key_filename(env)}"
|
16
|
+
def key_filename(env)
|
17
|
+
@key_filename ||= "#{env[:machine].name}-client.pem"
|
52
18
|
end
|
53
19
|
|
54
|
-
def
|
55
|
-
@
|
20
|
+
def client_key_path(env)
|
21
|
+
@client_key_path ||= butcher_config(env).client_key || "#{cache_dir(env)}/#{key_filename(env)}"
|
56
22
|
end
|
57
23
|
|
58
24
|
def create_cache_dir(env)
|
@@ -62,35 +28,31 @@ module Vagrant
|
|
62
28
|
end
|
63
29
|
end
|
64
30
|
|
65
|
-
def
|
31
|
+
def grab_key_from_guest(env)
|
66
32
|
create_cache_dir(env)
|
67
33
|
|
68
|
-
|
69
|
-
|
70
|
-
ui(env).info "Copied #{guest_key_path(env)} to #{guest_cache_key_path(env)}"
|
71
|
-
rescue Exception => e
|
72
|
-
ui(env).error "Failed to copy #{guest_key_path(env)} to #{guest_cache_key_path(env)}"
|
73
|
-
ui(env).error e
|
74
|
-
raise ::Vagrant::Butcher::Errors::KeyCopyFailure
|
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
|
75
36
|
end
|
37
|
+
|
38
|
+
ui(env).info "Saved client key to #{cache_dir(env)}/#{key_filename(env)}"
|
76
39
|
end
|
77
40
|
|
78
41
|
def cleanup_cache_dir(env)
|
79
42
|
unless @failed_deletions
|
80
|
-
key_file = "#{cache_dir(env)}/#{
|
43
|
+
key_file = "#{cache_dir(env)}/#{key_filename(env)}"
|
81
44
|
File.delete(key_file) if File.exists?(key_file)
|
82
45
|
Dir.delete(cache_dir(env)) if (Dir.entries(cache_dir(env)) - %w{ . .. }).empty?
|
83
46
|
else
|
84
|
-
ui(env).warn "#{@failed_deletions} not butchered from the Chef Server. Client key was left at #{
|
47
|
+
ui(env).warn "#{@failed_deletions} not butchered from the Chef Server. Client key was left at #{client_key_path(env)}"
|
85
48
|
end
|
86
49
|
end
|
87
50
|
|
88
51
|
def copy_guest_key(env)
|
89
52
|
begin
|
90
|
-
|
91
|
-
copy_key_file(env)
|
53
|
+
grab_key_from_guest(env)
|
92
54
|
rescue ::Vagrant::Errors::VagrantError => e
|
93
|
-
ui(env).error "Failed to
|
55
|
+
ui(env).error "Failed to create #{cache_dir(env)}/#{key_filename(env)}: #{e.class} - #{e}"
|
94
56
|
end
|
95
57
|
end
|
96
58
|
|
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.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cassiano Leal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ridley
|