vagrant-aws-winrm 0.0.3 → 0.0.4

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: fc3c8fbde2eadf199a443ec57748fdcff1c7410c
4
- data.tar.gz: 29178f62a5540a986cdc659be66d4f709c8292ec
3
+ metadata.gz: 94129784b1207e77f8953f782490d451e1d386ca
4
+ data.tar.gz: a3a947928d0df2b3d92601e2254026313b783133
5
5
  SHA512:
6
- metadata.gz: 3a883f3681fab1017803411e0eee55faffb582d959f6e617d3cf6fae4efd9398e4061c87f60f023fd9d9ed57aa2ce25883efed8eb075c106655b696e8e999843
7
- data.tar.gz: 46bc8c5828c0807df2ca076ebd5a9152d3aaf5b08e10b9cae2ddf60f4c908a414a4449050db3a34f415f2ab07e61375786358f7f91d77cdd277c006a1c71f78e
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 self.winrm_info(machine)
9
- logger = Log4r::Logger.new("vagrant_aws_winrm::capability::winrm_info")
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
- # AWS connection info
15
- access_key_id = machine.provider_config.access_key_id
16
- secret_access_key = machine.provider_config.secret_access_key
17
- session_token = machine.provider_config.session_token
18
- credentials = ::Aws::Credentials.new(access_key_id, secret_access_key, session_token)
19
- region = machine.provider_config.region
20
- region_config = machine.provider_config.get_region_config(region)
21
- endpoint = region_config.endpoint
22
-
23
- options = {
24
- region: region,
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
@@ -1,7 +1,7 @@
1
1
  module VagrantPlugins
2
2
  module AWS
3
3
  module WinRM
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
6
6
  end
7
7
  end
@@ -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-sdk", "~> 2"
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.3
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-18 00:00:00.000000000 Z
11
+ date: 2015-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: aws-sdk
14
+ name: vagrant-aws
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2'
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: '2'
26
+ version: 0.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement