knife-joyent 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +8 -0
- data/Gemfile +2 -0
- data/README.md +31 -11
- data/knife-joyent.gemspec +1 -1
- data/lib/chef/knife/joyent_base.rb +14 -1
- data/lib/chef/knife/joyent_network_list.rb +28 -0
- data/lib/chef/knife/joyent_server_create.rb +22 -9
- data/lib/chef/knife/joyent_server_delete.rb +1 -1
- data/lib/knife-joyent/version.rb +1 -1
- metadata +7 -4
data/CHANGES.md
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Knife Joyent
|
2
2
|
===
|
3
3
|
|
4
|
-
This is a [Knife](http://wiki.opscode.com/display/chef/Knife)
|
4
|
+
This is a [Knife](http://wiki.opscode.com/display/chef/Knife) plug-in for Joyent CloudAPI. This plug-in gives knife
|
5
5
|
the ability to create, bootstrap, and manage servers on the [Joyent Public Cloud](http://www.joyentcloud.com/) as well as Cloud providers powered by Joyent's [SmartDataCenter](http://www.joyent.com/products/smartdatacenter/) product offering.
|
6
6
|
|
7
7
|
For more information on Joyent CloudAPI, see: [CloudAPI Documentation](http://api.joyentcloud.com/docs)
|
@@ -25,6 +25,7 @@ Currently available commands:
|
|
25
25
|
knife joyent key add -f <keyfile> -k <name>
|
26
26
|
knife joyent key delete <name>
|
27
27
|
knife joyent key list
|
28
|
+
knife joyent network list
|
28
29
|
knife joyent server create (options)
|
29
30
|
knife joyent server delete <server_id>
|
30
31
|
knife joyent server list <options>
|
@@ -63,20 +64,30 @@ The following options can be specified in your knife configuration file
|
|
63
64
|
|
64
65
|
You can authenticate against CloudAPI using either:
|
65
66
|
|
66
|
-
|
67
|
+
an ssh key (recommended)
|
67
68
|
|
68
69
|
knife[:joyent_username] = "Your Joyent CloudAPI username"
|
69
|
-
knife[:
|
70
|
+
knife[:joyent_keyname] = "Name of key stored on Joyent"
|
71
|
+
knife[:joyent_keyfile] = "/path/to/your/private/key"
|
70
72
|
|
71
|
-
|
73
|
+
# Optional / not-recommended -- defaults to using ssh-agent
|
74
|
+
knife[:joyent_keyphrase] = "mypassphrase"
|
75
|
+
|
76
|
+
or username and password
|
72
77
|
|
73
78
|
knife[:joyent_username] = "Your Joyent CloudAPI username"
|
74
|
-
knife[:
|
75
|
-
|
79
|
+
knife[:joyent_password] = "Your Joyent CloudAPI password"
|
80
|
+
|
81
|
+
When authenticating with your ssh key (which we highly recommend), knife-joyent will
|
82
|
+
attempt to use ssh-agent to sign the request using the key configured with
|
83
|
+
``knife[:joyent_keyname]``. If no ssh-agent is present or if the specified identity
|
84
|
+
isn't found in the agent, you may be prompted for a pass-phrase. If you do not want
|
85
|
+
to use an ``ssh-agent``, you may optionally configure ``knife[:joyent_passphrase]``
|
86
|
+
to automatically unlock the key for authentication.
|
76
87
|
|
77
|
-
#### Optional
|
88
|
+
#### Optional Configuration
|
78
89
|
|
79
|
-
|
90
|
+
**``joyent_api_url``**
|
80
91
|
|
81
92
|
Specify a custom API endpoint, this is required if you want to specify
|
82
93
|
where you want to provision your machines, or if you are using knife with a
|
@@ -85,7 +96,7 @@ provider powered by [SmartDataCenter](http://www.joyent.com/products/smartdatace
|
|
85
96
|
# Defaults to https://us-west-1.api.joyentcloud.com/
|
86
97
|
knife[:joyent_api_url] = "https://us-sw-1.api.joyentcloud.com/"
|
87
98
|
|
88
|
-
|
99
|
+
**``joyent_metadata``**
|
89
100
|
|
90
101
|
Metadata to apply to each provisioned machine via the Metadata API. This should take
|
91
102
|
the form of a hash with a single level of nesting. See the
|
@@ -95,7 +106,16 @@ the form of a hash with a single level of nesting. See the
|
|
95
106
|
"some_data" => "value"
|
96
107
|
}
|
97
108
|
|
98
|
-
|
109
|
+
**``joyent_version``**
|
110
|
+
|
111
|
+
By default, knife-joyent will use the version of the Joyent Cloud API that fog prefers. This
|
112
|
+
can be overridden in knife.rb as follows:
|
113
|
+
|
114
|
+
knife[:joyent_version] = "~7.0"
|
115
|
+
|
116
|
+
Some command line options to knife-joyent subcommands may depend on the Joyent API version set.
|
117
|
+
|
118
|
+
**``provisioner``**
|
99
119
|
|
100
120
|
Machines provisioned will be tagged with key ``provisioner`` containing the value specified.
|
101
121
|
This is useful for tracking source of provisions for accounts where machines are provisioned
|
@@ -104,7 +124,7 @@ by/from different sources / users.
|
|
104
124
|
## Contributors
|
105
125
|
|
106
126
|
- [Sean Omera](https://github.com/someara) - Opscode
|
107
|
-
- [Eric Saxby](https://github.com/sax) -
|
127
|
+
- [Eric Saxby](https://github.com/sax) - Wanelo
|
108
128
|
- [Stephen Lauck](https://github.com/stephenlauck) - ModCloth
|
109
129
|
|
110
130
|
## Bootstrap template for smartos
|
data/knife-joyent.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.add_dependency "fog", "~> 1.
|
19
|
+
s.add_dependency "fog", "~> 1.12.1"
|
20
20
|
s.add_dependency "multi_json", "~> 1.7"
|
21
21
|
s.add_dependency "chef", ">= 0.10.10"
|
22
22
|
s.require_paths = ["lib"]
|
@@ -35,11 +35,21 @@ class Chef
|
|
35
35
|
:description => 'path to ssh private key for signature auth',
|
36
36
|
:proc => Proc.new {|key| Chef::Config[:knife][:joyent_keyfile] = key }
|
37
37
|
|
38
|
+
option :joyent_keyphrase,
|
39
|
+
:long => '--joyent-keyphrase <passpharse>',
|
40
|
+
:description => 'ssh passphrase to use if no ssh-agent is present',
|
41
|
+
:proc => Proc.new {|key| Chef::Config[:knife][:joyent_keyphrase] = key }
|
42
|
+
|
38
43
|
option :joyent_api_url,
|
39
44
|
:short => "-L JOYENT_API_URL",
|
40
45
|
:long => "--joyent-api-url JOYENT_API_URL",
|
41
46
|
:description => "Joyent API URL",
|
42
47
|
:proc => Proc.new {|key| Chef::Config[:knife][:joyent_api_url] = key }
|
48
|
+
|
49
|
+
option :joyent_version,
|
50
|
+
:long => "--joyent-api-version JOYENT_API_VERSION",
|
51
|
+
:description => "Joyent API version",
|
52
|
+
:proc => Proc.new {|key| Chef::Config[:knife][:joyent_version] = key }
|
43
53
|
end
|
44
54
|
end
|
45
55
|
|
@@ -51,7 +61,10 @@ class Chef
|
|
51
61
|
:joyent_password => Chef::Config[:knife][:joyent_password],
|
52
62
|
:joyent_keyname => Chef::Config[:knife][:joyent_keyname],
|
53
63
|
:joyent_keyfile => Chef::Config[:knife][:joyent_keyfile],
|
54
|
-
|
64
|
+
|
65
|
+
:joyent_url => Chef::Config[:knife][:joyent_api_url],
|
66
|
+
:joyent_version => Chef::Config[:knife][:joyent_version]
|
67
|
+
|
55
68
|
)
|
56
69
|
end
|
57
70
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'chef/knife/joyent_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class JoyentNetworkList < Knife
|
6
|
+
include Knife::JoyentBase
|
7
|
+
|
8
|
+
banner "knife joyent network list"
|
9
|
+
|
10
|
+
def run
|
11
|
+
networks = [
|
12
|
+
ui.color('ID', :bold),
|
13
|
+
ui.color('Name', :bold),
|
14
|
+
ui.color(''),
|
15
|
+
]
|
16
|
+
|
17
|
+
self.connection.networks.each do |network|
|
18
|
+
networks << network.id
|
19
|
+
networks << network.name
|
20
|
+
networks << (network.public ? 'public' : 'private')
|
21
|
+
end
|
22
|
+
|
23
|
+
puts ui.list(networks, :uneven_columns_across, 3)
|
24
|
+
exit 0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -51,6 +51,13 @@ class Chef
|
|
51
51
|
:proc => lambda { |o| JSON.parse(o) },
|
52
52
|
:default => {}
|
53
53
|
|
54
|
+
option :networks,
|
55
|
+
:short => "-w NETWORKS",
|
56
|
+
:long => "--networks NETWORKS",
|
57
|
+
:description => "Comma separated list of networks to attach (currently requires API version >= 7.0 in knife.rb)",
|
58
|
+
:proc => lambda { |n| n.split(/[\s,]+/)},
|
59
|
+
:default => nil
|
60
|
+
|
54
61
|
option :private_network,
|
55
62
|
:long => "--private-network",
|
56
63
|
:description => "Use the private IP for bootstrapping rather than the public IP",
|
@@ -129,15 +136,11 @@ class Chef
|
|
129
136
|
|
130
137
|
validate_server_name
|
131
138
|
|
132
|
-
node_name = config[:chef_node_name] || config[:server_name]
|
139
|
+
@node_name = config[:chef_node_name] || config[:server_name]
|
133
140
|
|
134
|
-
puts ui.color("Creating machine #{node_name}", :cyan)
|
141
|
+
puts ui.color("Creating machine #{@node_name}", :cyan)
|
135
142
|
|
136
|
-
server = connection.servers.create(
|
137
|
-
:name => node_name,
|
138
|
-
:dataset => config[:dataset],
|
139
|
-
:package => config[:package]
|
140
|
-
}.merge(joyent_metadata))
|
143
|
+
server = connection.servers.create(server_creation_options)
|
141
144
|
|
142
145
|
puts ui.color("Waiting for Server to be Provisioned", :magenta)
|
143
146
|
server.wait_for { print "."; ready? }
|
@@ -164,7 +167,7 @@ class Chef
|
|
164
167
|
tags << k
|
165
168
|
tags << v
|
166
169
|
end
|
167
|
-
puts ui.color("Updated tags for #{node_name}", :cyan)
|
170
|
+
puts ui.color("Updated tags for #{@node_name}", :cyan)
|
168
171
|
puts ui.list(tags, :uneven_columns_across, 2)
|
169
172
|
else
|
170
173
|
puts ui.color("No user defined in knife config for provision tagging -- continuing", :magenta)
|
@@ -176,7 +179,7 @@ class Chef
|
|
176
179
|
msg_pair("State", server.state)
|
177
180
|
msg_pair("Type", server.type)
|
178
181
|
msg_pair("Dataset", server.dataset)
|
179
|
-
msg_pair("
|
182
|
+
msg_pair("IPs", server.ips.join(" "))
|
180
183
|
msg_pair("JSON Attributes",config[:json_attributes]) unless config[:json_attributes].empty?
|
181
184
|
|
182
185
|
puts ui.color("Waiting for server to fully initialize...", :cyan)
|
@@ -263,6 +266,16 @@ class Chef
|
|
263
266
|
|
264
267
|
private
|
265
268
|
|
269
|
+
def server_creation_options
|
270
|
+
o = {
|
271
|
+
:name => @node_name,
|
272
|
+
:dataset => config[:dataset],
|
273
|
+
:package => config[:package]
|
274
|
+
}.merge!(joyent_metadata)
|
275
|
+
o.merge!(:networks => config[:networks]) if config[:networks]
|
276
|
+
o
|
277
|
+
end
|
278
|
+
|
266
279
|
def validate_server_name
|
267
280
|
# add some validation here ala knife-ec2
|
268
281
|
unless config[:server_name] || config[:chef_node_name]
|
data/lib/knife-joyent/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-joyent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.12.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.12.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: multi_json
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,6 +69,7 @@ extra_rdoc_files:
|
|
69
69
|
- LICENSE
|
70
70
|
files:
|
71
71
|
- .gitignore
|
72
|
+
- CHANGES.md
|
72
73
|
- Gemfile
|
73
74
|
- LICENSE
|
74
75
|
- README.md
|
@@ -80,6 +81,7 @@ files:
|
|
80
81
|
- lib/chef/knife/joyent_key_add.rb
|
81
82
|
- lib/chef/knife/joyent_key_delete.rb
|
82
83
|
- lib/chef/knife/joyent_key_list.rb
|
84
|
+
- lib/chef/knife/joyent_network_list.rb
|
83
85
|
- lib/chef/knife/joyent_server_create.rb
|
84
86
|
- lib/chef/knife/joyent_server_delete.rb
|
85
87
|
- lib/chef/knife/joyent_server_list.rb
|
@@ -122,3 +124,4 @@ signing_key:
|
|
122
124
|
specification_version: 3
|
123
125
|
summary: Joyent CloudAPI Support for Chef's Knife Command
|
124
126
|
test_files: []
|
127
|
+
has_rdoc: true
|