knife-digital_ocean 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,10 +1,20 @@
1
1
  # Knife::DigitalOcean
2
+ ## A knife plugin to deal with the [DigitalOcean.com](https://www.digitalocean.com) Cloud services.
2
3
 
3
4
  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.
4
- You can also skip the chef bootstrapping if you prefer using [knife-solo](https://github.com/matschaffer/knife-solo) or some other solutions.
5
+ You can also skip the chef bootstrapping if you prefer using [knife-solo](https://github.com/matschaffer/knife-solo) or another solution.
6
+
7
+ This knife plugin uses the [digital_ocean](https://github.com/rmoriz/digital_ocean) rubygem.
8
+
9
+
5
10
  ## Installation
6
- $ # install chef
7
- $ gem install knife-digital_ocean
11
+
12
+ (chef needs to be installed upfront, of course)
13
+
14
+ ```shell
15
+ ➜ gem install knife-digital_ocean
16
+ ```
17
+
8
18
 
9
19
  ## Overview
10
20
 
@@ -31,6 +41,7 @@ This plugin provides the following sub-commands:
31
41
  * knife digital_ocean sshkey list
32
42
  **Lists name + id of the uploaded known ssh keys**
33
43
 
44
+
34
45
  ## Configuration
35
46
 
36
47
  The best way is to put your API-credentials of DigitalOcean in your knife.rb file of choice:
@@ -48,53 +59,168 @@ knife[:digital_ocean_api_key] = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
48
59
 
49
60
  __Example__
50
61
 
51
- ```bash
52
- knife digital_ocean droplet create --server-name awesome-vm1.chef.io \
53
- --image 25306 \
54
- --location 2 \
55
- --size 66 \
56
- --ssh-keys 1234,4567 \
57
- --bootstrap \
58
- --run-list "role[base],role[webserver]"
62
+ ```shell
63
+ knife digital_ocean droplet create --server-name awesome-vm1.chef.io \
64
+ --image 25306 \
65
+ --location 2 \
66
+ --size 66 \
67
+ --ssh-keys 1234,1235 \
68
+ --bootstrap \
69
+ --run-list "role[base],role[webserver]"
59
70
  ```
60
71
 
61
72
  __Syntax__
62
- ```bash
63
- knife digital_ocean droplet create --server-name <FQDN> \
64
- --image <IMAGE ID> \
65
- --location <REGION ID> \
66
- --size <SIZE ID> \
67
- --ssh-keys <SSH KEY-ID(s), comma-separated> \
68
- --bootstrap \
69
- --run-list "<RUNLIST>"
73
+
74
+ ```shell
75
+ ➜ knife digital_ocean droplet create --server-name <FQDN> \
76
+ --image <IMAGE ID> \
77
+ --location <REGION ID> \
78
+ --size <SIZE ID> \
79
+ --ssh-keys <SSH KEY-ID(s), comma-separated> \
80
+ --bootstrap \
81
+ --run-list "<RUNLIST>"
70
82
  ```
71
83
 
72
84
  __Short Syntax__
73
- ```bash
74
- knife digital_ocean droplet create --N <FQDN> \
75
- --I <IMAGE ID> \
76
- --L <REGION ID> \
77
- --S <SIZE ID> \
78
- --K <SSH KEY-ID(s), comma-separated> \
79
- --B \
80
- --r "<RUNLIST>"
81
- ```
82
85
 
86
+ ```shell
87
+ ➜ knife digital_ocean droplet create --N <FQDN> \
88
+ --I <IMAGE ID> \
89
+ --L <REGION ID> \
90
+ --S <SIZE ID> \
91
+ --K <SSH KEY-ID(s), comma-separated> \
92
+ --B \
93
+ --r "<RUNLIST>"
94
+ ```
83
95
 
84
96
  #### With knife-solo, your custom external bootstrapping script or without chef at all
85
97
 
86
- This will just create a droplet and returns its IP-address no other actions are done. You can now run your custom solution e.g. ```knife solo bootstrap <IP> ```
98
+ This will just create a droplet and return its IP-address. Nothing else. You can now run your custom solution to provision the droplet e.g. ```knife solo bootstrap <IP> ``` if you use knife-solo.
99
+
87
100
  __Example__
88
101
 
89
102
  ```bash
90
- knife digital_ocean droplet create --server-name awesome-vm1.chef.io \
91
- --image 25306 \
92
- --location 2 \
93
- --size 66 \
94
- --ssh-keys 1234,4567
103
+ knife digital_ocean droplet create --server-name awesome-vm1.chef.io \
104
+ --image 25306 \
105
+ --location 2 \
106
+ --size 66 \
107
+ --ssh-keys 1234,4567
108
+ ```
109
+
110
+ ### List running droplets (servers)
111
+
112
+ ```shell
113
+ ➜ knife digital_ocean droplet list
114
+ ID Name Size Region IPv4 Image Status
115
+ 12345 app20.ams.nl.chef.io 1GB Amsterdam 1 185.14.123.123 25306 (Ubuntu 12.10 x32 Server) active
116
+ 23456 awesome-vm1.chef.io 512MB Amsterdam 1 185.14.124.125 25306 (Ubuntu 12.10 x32 Server) active
117
+ ```
118
+
119
+ ### Destroy a droplet (server) including all of its data!
120
+
121
+ ```shell
122
+ ➜ knife digital_ocean droplet destroy -S 23456
123
+ OK
124
+ ```
125
+
126
+ ### List regions (servers)
127
+
128
+ ```shell
129
+ ➜ knife digital_ocean region list
130
+ ID Name
131
+ 1 New York 1
132
+ 2 Amsterdam 1
133
+ ```
134
+
135
+ ### List sizes (server types)
136
+
137
+ ```shell
138
+ ➜ knife digital_ocean size list
139
+ ID Name
140
+ 63 1GB
141
+ 62 2GB
142
+ 64 4GB
143
+ 65 8GB
144
+ 61 16GB
145
+ 60 32GB
146
+ 70 48GB
147
+ 69 64GB
148
+ 68 96GB
149
+ 66 512MB
150
+ ```
151
+
152
+ ### List images
153
+
154
+ #### Custom images (snapshots, backups) (default)
155
+
156
+ ```shell
157
+ ➜ knife digital_ocean image list
158
+ ID Distribution Name Global
159
+ 11111 Ubuntu app100.ams.nlxxxxx.net 2013-02-01 -
160
+ 11112 Ubuntu app100.ams.nlxxxxx.net 2013-02-03 -
161
+ 11113 Ubuntu init -
162
+ ```
163
+
164
+
165
+ #### Global images (OS)
166
+
167
+ ```shell
168
+ ➜ knife digital_ocean image list --global
169
+ ID Distribution Name Global
170
+ 23593 Arch Linux Arch Linux 2012-09 x64 +
171
+ 1602 CentOS CentOS 5.8 x32 +
172
+ 1601 CentOS CentOS 5.8 x64 +
173
+ 1605 CentOS CentOS 6.0 x32 +
174
+ 1611 CentOS CentOS 6.2 x64 +
175
+ 12578 CentOS CentOS 6.3 x32 +
176
+ 12574 CentOS CentOS 6.3 x64 +
177
+ 12575 Debian Debian 6.0 x32 +
178
+ 12573 Debian Debian 6.0 x64 +
179
+ 1606 Fedora Fedora 15 x64 +
180
+ 1618 Fedora Fedora 16 x64 Desktop +
181
+ 1615 Fedora Fedora 16 x64 Server +
182
+ 32399 Fedora Fedora 17 x32 Desktop +
183
+ 32387 Fedora Fedora 17 x32 Server +
184
+ 32419 Fedora Fedora 17 x64 Desktop +
185
+ 32428 Fedora Fedora 17 x64 Server +
186
+ 63749 Gentoo Gentoo 2013-1 x64 +
187
+ 1607 Gentoo Gentoo x64 +
188
+ 46964 Ubuntu LAMP on Ubuntu 12.04 +
189
+ 4870 Ubuntu Rails 3.2.2 - Nginx MySQL Passenger +
190
+ 14098 Ubuntu Ubuntu 10.04 x32 Server +
191
+ 14097 Ubuntu Ubuntu 10.04 x64 Server +
192
+ 43462 Ubuntu Ubuntu 11.04x32 Desktop +
193
+ 43458 Ubuntu Ubuntu 11.04x64 Server +
194
+ 1609 Ubuntu Ubuntu 11.10 x32 Server +
195
+ 42735 Ubuntu Ubuntu 12.04 x32 Server +
196
+ 14218 Ubuntu Ubuntu 12.04 x64 Desktop +
197
+ 2676 Ubuntu Ubuntu 12.04 x64 Server +
198
+ 25485 Ubuntu Ubuntu 12.10 x32 Desktop +
199
+ 25306 Ubuntu Ubuntu 12.10 x32 Server +
200
+ 25493 Ubuntu Ubuntu 12.10 x64 Desktop +
201
+ 25489 Ubuntu Ubuntu 12.10 x64 Server +
202
+ 13632 openSUSE Open Suse 12.1 x32 +
203
+ 13863 openSUSE Open Suse 12.2 X64 +
95
204
  ```
96
205
 
97
206
 
207
+ ### SSH keys (previously uploaded via DigitalOcean's webfrontend)
208
+
209
+ ```shell
210
+ ➜ knife digital_ocean sshkey list
211
+ ID Name
212
+ 1234 Alice
213
+ 1235 Bob
214
+ 1236 Chuck
215
+ 1237 Craig
216
+ ```
217
+
218
+
219
+ ## Commercial Support
220
+
221
+ Commercial support is available. Please contact [https://roland.io/](https://roland.io/) or [http://moriz.com/](http://moriz.com/)
222
+
223
+
98
224
  ## Contributing
99
225
 
100
226
  1. Fork it
@@ -102,3 +228,13 @@ knife digital_ocean droplet create --server-name awesome-vm1.chef.io \
102
228
  3. Commit your changes (`git commit -am 'Add some feature'`)
103
229
  4. Push to the branch (`git push origin my-new-feature`)
104
230
  5. Create new Pull Request
231
+
232
+
233
+ ## License
234
+
235
+ Apache 2.0 (like Chef itself), see LICENSE.txt file.
236
+
237
+
238
+ ## Copyright
239
+
240
+ Copyright © 2013 [Roland Moriz](https://roland.io), [Moriz GmbH](https://moriz.de/)
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = 'http://github.com/rmoriz/knife-digital_ocean'
14
14
  gem.license = 'Apache 2.0'
15
15
 
16
- gem.add_dependency 'chef', '~> 10.18'
16
+ gem.add_dependency 'chef', '>= 10.18'
17
17
  gem.add_dependency 'digital_ocean'
18
18
  gem.add_dependency 'highline'
19
19
  gem.add_dependency 'net-ssh-multi', '~> 1.1'
@@ -43,7 +43,6 @@ class Chef
43
43
  :description => 'DigitalOcean Location (Region)',
44
44
  :proc => Proc.new { |location| Chef::Config[:knife][:location] = location }
45
45
 
46
- # FIXME splitting + kniferb
47
46
  option :ssh_key_ids,
48
47
  :short => '-K KEYID',
49
48
  :long => '--ssh-keys KEY_ID',
@@ -69,18 +68,18 @@ class Chef
69
68
  :default => 'root'
70
69
 
71
70
  option :distro,
72
- :short => '-d DISTRO',
73
- :long => '--distro DISTRO',
74
- :description => 'Chef-Bootstrap a distro using a template; default is "ubuntu10.04-gems"',
75
- :proc => Proc.new { |d| Chef::Config[:knife][:distro] = d },
76
- :default => 'chef-full'
71
+ :short => '-d DISTRO',
72
+ :long => '--distro DISTRO',
73
+ :description => 'Chef-Bootstrap a distro using a template; default is "chef-full"',
74
+ :proc => Proc.new { |d| Chef::Config[:knife][:distro] = d },
75
+ :default => 'chef-full'
77
76
 
78
77
  option :run_list,
79
- :short => '-r RUN_LIST',
80
- :long => '--run-list RUN_LIST',
78
+ :short => '-r RUN_LIST',
79
+ :long => '--run-list RUN_LIST',
81
80
  :description => 'Comma separated list of roles/recipes to apply',
82
- :proc => lambda { |o| o.split(/[\s,]+/) },
83
- :default => []
81
+ :proc => lambda { |o| o.split(/[\s,]+/) },
82
+ :default => []
84
83
 
85
84
  def run
86
85
  $stdout.sync = true
@@ -88,27 +87,27 @@ class Chef
88
87
  validate!
89
88
 
90
89
  unless locate_config_value(:server_name)
91
- ui.error("Server Name cannot be empty: -N <servername>")
90
+ ui.error('Server Name cannot be empty: -N <servername>')
92
91
  exit 1
93
92
  end
94
93
 
95
94
  unless locate_config_value(:image)
96
- ui.error("Image cannot be empty: -I <image>")
95
+ ui.error('Image cannot be empty: -I <image>')
97
96
  exit 1
98
97
  end
99
98
 
100
99
  unless locate_config_value(:size)
101
- ui.error("Size cannot be empty: -S <size>")
100
+ ui.error('Size cannot be empty: -S <size>')
102
101
  exit 1
103
102
  end
104
103
 
105
104
  unless locate_config_value(:location)
106
- ui.error("Location cannot be empty: -L <region>")
105
+ ui.error('Location cannot be empty: -L <region>')
107
106
  exit 1
108
107
  end
109
108
 
110
109
  unless locate_config_value(:ssh_key_ids)
111
- ui.error("One or more DigitalOcean SSH key ids missing: -K <KEY1>, <KEY2> ...")
110
+ ui.error('One or more DigitalOcean SSH key ids missing: -K <KEY1>, <KEY2> ...')
112
111
  exit 1
113
112
  end
114
113
 
@@ -118,21 +117,21 @@ class Chef
118
117
  :region_id => locate_config_value(:location),
119
118
  :ssh_key_ids => locate_config_value(:ssh_key_ids).join(','))
120
119
 
121
- if response.status != "OK"
120
+ if response.status != 'OK'
122
121
  ui.error("Droplet could not be started #{response.inspect}")
123
122
  exit 1
124
123
  end
125
124
 
126
125
  puts "Droplet creation for #{locate_config_value(:server_name)} started. Droplet-ID is #{response.droplet.id}"
127
126
 
128
- print "\n#{ui.color("Waiting for IPv4-Address", :magenta)}"
127
+ print ui.color("Waiting for IPv4-Address", :magenta)
129
128
  print(".") until ip_address = ip_address_available(response.droplet.id) {
130
129
  puts 'done'
131
130
  }
132
131
 
133
132
  puts ui.color("IPv4 address is: #{ip_address}", :green)
134
133
 
135
- print ui.color("Waiting for sshd:", :magenta)
134
+ print ui.color('Waiting for sshd:', :magenta)
136
135
  print('.') until tcp_test_ssh(ip_address, 22) {
137
136
  sleep 2
138
137
  puts 'done'
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module DigitalOcean
3
- VERSION = "0.0.1"
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-digital_ocean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-03 00:00:00.000000000 Z
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '10.18'
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '10.18'
30
30
  - !ruby/object:Gem::Dependency
@@ -195,7 +195,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  segments:
197
197
  - 0
198
- hash: 3713788869412067883
198
+ hash: 4541186248648249517
199
199
  required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  none: false
201
201
  requirements:
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  version: '0'
205
205
  segments:
206
206
  - 0
207
- hash: 3713788869412067883
207
+ hash: 4541186248648249517
208
208
  requirements: []
209
209
  rubyforge_project:
210
210
  rubygems_version: 1.8.23