chef-provisioning-fog 0.17.0 → 0.18.0

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: e48c5dfd96019788e8add883cf24a604e197e3d1
4
- data.tar.gz: 5f6cdf09bb038c76620ed6492333e3a912ae3a6e
3
+ metadata.gz: 7a903c7684ebc84d52a05fb774779952b1769d46
4
+ data.tar.gz: 22c0d531e5664e6806e34b8401013afd77855125
5
5
  SHA512:
6
- metadata.gz: f2a4be0a7ea606d12f33aa5942fc2c313644fb58dbb564ca804505fc5df774b6d4269a148d69e9987b102bfab86dbe839210a439d1a4f96d5181c5d3f9c05c96
7
- data.tar.gz: 5a4b1ec56cf012cd0b59d0d4c48c5391b08d08390f67574e47918e1c12b992186fad1929f86c57b8c0a0b7c9b1701da2231c95b984677495a282bcbdddcfb162
6
+ metadata.gz: 838ce6611ff9ee741f622345a60f8d00244612b11a23d4912e23d432948cc9d11f9ba698fe672a1bee74e2e1830bab9695a6ceafb1234a9e0e0a854def4c5d5b
7
+ data.tar.gz: 31bbeddadc8045701cfb9e8d45873a99ab033bfe4a8592442a7db1b3fc728c6d09743648640de406da095ed5c2603e8a09496287ead31653e7166b67227f89ff
data/Gemfile CHANGED
@@ -8,4 +8,5 @@ group :development do
8
8
  gem 'guard'
9
9
  gem 'guard-rspec'
10
10
  gem 'rb-readline'
