vagrant-aws-winrm 0.0.3 → 0.0.4
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 +4 -4
- data/lib/vagrant-aws-winrm/capability.rb +44 -47
- data/lib/vagrant-aws-winrm/version.rb +1 -1
- data/vagrant-aws-winrm.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94129784b1207e77f8953f782490d451e1d386ca
|
4
|
+
data.tar.gz: a3a947928d0df2b3d92601e2254026313b783133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e4d447b79d254df19429bd12a39922224e7944e39c8b1f7d5c51e8423959abb6d5ae15545be5b99aacd154d58f1c82bde45fb621ce83433ec67a6a508989bc6
|
7
|
+
data.tar.gz: d74d04b3ddc683c17c45da68a6fd87fed4afa5e736d0db1bc2d0ff012c8278c038315bc799c9fbf9df4aa6adbb5bf15569a106761660700398075d1a3fa22e38
|
@@ -1,63 +1,60 @@
|
|
1
|
+
require "vagrant-aws"
|
1
2
|
require "log4r"
|
2
|
-
require "aws-sdk"
|
3
3
|
|
4
4
|
module VagrantPlugins
|
5
5
|
module AWS
|
6
6
|
module WinRM
|
7
7
|
class Capability
|
8
|
-
def
|
9
|
-
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
@logger = Log4r::Logger.new("vagrant_aws_winrm::capability::winrm_info")
|
11
|
+
end
|
10
12
|
|
13
|
+
def self.winrm_info(machine)
|
11
14
|
if machine.config.winrm.password == :aws
|
12
15
|
machine.ui.info('Getting WinRM password from AWS...')
|
13
16
|
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
credentials: credentials
|
26
|
-
}
|
27
|
-
|
28
|
-
# Account for custom endpoints (e.g. OpenStack)
|
29
|
-
options[:endpoint] = endpoint if endpoint
|
30
|
-
|
31
|
-
logger.info("Getting password data from AWS...")
|
32
|
-
logger.info(" -- Region: #{region}")
|
33
|
-
logger.info(" -- Endpoint: #{endpoint}") if endpoint
|
34
|
-
logger.info(" -- Instance ID: #{machine.id}")
|
35
|
-
|
36
|
-
ec2 = Aws::EC2::Client.new(options)
|
37
|
-
password_data = ec2.get_password_data({ instance_id: machine.id }).password_data
|
38
|
-
password_data_bytes = Base64.decode64(password_data)
|
39
|
-
|
40
|
-
# Try to decrypt the password data using each one of the private key files
|
41
|
-
# set by the user until we hit one that decrypts successfully
|
42
|
-
machine.config.ssh.private_key_path.each do |private_key_path|
|
43
|
-
private_key_path = File.expand_path private_key_path
|
44
|
-
|
45
|
-
logger.info("Decrypting password data using #{private_key_path}")
|
46
|
-
rsa = OpenSSL::PKey::RSA.new File.read private_key_path
|
47
|
-
begin
|
48
|
-
machine.config.winrm.password = rsa.private_decrypt password_data_bytes
|
49
|
-
logger.info("Successfully decrypted password data using #{private_key_path}")
|
50
|
-
rescue OpenSSL::PKey::RSAError
|
51
|
-
logger.warn("Failed to decrypt password data using #{private_key_path}")
|
52
|
-
next
|
53
|
-
end
|
54
|
-
|
55
|
-
break
|
56
|
-
end
|
17
|
+
# Call the VagrantPlugins::AWS::Action::ConnectAWS
|
18
|
+
# middleware so we can get acces to the Fog connection
|
19
|
+
machine.env.action_runner.run(
|
20
|
+
Vagrant::Action::Builder.new.tap do |b|
|
21
|
+
b.use VagrantPlugins::AWS::Action::ConnectAWS
|
22
|
+
b.use self
|
23
|
+
end, {
|
24
|
+
machine: machine,
|
25
|
+
ui: machine.ui,
|
26
|
+
}
|
27
|
+
)
|
57
28
|
end
|
58
|
-
|
59
29
|
return {}
|
60
30
|
end
|
31
|
+
|
32
|
+
def call(env)
|
33
|
+
machine = env[:machine]
|
34
|
+
aws = env[:aws_compute]
|
35
|
+
|
36
|
+
response = aws.get_password_data({ instance_id: machine.id })
|
37
|
+
password_data = response.body['passwordData']
|
38
|
+
password_data_bytes = Base64.decode64(password_data)
|
39
|
+
|
40
|
+
# Try to decrypt the password data using each one of the private key files
|
41
|
+
# set by the user until we hit one that decrypts successfully
|
42
|
+
machine.config.ssh.private_key_path.each do |private_key_path|
|
43
|
+
private_key_path = File.expand_path private_key_path
|
44
|
+
|
45
|
+
@logger.info("Decrypting password data using #{private_key_path}")
|
46
|
+
rsa = OpenSSL::PKey::RSA.new File.read private_key_path
|
47
|
+
begin
|
48
|
+
machine.config.winrm.password = rsa.private_decrypt password_data_bytes
|
49
|
+
@logger.info("Successfully decrypted password data using #{private_key_path}")
|
50
|
+
rescue OpenSSL::PKey::RSAError
|
51
|
+
@logger.warn("Failed to decrypt password data using #{private_key_path}")
|
52
|
+
next
|
53
|
+
end
|
54
|
+
|
55
|
+
break
|
56
|
+
end
|
57
|
+
end
|
61
58
|
end
|
62
59
|
end
|
63
60
|
end
|
data/vagrant-aws-winrm.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "aws
|
21
|
+
spec.add_dependency "vagrant-aws", "~> 0.6.0"
|
22
22
|
|
23
23
|
#spec.add_development_dependency "bundler", "~> 1.7"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-aws-winrm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Goodman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: aws
|
14
|
+
name: vagrant-aws
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.6.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: 0.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|