vagrant-aws-winrm 0.0.1 → 0.0.2

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: 1333301219911be80fe150eebc58ca9322c6eb98
4
- data.tar.gz: 15e69ee3a48636152fe998cd6631feb1cca7c442
3
+ metadata.gz: 733d38beabc57d94aa97a155faea425928836425
4
+ data.tar.gz: aca4b5492132e3559d6d5f5c7a3fb74804bcc656
5
5
  SHA512:
6
- metadata.gz: 82ad45a7ce8d39adc9dfb780f4ab5e2e1a63f4e0285ec245232a43b160923e61683983fec085a7c0eadeac74487565eb7b360f7c6c999b8460a69c0af8b60878
7
- data.tar.gz: 810b035b50e197d7c7cd248d110a9070bcbfe592922d6e18040c021b280651d7f129911465ec6a3c9ffdb762b8819e8102f9184cbfa819017f4521ca154a55a2
6
+ metadata.gz: 59dc92c07945d9c14600b0ce05b37493f5a332368cef0968a171c93d724176b29ca3274a7cd80b59a8f8c92094e2cd18abdc793e89a96dd56e6cbcd4ff156f58
7
+ data.tar.gz: 8c972189f60eec62f95ef1dd81b4802f6047d78f7efa2c83d35ef56ba865cfddd7c07f84f68575dacb468d6ad725c905cd17eadbf2fe691b5bbc36b7075b4e87
@@ -1,3 +1,4 @@
1
+ require "log4r"
1
2
  require "aws-sdk"
2
3
 
3
4
  module VagrantPlugins
@@ -5,33 +6,48 @@ module VagrantPlugins
5
6
  module WinRM
6
7
  class Capability
7
8
  def self.winrm_info(machine)
9
+ logger = Log4r::Logger.new("vagrant_aws_winrm::capability::winrm_info")
10
+
8
11
  if machine.config.winrm.password == :aws
9
- machine.ui.info('Getting WinRM password from AWS')
12
+ machine.ui.info('Getting WinRM password from AWS...')
10
13
 
11
14
  # AWS connection info
12
15
  access_key_id = machine.provider_config.access_key_id
13
16
  secret_access_key = machine.provider_config.secret_access_key
14
17
  credentials = ::Aws::Credentials.new(access_key_id, secret_access_key)
15
18
  region = machine.provider_config.region
19
+ region_config = machine.provider_config.get_region_config(region)
20
+ endpoint = region_config.endpoint
21
+
22
+ options = {
23
+ region: region,
24
+ credentials: credentials
25
+ }
26
+
27
+ # Account for custom endpoints (e.g. OpenStack)
28
+ options[:endpoint] = endpoint if endpoint
16
29
 
17
- # Grab the region endpoint explicitly in the event that
18
- # a custom endpoint was specified (e.g. OpenStack)
19
- region_config = machine.provider_config.get_region_config(region)
20
- endpoint = region_config.endpoint
30
+ logger.info("Getting password data from AWS...")
31
+ logger.info(" -- Region: #{region}")
32
+ logger.info(" -- Endpoint: #{endpoint}") if endpoint
33
+ logger.info(" -- Instance ID: #{machine.id}")
21
34
 
22
- # Fetch that password data for the instance
23
- ec2 = Aws::EC2::Client.new(region: region, endpoint: endpoint, credentials: credentials)
35
+ ec2 = Aws::EC2::Client.new(options)
24
36
  password_data = ec2.get_password_data({ instance_id: machine.id }).password_data
25
37
  password_data_bytes = Base64.decode64(password_data)
26
38
 
27
39
  # Try to decrypt the password data using each one of the private key files
28
40
  # set by the user until we hit one that decrypts successfully
29
41
  machine.config.ssh.private_key_path.each do |private_key_path|
30
- rsa = OpenSSL::PKey::RSA.new File.read(File.expand_path private_key_path)
42
+ private_key_path = File.expand_path private_key_path
31
43
 
44
+ logger.info("Decrypting password data using #{private_key_path}")
45
+ rsa = OpenSSL::PKey::RSA.new File.read private_key_path
32
46
  begin
33
47
  machine.config.winrm.password = rsa.private_decrypt password_data_bytes
48
+ logger.info("Successfully decrypted password data using #{private_key_path}")
34
49
  rescue OpenSSL::PKey::RSAError
50
+ logger.warn("Failed to decrypt password data using #{private_key_path}")
35
51
  next
36
52
  end
37
53
 
@@ -14,9 +14,39 @@ module VagrantPlugins
14
14
  DESC
15
15
 
16
16
  provider_capability(:aws, :winrm_info) do
17
+ setup_logging
18
+
17
19
  require_relative 'capability'
18
20
  VagrantPlugins::AWS::WinRM::Capability
19
21
  end
22
+
23
+ def self.setup_logging
24
+ require "log4r"
25
+
26
+ level = nil
27
+ begin
28
+ level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
29
+ rescue NameError
30
+ # This means that the logging constant wasn't found,
31
+ # which is fine. We just keep `level` as `nil`. But
32
+ # we tell the user.
33
+ level = nil
34
+ end
35
+
36
+ # Some constants, such as "true" resolve to booleans, so the
37
+ # above error checking doesn't catch it. This will check to make
38
+ # sure that the log level is an integer, as Log4r requires.
39
+ level = nil if !level.is_a?(Integer)
40
+
41
+ # Set the logging level on all "vagrant" namespaced
42
+ # logs as long as we have a valid level.
43
+ if level
44
+ logger = Log4r::Logger.new("vagrant_aws_winrm")
45
+ logger.outputters = Log4r::Outputter.stderr
46
+ logger.level = level
47
+ logger = nil
48
+ end
49
+ end
20
50
  end
21
51
  end
22
52
  end
@@ -1,7 +1,7 @@
1
1
  module VagrantPlugins
2
2
  module AWS
3
3
  module WinRM
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-aws-winrm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-11-11 00:00:00.000000000 Z
11
+ date: 2015-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2'
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
26
  version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  description: Facilitates using the AWS-EC2-provided Administrator password as the
@@ -46,7 +46,7 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - ".gitignore"
49
+ - .gitignore
50
50
  - Gemfile
51
51
  - LICENSE.txt
52
52
  - README.md
@@ -66,12 +66,12 @@ require_paths:
66
66
  - lib
67
67
  required_ruby_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - ">="
69
+ - - '>='
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
74
+ - - '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []