knife-digital_ocean 0.0.5 → 0.1.0
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 +15 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +30 -0
- data/Guardfile +24 -0
- data/README.md +39 -9
- data/knife-digital_ocean.gemspec +2 -3
- data/lib/chef/knife/digital_ocean_base.rb +18 -9
- data/lib/chef/knife/digital_ocean_droplet_create.rb +36 -12
- data/lib/chef/knife/digital_ocean_droplet_destroy.rb +1 -1
- data/lib/chef/knife/digital_ocean_droplet_list.rb +1 -1
- data/lib/chef/knife/digital_ocean_image_list.rb +1 -1
- data/lib/chef/knife/digital_ocean_region_list.rb +1 -1
- data/lib/chef/knife/digital_ocean_size_list.rb +1 -1
- data/lib/chef/knife/digital_ocean_sshkey_list.rb +1 -1
- data/lib/knife-digital_ocean/version.rb +1 -1
- data/spec/lib/chef/knife/digital_ocean_droplet_create_spec.rb +152 -0
- data/spec/lib/chef/knife/digital_ocean_droplet_destroy_spec.rb +6 -0
- data/spec/lib/chef/knife/digital_ocean_droplet_list_spec.rb +6 -0
- data/spec/lib/chef/knife/digital_ocean_image_list_spec.rb +6 -0
- data/spec/lib/chef/knife/digital_ocean_region_list_spec.rb +6 -0
- data/spec/lib/chef/knife/digital_ocean_size_list_spec.rb +6 -0
- data/spec/lib/chef/knife/digital_ocean_sshkey_list_spec.rb +6 -0
- data/spec/lib/knife-digital_ocean/version_spec.rb +8 -0
- data/spec/spec_helper.rb +10 -3
- metadata +36 -44
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTZkMjlmY2NhNmQ3YmQ1ZjM1ZTI0MjM0MmQyMmQwZDRlOGVlM2I0OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTFmN2M3ZTQ0NDZiMzQxM2Y0NmIzZGJlZDgwYWU0NWMzY2E5NDFhYQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzQ1Y2Y5Mjk5YWJjZTNiOTNlZTQzNTljMjEwMzI0MTZjMTZjNzk1ZmMxYmUy
|
10
|
+
OGYyMzFjMmU0YTRlYjJhMTQwZTFhMGJlMzU1NmJjNzYwOTNlMzc4Mjc0MDM2
|
11
|
+
NGIzOTRkNGMzM2MzYmRlMzcxYjc2MWE4ZTcwMzRiYjNlOWI4Y2U=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTczNTdhM2E4YTk1ZWM5MTAxZmU0MDI5ZWFiNjM3MjE1ZDA0OTczYjdjZWYy
|
14
|
+
YTgxZDgzNzhjZTJkMjEwZTM0YzVkN2UwNTdmNGI0MGE3Y2RkNzM1NDE2YzYy
|
15
|
+
Y2E2ZDZkZWFkYzJhOWRmNjI5YTRlMmJkYTM4N2E5ZTkyYzY0OWI=
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
## 0.1.1 / unreleased
|
2
|
+
|
3
|
+
## 0.1.0 / 2013-03-01
|
4
|
+
|
5
|
+
* [Full Changelog](https://github.com/rmoriz/knife-digital_ocean/compare/v0.0.5...master)
|
6
|
+
* support for integrated ```knife-solo``` bootstrapping using the ```--solo``` option (by tmatilai)
|
7
|
+
* added basic rspec tests for various bootstrapping options
|
8
|
+
* remove JRuby from CI as chef itself does currently not work with JRuby
|
9
|
+
except when c-extensions are enabled (off by default)
|
10
|
+
|
11
|
+
|
12
|
+
## 0.0.5 / 2013-02-23
|
13
|
+
|
14
|
+
* [Full Changelog](https://github.com/rmoriz/knife-digital_ocean/compare/v0.0.4...v0.0.5)
|
15
|
+
|
16
|
+
|
17
|
+
## 0.0.4 / 2013-02-18
|
18
|
+
|
19
|
+
* [Full Changelog](https://github.com/rmoriz/knife-digital_ocean/compare/v0.0.3...v0.0.4)
|
20
|
+
|
21
|
+
|
22
|
+
## 0.0.2 / 2013-02-04
|
23
|
+
|
24
|
+
* [Full Changelog](https://github.com/rmoriz/knife-digital_ocean/compare/v0.0.1...v0.0.2)
|
25
|
+
|
26
|
+
|
27
|
+
## 0.0.1 / 2013-02-03
|
28
|
+
|
29
|
+
* [Full Changelog](https://github.com/rmoriz/knife-digital_ocean/compare/d9bd11c01c8d963a1214e7ab234eeb7f09e6a7eb...v0.0.1)
|
30
|
+
* First release
|
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
data/README.md
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
# Knife::DigitalOcean
|
2
2
|
## A knife plugin to deal with the [DigitalOcean.com](https://www.digitalocean.com) Cloud services.
|
3
3
|
|
4
|
+
[](https://travis-ci.org/rmoriz/knife-digital_ocean)
|
5
|
+
<a href="https://gemnasium.com/rmoriz/knife-digital_ocean"><img src="https://gemnasium.com/rmoriz/knife-digital_ocean.png"/></a>
|
6
|
+
<a href="https://codeclimate.com/github/rmoriz/knife-digital_ocean"><img src="https://codeclimate.com/github/rmoriz/knife-digital_ocean.png"/></a>
|
7
|
+
|
4
8
|
This is a plugin for [Chef's](http://www.opscode.com/chef/) [knife](http://wiki.opscode.com/display/chef/Knife) tool. It allows you to bootstrap virtual machines with [DigitalOcean.com](https://www.digitalocean.com/) including the initial bootstrapping of chef on that system.
|
5
|
-
You can also
|
9
|
+
You can also use [knife-solo](http://matschaffer.github.com/knife-solo/) for chef bootstrapping or skip it altogether for another solution.
|
6
10
|
|
7
11
|
This knife plugin uses the [digital_ocean](https://github.com/rmoriz/digital_ocean) rubygem.
|
8
12
|
|
9
13
|
|
10
14
|
## Installation
|
11
15
|
|
12
|
-
(chef needs to be installed upfront, of course)
|
13
|
-
|
14
16
|
```shell
|
15
17
|
➜ gem install knife-digital_ocean
|
16
18
|
```
|
@@ -21,7 +23,7 @@ This knife plugin uses the [digital_ocean](https://github.com/rmoriz/digital_oce
|
|
21
23
|
This plugin provides the following sub-commands:
|
22
24
|
|
23
25
|
* knife digital_ocean droplet create (options)
|
24
|
-
**Creates a virtual machine with or without bootstrapping chef
|
26
|
+
**Creates a virtual machine with or without bootstrapping chef**
|
25
27
|
|
26
28
|
* knife digital_ocean droplet destroy (options)
|
27
29
|
**Destroys the virtual machine and its data**
|
@@ -55,7 +57,13 @@ knife[:digital_ocean_api_key] = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
|
|
55
57
|
|
56
58
|
### Create a Droplet
|
57
59
|
|
58
|
-
|
60
|
+
There are three different ways of creating a server/droplet instance:
|
61
|
+
|
62
|
+
If you just want to launch an instance
|
63
|
+
form the command line without any bootstrapping, go for option **C**.
|
64
|
+
If you use ```knife-solo``` try **B** and if you are a ```chef-server```-fan
|
65
|
+
use method **A**:
|
66
|
+
#### A. With bootstrapping in an chef-server environment:
|
59
67
|
|
60
68
|
__Example__
|
61
69
|
|
@@ -93,9 +101,26 @@ __Short Syntax__
|
|
93
101
|
-r "<RUNLIST>"
|
94
102
|
```
|
95
103
|
|
96
|
-
#### With knife-solo
|
104
|
+
#### B. With knife-solo bootstrapping
|
97
105
|
|
98
|
-
|
106
|
+
You need to have [knife-solo](http://matschaffer.github.com/knife-solo/) gem installed.
|
107
|
+
|
108
|
+
This will create a droplet and run `knife solo bootstrap <IP>` equivalent for it.
|
109
|
+
|
110
|
+
__Example__
|
111
|
+
|
112
|
+
```bash
|
113
|
+
➜ knife digital_ocean droplet create --server-name awesome-vm1.chef.io \
|
114
|
+
--image 25306 \
|
115
|
+
--location 2 \
|
116
|
+
--size 66 \
|
117
|
+
--ssh-keys 1234,4567 \
|
118
|
+
--solo
|
119
|
+
```
|
120
|
+
|
121
|
+
#### C. With your custom external bootstrapping script or without chef at all
|
122
|
+
|
123
|
+
This will just create a droplet and return its IP-address. Nothing else. You can now run your custom solution to provision the droplet.
|
99
124
|
|
100
125
|
__Example__
|
101
126
|
|
@@ -123,7 +148,7 @@ ID Name Size Region IPv4 Image
|
|
123
148
|
OK
|
124
149
|
```
|
125
150
|
|
126
|
-
### List regions
|
151
|
+
### List regions
|
127
152
|
|
128
153
|
```shell
|
129
154
|
➜ knife digital_ocean region list
|
@@ -132,7 +157,7 @@ ID Name
|
|
132
157
|
2 Amsterdam 1
|
133
158
|
```
|
134
159
|
|
135
|
-
### List sizes (
|
160
|
+
### List sizes (instance types)
|
136
161
|
|
137
162
|
```shell
|
138
163
|
➜ knife digital_ocean size list
|
@@ -229,6 +254,11 @@ Commercial support is available. Please contact [https://roland.io/](https://rol
|
|
229
254
|
4. Push to the branch (`git push origin my-new-feature`)
|
230
255
|
5. Create new Pull Request
|
231
256
|
|
257
|
+
### Contributors
|
258
|
+
|
259
|
+
* [Teemu Matilainen](https://github.com/tmatilai)
|
260
|
+
|
261
|
+
For more information and a complete list see [the contributor page on GitHub](https://github.com/rmoriz/knife-digital_ocean/contributors).
|
232
262
|
|
233
263
|
## License
|
234
264
|
|
data/knife-digital_ocean.gemspec
CHANGED
@@ -16,14 +16,13 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.add_dependency 'chef', '>= 10.18'
|
17
17
|
gem.add_dependency 'digital_ocean'
|
18
18
|
gem.add_dependency 'highline'
|
19
|
-
gem.add_dependency 'net-ssh-multi', '~> 1.1'
|
20
19
|
|
21
|
-
|
22
|
-
gem.add_development_dependency 'rspec', '~> 2.0'
|
20
|
+
gem.add_development_dependency 'rspec', '~> 2.13'
|
23
21
|
gem.add_development_dependency 'guard'
|
24
22
|
gem.add_development_dependency 'guard-rspec'
|
25
23
|
gem.add_development_dependency 'rb-fsevent'
|
26
24
|
gem.add_development_dependency 'rake'
|
25
|
+
gem.add_development_dependency 'knife-solo'
|
27
26
|
|
28
27
|
gem.files = `git ls-files`.split($/)
|
29
28
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -16,19 +16,28 @@ class Chef
|
|
16
16
|
class Knife
|
17
17
|
module DigitalOceanBase
|
18
18
|
|
19
|
+
def self.load_deps
|
20
|
+
require 'digital_ocean'
|
21
|
+
require 'highline'
|
22
|
+
end
|
23
|
+
|
19
24
|
def self.included(includer)
|
20
25
|
includer.class_eval do
|
21
26
|
category 'digital_ocean'
|
22
27
|
|
23
|
-
deps
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
# Lazy load our dependencies. Later calls to `Knife#deps` override
|
29
|
+
# previous ones, so if the including class calls it, it needs to also
|
30
|
+
# call our #load_deps, i.e:
|
31
|
+
#
|
32
|
+
# Include Chef::Knife::DigitalOceanBase
|
33
|
+
#
|
34
|
+
# deps do
|
35
|
+
# require 'foo'
|
36
|
+
# require 'bar'
|
37
|
+
# Chef::Knife::DigitalOceanBase.load_deps
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
deps { Chef::Knife::DigitalOceanBase.load_deps }
|
32
41
|
|
33
42
|
option :digital_ocean_client_id,
|
34
43
|
:short => '-K CLIENT_ID',
|
@@ -10,13 +10,23 @@
|
|
10
10
|
# See the License for the specific language governing permissions and
|
11
11
|
# limitations under the License.
|
12
12
|
#
|
13
|
-
require
|
13
|
+
require 'chef/knife/digital_ocean_base'
|
14
14
|
|
15
15
|
class Chef
|
16
16
|
class Knife
|
17
17
|
class DigitalOceanDropletCreate < Knife
|
18
18
|
include Knife::DigitalOceanBase
|
19
19
|
|
20
|
+
deps do
|
21
|
+
require 'socket'
|
22
|
+
require 'chef/knife/bootstrap'
|
23
|
+
Chef::Knife::Bootstrap.load_deps
|
24
|
+
Chef::Knife::DigitalOceanBase.load_deps
|
25
|
+
# Knife loads subcommands automatically, so we can just check if the
|
26
|
+
# class exists.
|
27
|
+
Chef::Knife::SoloBootstrap.load_deps if defined? Chef::Knife::SoloBootstrap
|
28
|
+
end
|
29
|
+
|
20
30
|
banner 'knife digital_ocean droplet create (options)'
|
21
31
|
|
22
32
|
option :server_name,
|
@@ -58,8 +68,12 @@ class Chef
|
|
58
68
|
option :bootstrap,
|
59
69
|
:short => '-B',
|
60
70
|
:long => '--bootstrap',
|
61
|
-
:
|
62
|
-
|
71
|
+
:description => 'Do a chef-client bootstrap on the created droplet (for use with chef-server)'
|
72
|
+
|
73
|
+
option :solo,
|
74
|
+
:long => '--[no-]solo',
|
75
|
+
:description => 'Do a chef-solo bootstrap on the droplet using knife-solo',
|
76
|
+
:proc => Proc.new { |s| Chef::Config[:knife][:solo] = s }
|
63
77
|
|
64
78
|
option :ssh_user,
|
65
79
|
:short => '-x USERNAME',
|
@@ -90,7 +104,6 @@ class Chef
|
|
90
104
|
option :host_key_verify,
|
91
105
|
:long => "--[no-]host-key-verify",
|
92
106
|
:description => "Verify host key, enabled by default",
|
93
|
-
:boolean => true,
|
94
107
|
:default => true
|
95
108
|
|
96
109
|
option :prerelease,
|
@@ -132,6 +145,15 @@ class Chef
|
|
132
145
|
exit 1
|
133
146
|
end
|
134
147
|
|
148
|
+
if solo_bootstrap? && !defined?(Chef::Knife::SoloBootstrap)
|
149
|
+
ui.error [
|
150
|
+
'Knife plugin knife-solo was not found.',
|
151
|
+
'Please add the knife-solo gem to your Gemfile or',
|
152
|
+
'install it manually with `gem install knife-solo`.'
|
153
|
+
].join(" ")
|
154
|
+
exit 1
|
155
|
+
end
|
156
|
+
|
135
157
|
response = client.droplets.create(:name => locate_config_value(:server_name),
|
136
158
|
:size_id => locate_config_value(:size),
|
137
159
|
:image_id => locate_config_value(:image),
|
@@ -158,7 +180,7 @@ class Chef
|
|
158
180
|
puts 'done'
|
159
181
|
}
|
160
182
|
|
161
|
-
if locate_config_value(:bootstrap)
|
183
|
+
if locate_config_value(:bootstrap) || solo_bootstrap?
|
162
184
|
bootstrap_for_node(ip_address).run
|
163
185
|
else
|
164
186
|
puts ip_address
|
@@ -203,22 +225,24 @@ class Chef
|
|
203
225
|
end
|
204
226
|
|
205
227
|
def bootstrap_for_node(ip_address)
|
206
|
-
bootstrap =
|
228
|
+
bootstrap = bootstrap_class.new
|
207
229
|
bootstrap.name_args = [ ip_address ]
|
208
|
-
bootstrap.config
|
209
|
-
bootstrap.config[:ssh_user] = config[:ssh_user]
|
210
|
-
bootstrap.config[:identity_file] = config[:identity_file]
|
230
|
+
bootstrap.config = config.dup
|
211
231
|
bootstrap.config[:chef_node_name] = locate_config_value(:server_name)
|
212
|
-
bootstrap.config[:prerelease] = config[:prerelease]
|
213
232
|
bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
|
214
233
|
bootstrap.config[:distro] = locate_config_value(:distro)
|
215
234
|
bootstrap.config[:use_sudo] = true unless config[:ssh_user] == 'root'
|
216
235
|
bootstrap.config[:template_file] = locate_config_value(:template_file)
|
217
|
-
bootstrap.config[:environment] = config[:environment]
|
218
|
-
bootstrap.config[:host_key_verify] = config[:host_key_verify]
|
219
236
|
bootstrap
|
220
237
|
end
|
221
238
|
|
239
|
+
def bootstrap_class
|
240
|
+
solo_bootstrap? ? Chef::Knife::SoloBootstrap : Chef::Knife::Bootstrap
|
241
|
+
end
|
242
|
+
|
243
|
+
def solo_bootstrap?
|
244
|
+
config[:solo] || (config[:solo].nil? && Chef::Config[:knife][:solo])
|
245
|
+
end
|
222
246
|
end
|
223
247
|
end
|
224
248
|
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
def mock_api_response(data = {})
|
4
|
+
Hashie::Rash.new(data)
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Chef::Knife::DigitalOceanDropletCreate do
|
8
|
+
|
9
|
+
subject {
|
10
|
+
s = Chef::Knife::DigitalOceanDropletCreate.new
|
11
|
+
s.stub(:client).and_return mock(DigitalOcean::API)
|
12
|
+
s
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:config) {
|
16
|
+
{
|
17
|
+
:digital_ocean_client_id => 'CLIENT_ID',
|
18
|
+
:digital_ocean_api_key => 'API_KEY',
|
19
|
+
:server_name => 'sever-name.example.com',
|
20
|
+
:image => 11111,
|
21
|
+
:location => 22222,
|
22
|
+
:size => 33333,
|
23
|
+
:ssh_key_ids => [ 44444, 44445 ]
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
let(:custom_config) {
|
28
|
+
{}
|
29
|
+
}
|
30
|
+
|
31
|
+
let(:api_response) {
|
32
|
+
{
|
33
|
+
:status => 'OK',
|
34
|
+
:droplet => { :id => '123' }
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
before do
|
39
|
+
Chef::Knife::DigitalOceanDropletCreate.load_deps
|
40
|
+
|
41
|
+
# reset
|
42
|
+
Chef::Config[:knife] = {}
|
43
|
+
|
44
|
+
# config
|
45
|
+
config.merge(custom_config).each do |k, v|
|
46
|
+
Chef::Config[:knife][k] = v
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'bootstrapping for chef-server' do
|
51
|
+
let(:custom_config) {
|
52
|
+
{
|
53
|
+
:bootstrap => true
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
describe 'should use the default bootstrap class' do
|
58
|
+
let(:subject) {
|
59
|
+
s = super()
|
60
|
+
s.client.stub_chain(:droplets, :create).and_return mock_api_response(api_response)
|
61
|
+
s.stub!(:ip_address_available).and_return '123.123.123.123'
|
62
|
+
s.stub!(:tcp_test_ssh).and_return true
|
63
|
+
s
|
64
|
+
}
|
65
|
+
|
66
|
+
it 'should use the right bootstrap class' do
|
67
|
+
subject.bootstrap_class.should eql(Chef::Knife::Bootstrap)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should call #run on the bootstrap class' do
|
71
|
+
Chef::Knife::Bootstrap.any_instance.stub(:run)
|
72
|
+
lambda { subject.run }.should_not raise_error(SystemExit)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'bootstrapping for knife-solo' do
|
78
|
+
|
79
|
+
let(:custom_config) {
|
80
|
+
{
|
81
|
+
:solo => true
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
describe 'when knife-solo is installed' do
|
86
|
+
before do
|
87
|
+
# simulate installed knife-solo gem
|
88
|
+
require 'chef/knife/solo_bootstrap'
|
89
|
+
end
|
90
|
+
|
91
|
+
let(:subject) {
|
92
|
+
s = super()
|
93
|
+
s.client.stub_chain(:droplets, :create).and_return mock_api_response(api_response)
|
94
|
+
s.stub!(:ip_address_available).and_return '123.123.123.123'
|
95
|
+
s.stub!(:tcp_test_ssh).and_return true
|
96
|
+
s
|
97
|
+
}
|
98
|
+
|
99
|
+
it 'should use the right bootstrap class' do
|
100
|
+
subject.bootstrap_class.should eql(Chef::Knife::SoloBootstrap)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should call #run on the bootstrap class' do
|
104
|
+
Chef::Knife::SoloBootstrap.any_instance.should_receive(:run)
|
105
|
+
Chef::Knife::Bootstrap.any_instance.should_not_receive(:run)
|
106
|
+
lambda { subject.run }.should_not raise_error(SystemExit)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe 'when knife-solo is not installed' do
|
111
|
+
before do
|
112
|
+
# simulate knife-solo gem is not installed
|
113
|
+
Chef::Knife.send(:remove_const, :SoloBootstrap) if defined?(Chef::Knife::SoloBootstrap)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should not create a droplet' do
|
117
|
+
subject.client.should_not_receive(:droplets)
|
118
|
+
lambda { subject.run }.should raise_error(SystemExit)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'no bootstrapping' do
|
125
|
+
let(:custom_config) {
|
126
|
+
{}
|
127
|
+
}
|
128
|
+
|
129
|
+
describe 'should not do any bootstrapping' do
|
130
|
+
let(:subject) {
|
131
|
+
s = super()
|
132
|
+
s.client.stub_chain(:droplets, :create).and_return mock_api_response(api_response)
|
133
|
+
s.stub!(:ip_address_available).and_return '123.123.123.123'
|
134
|
+
s.stub!(:tcp_test_ssh).and_return true
|
135
|
+
s
|
136
|
+
}
|
137
|
+
|
138
|
+
it 'should call #bootstrap_for_node' do
|
139
|
+
subject.should_not_receive(:bootstrap_for_node)
|
140
|
+
expect { subject.run }.to raise_error
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should have a 0 exit code' do
|
144
|
+
expect { subject.run }.to raise_error { |e|
|
145
|
+
e.status.should eql(0)
|
146
|
+
e.should be_a(SystemExit)
|
147
|
+
}
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
2
|
require 'rspec/autorun'
|
3
|
-
require 'knife-digital_ocean'
|
4
3
|
|
4
|
+
require 'digital_ocean'
|
5
|
+
require 'rash'
|
5
6
|
|
7
|
+
require 'chef/knife'
|
8
|
+
require 'chef/knife/digital_ocean_droplet_create'
|
9
|
+
require 'chef/knife/digital_ocean_droplet_destroy'
|
10
|
+
require 'chef/knife/digital_ocean_droplet_list'
|
11
|
+
require 'chef/knife/digital_ocean_image_list'
|
12
|
+
require 'chef/knife/digital_ocean_region_list'
|
13
|
+
require 'chef/knife/digital_ocean_size_list'
|
14
|
+
require 'chef/knife/digital_ocean_sshkey_list'
|
6
15
|
|
7
16
|
Dir['./spec/support/**/*.rb'].sort.each {|f| require f}
|
8
|
-
|
9
|
-
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-digital_ocean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Roland Moriz
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: chef
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: digital_ocean
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: highline
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,47 +48,41 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
56
|
+
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
70
|
-
type: :
|
61
|
+
version: '2.13'
|
62
|
+
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
68
|
+
version: '2.13'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
70
|
+
name: guard
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ! '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
|
-
version: '
|
75
|
+
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ! '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
82
|
+
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
|
-
name: guard
|
84
|
+
name: guard-rspec
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ! '>='
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,15 +90,13 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ! '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
98
|
+
name: rb-fsevent
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - ! '>='
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,15 +104,13 @@ dependencies:
|
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - ! '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
112
|
+
name: rake
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
115
|
- - ! '>='
|
132
116
|
- !ruby/object:Gem::Version
|
@@ -134,15 +118,13 @@ dependencies:
|
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
122
|
- - ! '>='
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: '0'
|
142
125
|
- !ruby/object:Gem::Dependency
|
143
|
-
name:
|
126
|
+
name: knife-solo
|
144
127
|
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
128
|
requirements:
|
147
129
|
- - ! '>='
|
148
130
|
- !ruby/object:Gem::Version
|
@@ -150,7 +132,6 @@ dependencies:
|
|
150
132
|
type: :development
|
151
133
|
prerelease: false
|
152
134
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
135
|
requirements:
|
155
136
|
- - ! '>='
|
156
137
|
- !ruby/object:Gem::Version
|
@@ -164,7 +145,9 @@ extra_rdoc_files: []
|
|
164
145
|
files:
|
165
146
|
- .gitignore
|
166
147
|
- .travis.yml
|
148
|
+
- CHANGELOG.md
|
167
149
|
- Gemfile
|
150
|
+
- Guardfile
|
168
151
|
- LICENSE.txt
|
169
152
|
- README.md
|
170
153
|
- Rakefile
|
@@ -179,37 +162,46 @@ files:
|
|
179
162
|
- lib/chef/knife/digital_ocean_sshkey_list.rb
|
180
163
|
- lib/knife-digital_ocean.rb
|
181
164
|
- lib/knife-digital_ocean/version.rb
|
165
|
+
- spec/lib/chef/knife/digital_ocean_droplet_create_spec.rb
|
166
|
+
- spec/lib/chef/knife/digital_ocean_droplet_destroy_spec.rb
|
167
|
+
- spec/lib/chef/knife/digital_ocean_droplet_list_spec.rb
|
168
|
+
- spec/lib/chef/knife/digital_ocean_image_list_spec.rb
|
169
|
+
- spec/lib/chef/knife/digital_ocean_region_list_spec.rb
|
170
|
+
- spec/lib/chef/knife/digital_ocean_size_list_spec.rb
|
171
|
+
- spec/lib/chef/knife/digital_ocean_sshkey_list_spec.rb
|
172
|
+
- spec/lib/knife-digital_ocean/version_spec.rb
|
182
173
|
- spec/spec_helper.rb
|
183
174
|
homepage: http://github.com/rmoriz/knife-digital_ocean
|
184
175
|
licenses:
|
185
176
|
- Apache 2.0
|
177
|
+
metadata: {}
|
186
178
|
post_install_message:
|
187
179
|
rdoc_options: []
|
188
180
|
require_paths:
|
189
181
|
- lib
|
190
182
|
required_ruby_version: !ruby/object:Gem::Requirement
|
191
|
-
none: false
|
192
183
|
requirements:
|
193
184
|
- - ! '>='
|
194
185
|
- !ruby/object:Gem::Version
|
195
186
|
version: '0'
|
196
|
-
segments:
|
197
|
-
- 0
|
198
|
-
hash: -3898868140226600481
|
199
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
|
-
none: false
|
201
188
|
requirements:
|
202
189
|
- - ! '>='
|
203
190
|
- !ruby/object:Gem::Version
|
204
191
|
version: '0'
|
205
|
-
segments:
|
206
|
-
- 0
|
207
|
-
hash: -3898868140226600481
|
208
192
|
requirements: []
|
209
193
|
rubyforge_project:
|
210
|
-
rubygems_version:
|
194
|
+
rubygems_version: 2.0.0
|
211
195
|
signing_key:
|
212
|
-
specification_version:
|
196
|
+
specification_version: 4
|
213
197
|
summary: A plugin for chef's knife to manage instances of DigitalOcean servers
|
214
198
|
test_files:
|
199
|
+
- spec/lib/chef/knife/digital_ocean_droplet_create_spec.rb
|
200
|
+
- spec/lib/chef/knife/digital_ocean_droplet_destroy_spec.rb
|
201
|
+
- spec/lib/chef/knife/digital_ocean_droplet_list_spec.rb
|
202
|
+
- spec/lib/chef/knife/digital_ocean_image_list_spec.rb
|
203
|
+
- spec/lib/chef/knife/digital_ocean_region_list_spec.rb
|
204
|
+
- spec/lib/chef/knife/digital_ocean_size_list_spec.rb
|
205
|
+
- spec/lib/chef/knife/digital_ocean_sshkey_list_spec.rb
|
206
|
+
- spec/lib/knife-digital_ocean/version_spec.rb
|
215
207
|
- spec/spec_helper.rb
|