chef-provisioning-fog 0.12 → 0.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34990906985f7a7c4de47ef2a7e670a309412324
4
- data.tar.gz: ad07082eaa71fc18afdc44b5fbd22819ffc75998
3
+ metadata.gz: e33216302d47668520364a911ed5161cd681ca4a
4
+ data.tar.gz: 0cc594a02828434a96c2202f3ff7db057825cbe4
5
5
  SHA512:
6
- metadata.gz: 62236621c239d507ed1393e3a6780ca72966e7f27a46d4954ea5ca4da066dc18b826c5a2cf7f3fe4b251decec583e9212774a0614228abd62a4e6f379c400eec
7
- data.tar.gz: 1b7e1878546996f6d05790f3efbf5d0b855aa88db4a77553ef08c039a31c3f36979eedca140311d78a7f826339b31502ea2fef266b7902f40a3d48d8feb4579e
6
+ metadata.gz: 35cb4c6b4f3dbd4711db0e791568b49a614169b2b648a3f815684759219412b6a027b636ebc3e2a8ce521ef007a388aa37998bb989c95611f6b553a001e42b08
7
+ data.tar.gz: db0e74164bf16bb798025477d3dc1239ad3bf34eb69c823bf58ae2fcaa7c42222b6aa1100530108f4d03234de8fdf21b32afd43445c0b16bb7cbfa53bdcb917c
@@ -53,8 +53,8 @@ module FogDriver
53
53
  # from_provider and compute_options_for, and add the new provider in the case
54
54
  # statements so that URLs for your fog provider can be generated. If your
55
55
  # cloud provider has environment variables or standard config files (like
56
- # ~/.aws/config), you can read those and merge that information in the
57
- # compute_options_for function.
56
+ # ~/.aws/credentials or ~/.aws/config), you can read those and merge that information
57
+ # in the compute_options_for function.
58
58
  #
59
59
  # ## Location format
60
60
  #
@@ -155,7 +155,7 @@ module FogDriver
155
155
  # config - configuration. :driver_options, :keys, :key_paths and :log_level are used.
156
156
  # driver_options is a hash with these possible options:
157
157
  # - compute_options: the hash of options to Fog::Compute.new.
158
- # - aws_config_file: aws config file (default: ~/.aws/config)
158
+ # - aws_config_file: aws config file (defaults: ~/.aws/credentials, ~/.aws/config)
159
159
  # - aws_csv_file: aws csv credentials file downloaded from EC2 interface
160
160
  # - aws_profile: profile name to use for credentials
161
161
  # - aws_credentials: AWSCredentials object. (will be created for you by default)
@@ -167,8 +167,9 @@ module FogDriver
167
167
  end
168
168
 
169
169
  def convergence_strategy_for(machine_spec, machine_options)
170
- machine_options[:convergence_options] ||= {}
171
- machine_options[:convergence_options][:ohai_hints] = { 'ec2' => ''}
170
+ machine_options = Cheffish::MergedConfig.new(machine_options, {
171
+ :convergence_options => {:ohai_hints => {'ec2' => ''}}
172
+ })
172
173
  super(machine_spec, machine_options)
173
174
  end
174
175
 
@@ -227,7 +228,7 @@ module FogDriver
227
228
  aws_profile = find_aws_profile_for_account_id(aws_credentials, aws_account_id, default_iam_endpoint)
228
229
  end
229
230
 
230
- fail 'No AWS profile specified! Are you missing something in the Chef config or ~/.aws/config?' unless aws_profile
231
+ fail 'No AWS profile specified! Are you missing something in the Chef or AWS config?' unless aws_profile
231
232
 
232
233
  aws_profile[:ec2_endpoint] ||= default_ec2_endpoint
233
234
  aws_profile[:iam_endpoint] ||= default_iam_endpoint
@@ -256,7 +257,7 @@ module FogDriver
256
257
  if aws_profile
257
258
  Chef::Log.info("Discovered AWS profile #{aws_profile[:name]} pointing at account #{aws_account_id}. Using ...")
258
259
  else
259
- raise "No AWS profile leads to account ##{aws_account_id}. Do you need to add profiles to ~/.aws/config?"
260
+ raise "No AWS profile leads to account #{aws_account_id}. Do you need to add profiles to the AWS config?"
260
261
  end