11
+ gem 'simplecov'
11
12
  end
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Build Status](https://travis-ci.org/chef/chef-provisioning-fog.svg?branch=master)][travis]
5
5
  [![Dependency Status](https://img.shields.io/gemnasium/chef/chef-provisioning-fog.svg)][gemnasium]
6
6
 
7
- This is the Fog driver for Chef Provisioning. It provides Amazon EC2, Rackspace, DigitalOcean, SoftLayer, OpenStack, vCloud Air and XenServer functionality.
7
+ This is the Fog driver for Chef Provisioning. It provides Amazon EC2, DigitalOcean, Google Compute Engine, IBM Softlayer, Joyent, OpenStack, Rackspace, vCloud Air and XenServer functionality.
8
8
 
9
9
  ## Documentation
10
10
 
@@ -21,48 +21,43 @@ These are the primary documents to help learn about using Provisioning and creat
21
21
 
22
22
  **A note about key pairs** - The key name used in `fog_key_pair` must be the same as the filename of the local key to be used. If the key does not exist in one of `private_key_paths` (which you can set in `knife.rb` or in a `client.rb`) it will be created.
23
23
 
24
- ### DigitalOcean
24
+ ### Amazon EC2
25
25
 
26
- Update your `knife.rb` to contain your DigitalOcean API token and the driver:
26
+ You'll need to update your `knife.rb` to work:
27
27
 
28
- ```ruby
29
- driver 'fog:DigitalOcean'
30
- driver_options compute_options: { digitalocean_token: 'token' }
28
+ You need one of the following for the driver:
29
+ ```
30
+ fog:AWS:<account_id>:<region>
31
+ fog:AWS:<profile_name>
32
+ fog:AWS:<profile_name>:<region>
31
33
  ```
32
34
 
33
- For a full example see [examples/digitalocean/simple.rb](examples/digitalocean/simple.rb).
34
-
35
- ### OpenStack
36
-
37
- You'll need to update your `knife.rb` to work:
35
+ For example:
38
36
 
39
37
  ```ruby
40
- driver 'fog:OpenStack'
38
+ driver 'fog:AWS:<account_id>:<region>'
41
39
  driver_options :compute_options => {
42
- :openstack_auth_url => 'http://YOUROPENSTACK-CLOUD:5000/v2.0/tokens',
43
- :openstack_username => 'YOUR-USERNAME',
44
- :openstack_api_key => 'YOUR-PASSWORD',
45
- :openstack_tenant => 'YOUR-TENANT-ID-NAME'
40
+ :aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
41
+ :aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY',
42
+ :region => 'THE-REGION-YOU-WANT-TO-PROVISION-IN'
46
43
  }
47
44
  ```
48
45
 
49
- For a full example see [examples/openstack/simple.rb](examples/openstack/simple.rb).
46
+ For a full example see [examples/aws/simple.rb](examples/aws/simple.rb).
50
47
 
51
- ### Rackspace
52
48
 
53
- For this example, you must configure `knife.rb` with your credentials and a region to operate on. This example is [also available as a Github repo](https://github.com/martinb3/chef-provisioning-rackspace-example).
49
+ ### DigitalOcean
50
+
51
+ Update your `knife.rb` to contain your DigitalOcean API token and the driver:
54
52
 
55
- You must configure some credentials and region in a `knife.rb` file like so:
56
53
  ```ruby
57
- driver 'fog:Rackspace'
58
- driver_options :compute_options => {
59
- :rackspace_username => 'MY-RACKSPACE-USERr',
60
- :rackspace_api_key => 'API-KEY-FOR-USER',
61
- :rackspace_region => 'dfw' # could be 'org', 'iad', 'hkg', etc
62
- }
54
+ driver 'fog:DigitalOcean'
55
+ driver_options compute_options: {
56
+ digitalocean_token: 'token'
57
+ }
63
58
  ```
64
59
 
65
- For a full example see [examples/rackspace/simple.rb](examples/rackspace/simple.rb).
60
+ For a full example see [examples/digitalocean/simple.rb](examples/digitalocean/simple.rb).
66
61
 
67
62
  ### Google Compute Engine
68
63
 
@@ -70,7 +65,8 @@ You'll need to update your `knife.rb` to work:
70
65
 
71
66
  ```ruby
72
67
  driver 'fog:Google'
73
- driver_options :compute_options => { :provider => 'google',
68
+ driver_options :compute_options => {
69
+ :provider => 'google',
74
70
  :google_project => 'YOUR-PROJECT-ID', # the name will work here
75
71
  :google_client_email => 'YOUR-SERVICE-ACCOUNT-EMAIL',
76
72
  :google_key_location => 'YOUR-SERVICE-P12-KEY-FILE-FULL-PATH.p12'
@@ -89,13 +85,44 @@ For a full simple example see [examples/google/simple.rb](examples/google/simple
89
85
  For an example that shows a different `:disk_type` see
90
86
  [examples/google/simple_different_disk.rb](examples/google/simple_different_disk.rb).
91
87
 
92
- ### Joyent
88
+ ### IBM SoftLayer
89
+
90
+ You'll need to update your `knife.rb` to work with this also:
91
+
92
+ ```ruby
93
+ driver 'fog:SoftLayer'
94
+ driver_options :compute_options => {
95
+ :provider => 'softlayer',
96
+ :softlayer_username => 'username',
97
+ :softlayer_api_key => 'api_key',
98
+ :softlayer_default_domain => 'example.com',
99
+ }
100
+
101
+ ```
102
+
103
+ Once you or your administrator has created a SoftLayer account you can manage
104
+ your API key at https://control.softlayer.com/account/users
105
+
106
+ `:bootstrap_options => {:key_name => 'label'}` is looked up by_label; make sure
107
+ you have a public key created on control portal at
108
+ https://control.softlayer.com/devices/sshkeys with a matching label.
109
+
110
+ NOTE: the SoftLayer driver injects a custom post provisioning script that
111
+ ensures some packages needed by chef-provisioning-fog to install chef are
112
+ present (e.g. sudo). The injected script will call your :postInstallScriptUri
113
+ if you define one. The driver will wait until the injected script is done. The
114
+ driver and script communicate using userMetadata so you cannot use metadata.
115
+
116
+ For a full example see [examples/softlayer/simple.rb](examples/softlayer/simple.rb).
117
+
118
+ ### Joyent
93
119
 
94
120
  You'll need to update your `knife.rb` to work:
95
121
 
96
122
  ```ruby
97
123
  driver 'fog:Joyent'
98
- driver_options :compute_options => { :joyent_username => 'YOUR-JOYENT-LOGIN',
124
+ driver_options :compute_options => {
125
+ :joyent_username => 'YOUR-JOYENT-LOGIN',
99
126
  :joyent_password => 'YOUR-JOYENT-PASSWORD',
100
127
  :joyent_keyname => 'THE-SSH-KEY-YOUVE-UPLOADED',
101
128
  :joyent_version => '7.3.0', # if you are using the joyent public cloud
@@ -111,34 +138,47 @@ For a more in-depth usage of this driver to use with either Private or Public Jo
111
138
 
112
139
  For a infrastructure container example see [examples/joyent/infrastructure.rb](examples/joyent/infrastructure.rb).
113
140
 
114
- ### IBM SoftLayer
115
141
 
116
- You'll need to update your `knife.rb` to work with this also:
142
+ ### OpenStack
143
+
144
+ You'll need to update your `knife.rb` to work:
117
145
 
118
146
  ```ruby
119
- driver 'fog:SoftLayer'
120
- driver_options :compute_options => { :provider => 'softlayer',
121
- :softlayer_username => 'username',
122
- :softlayer_api_key => 'api_key',
123
- :softlayer_default_domain => 'example.com',
124
- }
147
+ driver 'fog:OpenStack'
148
+ driver_options :compute_options => {
149
+ :openstack_auth_url => 'http://YOUROPENSTACK-CLOUD:5000/v2.0/tokens',
150
+ :openstack_username => 'YOUR-USERNAME',
151
+ :openstack_api_key => 'YOUR-PASSWORD',
152
+ :openstack_tenant => 'YOUR-TENANT-ID-NAME'
153
+ }
154
+ ```
155
+
156
+ For a full example see [examples/openstack/simple.rb](examples/openstack/simple.rb).
157
+
158
+ ### Rackspace
125
159
 
160
+ For this example, you must configure `knife.rb` with your credentials and a region to operate on. This example is [also available as a Github repo](https://github.com/martinb3/chef-provisioning-rackspace-example).
161
+
162
+ You must configure some credentials and region in a `knife.rb` file like so:
163
+ ```ruby
164
+ driver 'fog:Rackspace'
165
+ driver_options :compute_options => {
166
+ :rackspace_username => 'MY-RACKSPACE-USERr',
167
+ :rackspace_api_key => 'API-KEY-FOR-USER',
168
+ :rackspace_region => 'dfw' # could be 'org', 'iad', 'hkg', etc
169
+ }
126
170
  ```
127
171
 
128
- Once you or your administrator has created a SoftLayer account you can manage
129
- your API key at https://control.softlayer.com/account/users
172
+ For a full example see [examples/rackspace/simple.rb](examples/rackspace/simple.rb).
130
173
 
131
- `:bootstrap_options => {:key_name => 'label'}` is looked up by_label; make sure
132
- you have a public key created on control portal at
133
- https://control.softlayer.com/devices/sshkeys with a matching label.
174
+ ### vCloud Air
134
175
 
135
- NOTE: the SoftLayer driver injects a custom post provisioning script that
136
- ensures some packages needed by chef-provisioning-fog to install chef are
137
- present (e.g. sudo). The injected script will call your :postInstallScriptUri
138
- if you define one. The driver will wait until the injected script is done. The
139
- driver and script communicate using userMetadata so you cannot use metadata.
176
+ Docs TODO.
177
+
178
+ ### XenServer
179
+
180
+ Docs TODO.
140
181
 
141
- For a full example see [examples/softlayer/simple.rb](examples/softlayer/simple.rb).
142
182
 
143
183
  ### Cleaning up
144
184
 
@@ -165,10 +205,9 @@ Chef Provisioning has two major abstractions: the machine resource, and drivers.
165
205
 
166
206
  You declare what your machines do (recipes, tags, etc.) with the `machine` resource, the fundamental unit of Chef Provisioning. You will typically declare `machine` resources in a separate, OS/provisioning-independent file that declares the *topology* of your app--your machines and the recipes that will run on them.
167
207
 
168
- The machine resources from the [cluster.rb example](https://github.com/chef/chef-provisioning/blob/master/docs/examples/cluster.rb) are pretty straightforward. Here's a copy/paste:
208
+ The machine resources from the [cluster.rb example](https://github.com/chef/chef-provisioning/blob/master/docs/examples/cluster.rb) are pretty straightforward. Here's a copy/paste, it'll create a database machine then one web server.
169
209
 
170
210
  ```ruby
171
- # Database!
172
211
  machine 'mario' do
173
212
  recipe 'postgresql'
174
213
  recipe 'mydb'
@@ -177,7 +216,6 @@ end
177
216
 
178
217
  num_webservers = 1
179
218
 
180
- # Web servers!
181
219
  1.upto(num_webservers) do |i|
182
220
  machine "luigi#{i}" do
183
221
  recipe 'apache'
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'bundler'
2
2
  require 'bundler/gem_tasks'
3
3
 
4
+ desc "run specs"
4
5
  task :spec do
5
- require File.expand_path('spec/run')
6
+ sh "bundle exec rspec"
6
7
  end
7
8
 
8
9
  require "github_changelog_generator/task"
@@ -244,7 +244,7 @@ module FogDriver
244
244
  machine_spec.reference = nil
245
245
  end
246
246
  end
247
- strategy = convergence_strategy_for(machine_spec, machine_options)
247
+ strategy = ConvergenceStrategy::NoConverge.new(machine_options[:convergence_options], config)
248
248
  strategy.cleanup_convergence(action_handler, machine_spec)
249
249
  end
250
250
 
@@ -297,7 +297,8 @@ module FogDriver
297
297
  specs_and_options.each do |machine_spec, machine_options|
298
298
  server = specs_and_servers[machine_spec]
299
299
  if server
300
- if %w(terminated archive DELETED).include?(server.state) # Can't come back from that
300
+ server_state = server.respond_to?(:status) ? server.status : server.state
301
+ if %w(terminated archive DELETED).include?(server_state.downcase) # Can't come back from that
301
302
  Chef::Log.warn "Machine #{machine_spec.name} (#{server.id} on #{driver_url}) is terminated. Recreating ..."
302
303
  else
303
304
  yield machine_spec, server if block_given?
@@ -307,13 +308,13 @@ module FogDriver
307
308
  Chef::Log.warn "Machine #{machine_spec.name} (#{machine_spec.reference['server_id']} on #{driver_url}) no longer exists. Recreating ..."
308
309
  end
309
310
 
310
- machine_spec.reference ||= {}
311
- machine_spec.reference.update(
312
- 'driver_url' => driver_url,
313
- 'driver_version' => FogDriver::VERSION,
314
- 'creator' => creator,
315
- 'allocated_at' => Time.now.to_i
316
- )
311
+ machine_spec.reference ||= {}
312
+ machine_spec.reference.update(
313
+ 'driver_url' => driver_url,
314
+ 'driver_version' => FogDriver::VERSION,
315
+ 'creator' => creator,
316
+ 'allocated_at' => Time.now.to_i
317
+ )
317
318
 
318
319
  bootstrap_options = bootstrap_options_for(action_handler, machine_spec, machine_options)
319
320
  machine_spec.reference['key_name'] = bootstrap_options[:key_name] if bootstrap_options[:key_name]
@@ -375,13 +376,13 @@ module FogDriver
375
376
 
376
377
  def start_server(action_handler, machine_spec, server)
377
378
  # If it is stopping, wait for it to get out of "stopping" transition status before starting
378
- if server.state == 'stopping'
379
+ server_state = server.respond_to?(:status) ? server.status : server.state
380
+ if server_state == 'stopping'
379
381
  action_handler.report_progress "wait for #{machine_spec.name} (#{server.id} on #{driver_url}) to finish stopping ..."
380
- server.wait_for { server.state != 'stopping' }
382
+ server.wait_for { server_state != 'stopping' }
381
383
  action_handler.report_progress "#{machine_spec.name} is now stopped"
382
384
  end
383
-
384
- if server.state == 'stopped'
385
+ if server_state == 'stopped'
385
386
  action_handler.perform_action "start machine #{machine_spec.name} (#{server.id} on #{driver_url})" do
386
387
  server.start
387
388
  machine_spec.reference['started_at'] = Time.now.to_i
@@ -10,6 +10,13 @@ module FogDriver
10
10
  ''
11
11
  end
12
12
 
13
+ def convergence_strategy_for(machine_spec, machine_options)
14
+ machine_options = Cheffish::MergedConfig.new(machine_options, {
15
+ :convergence_options => {:ohai_hints => {'digital_ocean' => {}}}
16
+ })
17
+ super(machine_spec, machine_options)
18
+ end
19
+
13
20
  def converge_floating_ips(action_handler, machine_spec, machine_options, server)
14
21
  # DigitalOcean does not have floating IPs
15
22
  end
@@ -9,6 +9,13 @@ class Chef
9
9
  ''
10
10
  end
11
11
 
12
+ def convergence_strategy_for(machine_spec, machine_options)
13
+ machine_options = Cheffish::MergedConfig.new(machine_options, {
14
+ :convergence_options => {:ohai_hints => {'gce' => {}}}
15
+ })
16
+ super(machine_spec, machine_options)
17
+ end
18
+
12
19
  def converge_floating_ips(action_handler, machine_spec, machine_options, server)
13
20
  end
14
21
 
@@ -11,6 +11,13 @@ module FogDriver
11
11
  compute_options[:openstack_username]
12
12
  end
13
13
 
14
+ def convergence_strategy_for(machine_spec, machine_options)
15
+ machine_options = Cheffish::MergedConfig.new(machine_options, {
16
+ :convergence_options => {:ohai_hints => {'openstack' => {}}}
17
+ })
18
+ super(machine_spec, machine_options)
19
+ end
20
+
14
21
  def self.compute_options_for(provider, id, config)
15
22
  new_compute_options = {}
16
23
  new_compute_options[:provider] = provider
@@ -11,6 +11,14 @@ module FogDriver
11
11
  compute_options[:rackspace_username]
12
12
  end
13
13
 
14
+ def convergence_strategy_for(machine_spec, machine_options)
15
+ machine_options = Cheffish::MergedConfig.new(machine_options, {
16
+ :convergence_options => {:ohai_hints => {'rackspace' => {}}}
17
+ })
18
+ super(machine_spec, machine_options)
19
+ end
20
+
21
+
14
22
  def self.compute_options_for(provider, id, config)
15
23
  new_compute_options = {}
16
24
  new_compute_options[:provider] = provider
@@ -17,6 +17,13 @@ class Chef
17
17
  compute_options[:softlayer_username]
18
18
  end
19
19
 
20
+ def convergence_strategy_for(machine_spec, machine_options)
21
+ machine_options = Cheffish::MergedConfig.new(machine_options, {
22
+ :convergence_options => {:ohai_hints => {'softlayer' => {}}}
23
+ })
24
+ super(machine_spec, machine_options)
25
+ end
26
+
20
27
  def self.compute_options_for(provider, id, config)
21
28
  new_compute_options = {}
22
29
  new_compute_options[:provider] = provider
@@ -211,4 +218,3 @@ SHELL
211
218
  end
212
219
  end
213
220
  end
214
-
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Provisioning
3
3
  module FogDriver
4
- VERSION = '0.17.0'
4
+ VERSION = '0.18.0'
5
5
  end
6
6
  end
7
7
  end
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,14 @@ $:.unshift File.expand_path('../support', __FILE__)
3
3
  require 'fog'
4
4
  require 'chef/provisioning'
5
5
  require 'chef/provisioning/fog_driver/driver'
6
+ require 'simplecov'
7
+
8
+ SimpleCov.start do
9
+ # add_filter do |source_file|
10
+ # # source_file.lines.count < 5
11
+ # source.filename =~ /^#{SimpleCov.root}\/chef-provisioning-fake/)
12
+ # end
13
+ end
6
14
 
7
15
  RSpec.configure do |config|
8
16
  config.run_all_when_everything_filtered = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-03-28 00:00:00.000000000 Z
15
+ date: 2016-03-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: chef-provisioning