knife-clodo 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/knife-clodo.gemspec +2 -2
- data/lib/chef/knife/bootstrap/debian6apt.erb +1 -1
- data/lib/chef/knife/clodo_base.rb +7 -21
- data/lib/chef/knife/clodo_server_create.rb +22 -27
- metadata +9 -11
data/knife-clodo.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'knife-clodo'
|
3
|
-
spec.version = '0.1.
|
3
|
+
spec.version = '0.1.4'
|
4
4
|
spec.summary = 'Clodo.Ru knife plugin'
|
5
|
-
spec.add_dependency('fog', '>= 0.
|
5
|
+
spec.add_dependency('fog', '>= 0.11.0')
|
6
6
|
spec.description = <<-EOF
|
7
7
|
Knife plugin for Clodo.Ru cloud provider.
|
8
8
|
EOF
|
@@ -1,7 +1,7 @@
|
|
1
1
|
bash -c '
|
2
2
|
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
|
3
3
|
|
4
|
-
while [ -e /var/adm/autoinstall/init.d/* ] do
|
4
|
+
while [ -d /var/adm/autoinstall/init.d -a -e /var/adm/autoinstall/init.d/* ] do
|
5
5
|
echo "Autoinstallation still in progress. Waiting 5sec...";
|
6
6
|
sleep 5;
|
7
7
|
done
|
@@ -18,44 +18,30 @@ class Chef
|
|
18
18
|
option :clodo_api_key,
|
19
19
|
:short => "-K KEY",
|
20
20
|
:long => "--clodo-api-key KEY",
|
21
|
-
:description => "Your clodo.ru API key"
|
22
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:clodo_api_key] = key }
|
21
|
+
:description => "Your clodo.ru API key"
|
23
22
|
|
24
23
|
option :clodo_username,
|
25
24
|
:short => "-A USERNAME",
|
26
25
|
:long => "--clodo-username USERNAME",
|
27
|
-
:description => "Your clodo.ru API username"
|
28
|
-
:proc => Proc.new { |username| Chef::Config[:knife][:clodo_username] = username }
|
26
|
+
:description => "Your clodo.ru API username"
|
29
27
|
|
30
28
|
option :clodo_api_auth_url,
|
31
29
|
:long => "--clodo-api-auth-url URL",
|
32
|
-
:description => "Your clodo.ru API auth url"
|
33
|
-
:default => "api.clodo.ru",
|
34
|
-
:proc => Proc.new { |url| Chef::Config[:knife][:clodo_api_auth_url] = url }
|
30
|
+
:description => "Your clodo.ru API auth url"
|
35
31
|
end
|
36
32
|
|
37
33
|
def connection
|
38
34
|
@connection ||= Fog::Compute::Clodo.new({
|
39
|
-
:clodo_api_key
|
40
|
-
:clodo_username => (
|
41
|
-
:clodo_auth_url =>
|
35
|
+
:clodo_api_key => locate_config_value(:clodo_api_key),
|
36
|
+
:clodo_username => locate_config_value(:clodo_username),
|
37
|
+
:clodo_auth_url => locate_config_value(:clodo_api_auth_url) || 'api.clodo.ru'})
|
42
38
|
end
|
43
39
|
|
44
40
|
def locate_config_value(key)
|
45
41
|
key = key.to_sym
|
46
|
-
Chef::Config[:knife][key]
|
42
|
+
config[key] || Chef::Config[:knife][key]
|
47
43
|
end
|
48
|
-
|
49
|
-
def public_dns_name(server)
|
50
|
-
@public_dns_name ||= begin
|
51
|
-
Resolv.getname(server.public_ip_address)
|
52
|
-
rescue
|
53
|
-
"#{server.public_ip_address.gsub('.','-')}.clodo.ru"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
44
|
end
|
58
|
-
|
59
45
|
end
|
60
46
|
end
|
61
47
|
end
|
@@ -84,8 +84,7 @@ class Chef
|
|
84
84
|
|
85
85
|
option :bootstrap_version,
|
86
86
|
:long => "--bootstrap-version VERSION",
|
87
|
-
:description => "The version of Chef to install"
|
88
|
-
:proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
|
87
|
+
:description => "The version of Chef to install"
|
89
88
|
|
90
89
|
option :bootstrap_delay,
|
91
90
|
:long => "--bootstrap-delay SEC",
|
@@ -96,22 +95,14 @@ class Chef
|
|
96
95
|
:long => "--prerelease",
|
97
96
|
:description => "Install the pre-release chef gems"
|
98
97
|
|
99
|
-
option :bootstrap_version,
|
100
|
-
:long => "--bootstrap-version VERSION",
|
101
|
-
:description => "The version of Chef to install",
|
102
|
-
:proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
|
103
|
-
|
104
98
|
option :distro,
|
105
99
|
:short => "-d DISTRO",
|
106
100
|
:long => "--distro DISTRO",
|
107
|
-
:description => "Bootstrap a distro using a template; default is 'debian6apt'"
|
108
|
-
:proc => Proc.new { |d| Chef::Config[:knife][:distro] = d },
|
109
|
-
:default => "debian6apt"
|
101
|
+
:description => "Bootstrap a distro using a template; default is 'debian6apt'"
|
110
102
|
|
111
103
|
option :template_file,
|
112
104
|
:long => "--template-file TEMPLATE",
|
113
105
|
:description => "Full path to location of template to use",
|
114
|
-
:proc => Proc.new { |t| Chef::Config[:knife][:template_file] = t },
|
115
106
|
:default => false
|
116
107
|
|
117
108
|
option :run_list,
|
@@ -127,7 +118,6 @@ class Chef
|
|
127
118
|
if readable
|
128
119
|
Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")
|
129
120
|
yield
|
130
|
-
true
|
131
121
|
else
|
132
122
|
false
|
133
123
|
end
|
@@ -149,21 +139,21 @@ class Chef
|
|
149
139
|
def run
|
150
140
|
$stdout.sync = true
|
151
141
|
|
152
|
-
unless
|
142
|
+
unless locate_config_value(:image)
|
153
143
|
ui.error("You have not provided a valid image value. Please note the short option for this value recently changed from '-i' to '-I'.")
|
154
144
|
exit 1
|
155
145
|
end
|
156
146
|
|
157
147
|
options = {
|
158
|
-
:vps_type
|
159
|
-
:vps_memory
|
160
|
-
:vps_memory_max =>
|
161
|
-
:vps_hdd
|
162
|
-
:vps_admin
|
163
|
-
:vps_os
|
148
|
+
:vps_type => locate_config_value(:server_type),
|
149
|
+
:vps_memory => locate_config_value(:server_memory),
|
150
|
+
:vps_memory_max => locate_config_value(:server_memory_max),
|
151
|
+
:vps_hdd => locate_config_value(:server_disk),
|
152
|
+
:vps_admin => locate_config_value(:server_support_level),
|
153
|
+
:vps_os => locate_config_value(:image)
|
164
154
|
}
|
165
155
|
|
166
|
-
options[:
|
156
|
+
options[:vps_title] = config[:server_name] if config[:server_name]
|
167
157
|
|
168
158
|
server = connection.servers.create(options)
|
169
159
|
|
@@ -176,25 +166,28 @@ class Chef
|
|
176
166
|
print "\n#{ui.color("Waiting server", :magenta)}"
|
177
167
|
|
178
168
|
# wait for it to be ready to do stuff
|
179
|
-
server.wait_for
|
169
|
+
server.wait_for(600, 10) do print "."; ready? end
|
180
170
|
|
181
171
|
puts("\n")
|
182
172
|
|
183
|
-
puts "#{ui.color("Public DNS Name", :cyan)}: #{public_dns_name(server)}"
|
184
173
|
puts "#{ui.color("Public IP Address", :cyan)}: #{server.public_ip_address}"
|
185
174
|
puts "#{ui.color("Password", :cyan)}: #{server.password}"
|
186
175
|
|
187
176
|
print "\n#{ui.color("Waiting for sshd", :magenta)}"
|
188
177
|
|
189
|
-
print(".") until tcp_test_ssh(server.public_ip_address) { sleep @initial_sleep_delay ||= config[:bootstrap_delay].to_i;
|
178
|
+
print(".") until tcp_test_ssh(server.public_ip_address) { sleep @initial_sleep_delay ||= config[:bootstrap_delay].to_i; true; }
|
179
|
+
|
180
|
+
if File::exists? "#{ENV['HOME']}/.ssh/id_rsa.pub"
|
181
|
+
server.public_key_path = "#{ENV['HOME']}/.ssh/id_rsa.pub"
|
182
|
+
server.setup({:password => server.password})
|
183
|
+
end
|
190
184
|
|
191
|
-
bootstrap_for_node(server).run
|
185
|
+
bootstrap_for_node(server).run if locate_config_value(:distro) || locate_config_value(:template_file)
|
192
186
|
|
193
187
|
puts "\n"
|
194
188
|
puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
|
195
189
|
puts "#{ui.color("Name", :cyan)}: #{server.name}"
|
196
190
|
puts "#{ui.color("Image", :cyan)}: #{server.image}"
|
197
|
-
puts "#{ui.color("Public DNS Name", :cyan)}: #{public_dns_name(server)}"
|
198
191
|
puts "#{ui.color("Public IP Address", :cyan)}: #{server.public_ip_address}"
|
199
192
|
puts "#{ui.color("Password", :cyan)}: #{server.password}"
|
200
193
|
puts "#{ui.color("Environment", :cyan)}: #{config[:environment] || '_default'}"
|
@@ -203,7 +196,7 @@ class Chef
|
|
203
196
|
|
204
197
|
def bootstrap_for_node(server)
|
205
198
|
bootstrap = Chef::Knife::Bootstrap.new
|
206
|
-
bootstrap.name_args = [
|
199
|
+
bootstrap.name_args = [server.public_ip_address]
|
207
200
|
bootstrap.config[:run_list] = config[:run_list]
|
208
201
|
bootstrap.config[:ssh_user] = config[:ssh_user] || "root"
|
209
202
|
bootstrap.config[:ssh_password] = server.password
|
@@ -213,7 +206,9 @@ class Chef
|
|
213
206
|
bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
|
214
207
|
# bootstrap will run as root...sudo (by default) also messes up Ohai on CentOS boxes
|
215
208
|
bootstrap.config[:use_sudo] = true unless config[:ssh_user] == 'root'
|
216
|
-
bootstrap.config[:environment] =
|
209
|
+
bootstrap.config[:environment] = locate_config_value(:environment)
|
210
|
+
bootstrap.config[:distro] = locate_config_value(:distro)
|
211
|
+
bootstrap.config[:template_file] = locate_config_value(:template_file)
|
217
212
|
bootstrap
|
218
213
|
end
|
219
214
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-clodo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stepan G. Fedorov
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-10-24 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: fog
|
@@ -26,12 +25,12 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
28
|
+
hash: 51
|
30
29
|
segments:
|
31
30
|
- 0
|
32
|
-
-
|
31
|
+
- 11
|
33
32
|
- 0
|
34
|
-
version: 0.
|
33
|
+
version: 0.11.0
|
35
34
|
type: :runtime
|
36
35
|
version_requirements: *id001
|
37
36
|
description: "\tKnife plugin for Clodo.Ru cloud provider.\n"
|
@@ -54,7 +53,6 @@ files:
|
|
54
53
|
- lib/chef/knife/clodo_server_reboot.rb
|
55
54
|
- lib/chef/knife/clodo_server_start.rb
|
56
55
|
- lib/chef/knife/clodo_server_stop.rb
|
57
|
-
has_rdoc: true
|
58
56
|
homepage: http://clodo.ru/
|
59
57
|
licenses: []
|
60
58
|
|
@@ -84,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
82
|
requirements: []
|
85
83
|
|
86
84
|
rubyforge_project:
|
87
|
-
rubygems_version: 1.
|
85
|
+
rubygems_version: 1.7.2
|
88
86
|
signing_key:
|
89
87
|
specification_version: 3
|
90
88
|
summary: Clodo.Ru knife plugin
|