261
262
  aws_profile
262
263
  end
@@ -313,9 +314,9 @@ module FogDriver
313
314
  else
314
315
  aws_credentials = Credentials.new
315
316
  if driver_options[:aws_config_file]
316
- aws_credentials.load_ini(driver_options.delete(:aws_config_file))
317
+ aws_credentials.load_ini(driver_options[:aws_config_file])
317
318
  elsif driver_options[:aws_csv_file]
318
- aws_credentials.load_csv(driver_options.delete(:aws_csv_file))
319
+ aws_credentials.load_csv(driver_options[:aws_csv_file])
319
320
  else
320
321
  aws_credentials.load_default
321
322
  end
@@ -1,5 +1,6 @@
1
1
  require 'inifile'
2
2
  require 'csv'
3
+ require 'chef/mixin/deep_merge'
3
4
 
4
5
  class Chef
5
6
  module Provisioning
@@ -13,10 +14,11 @@ module FogDriver
13
14
  end
14
15
 
15
16
  include Enumerable
17
+ include Chef::Mixin::DeepMerge
16
18
 
17
19
  def default
18
20
  if @credentials.size == 0
19
- raise "No credentials loaded! Do you have a ~/.aws/config?"
21
+ raise "No credentials loaded! Do you have one of ~/.aws/credentials or ~/.aws/config?"
20
22
  end
21
23
  @credentials[ENV['AWS_DEFAULT_PROFILE'] || 'default'] || @credentials.first[1]
22
24
  end
@@ -33,8 +35,16 @@ module FogDriver
33
35
  @credentials.each(&block)
34
36
  end
35
37
 
36
- def load_ini(credentials_ini_file)
37
- inifile = IniFile.load(File.expand_path(credentials_ini_file))
38
+ def load_inis(config_ini_file, credentials_ini_file = nil)
39
+ @credentials = load_config_ini(config_ini_file)
40
+ @credentials = deep_merge!(@credentials,
41
+ load_credentials_ini(credentials_ini_file)
42
+ ) if credentials_ini_file
43
+ end
44
+
45
+ def load_config_ini(config_ini_file)
46
+ inifile = IniFile.load(File.expand_path(config_ini_file))
47
+ config = {}
38
48
  if inifile
39
49
  inifile.each_section do |section|
40
50
  if section =~ /^\s*profile\s+(.+)$/ || section =~ /^\s*(default)\s*/
@@ -44,14 +54,27 @@ module FogDriver
44
54
  result
45
55
  end
46
56
  profile[:name] = profile_name
47
- @credentials[profile_name] = profile
57
+ config[profile_name] = profile
48
58
  end
49
59
  end
50
- else
51
- # Get it to throw an error
52
- File.open(File.expand_path(credentials_ini_file)) do
60
+ end
61
+ config
62
+ end
63
+
64
+ def load_credentials_ini(credentials_ini_file)
65
+ inifile = IniFile.load(File.expand_path(credentials_ini_file))
66
+ config = {}
67
+ if inifile
68
+ inifile.each_section do |section|
69
+ profile = inifile[section].inject({}) do |result, pair|
70
+ result[pair[0].to_sym] = pair[1]
71
+ result
72
+ end
73
+ profile[:name] = section
74
+ config[section] = profile
53
75
  end
54
76
  end
77
+ config
55
78
  end
56
79
 
57
80
  def load_csv(credentials_csv_file)
@@ -67,8 +90,13 @@ module FogDriver
67
90
 
68
91
  def load_default
69
92
  config_file = ENV['AWS_CONFIG_FILE'] || File.expand_path('~/.aws/config')
93
+ credentials_file = ENV['AWS_CREDENTIAL_FILE'] || File.expand_path('~/.aws/credentials')
70
94
  if File.file?(config_file)
71
- load_ini(config_file)
95
+ if File.file?(credentials_file)
96
+ load_inis(config_file, credentials_file)
97
+ else
98
+ load_inis(config_file)
99
+ end
72
100
  end
73
101
  end
74
102
 
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Provisioning
3
3
  module FogDriver
4
- VERSION = '0.12'
4
+ VERSION = '0.13'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-fog
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.12'
4
+ version: '0.13'
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-27 00:00:00.000000000 Z
11
+ date: 2015-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef