knife-nc 0.0.0 → 0.0.1
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.
- data/README.md +40 -17
- data/lib/chef/knife/bootstrap/nc-centos5-gems.erb +65 -0
- data/lib/chef/knife/bootstrap/nc-centos6-gems.erb +55 -0
- data/lib/chef/knife/nc_base.rb +4 -2
- data/lib/chef/knife/nc_image_list.rb +1 -1
- data/lib/chef/knife/nc_server_create.rb +24 -21
- data/lib/chef/knife/nc_server_delete.rb +1 -1
- data/lib/chef/knife/nc_server_list.rb +2 -2
- data/lib/knife-nc/chef_extensions.rb +54 -0
- data/lib/knife-nc/nifty_cloud_sdk_extensions.rb +37 -0
- data/lib/knife-nc/version.rb +1 -1
- metadata +7 -3
data/README.md
CHANGED
@@ -14,7 +14,7 @@ knife-ec2 と同じように、インスタンスを作成した上で Chef の
|
|
14
14
|
# "chef" gem のインストール
|
15
15
|
gem install chef
|
16
16
|
|
17
|
-
|
17
|
+
# "ニフティクラウドSDK for Ruby" のインストール
|
18
18
|
wget http://cloud.nifty.com/api/sdk/NIFTY_Cloud_SDK_for_ruby.zip
|
19
19
|
cd NIFTY_Cloud_SDK_for_ruby
|
20
20
|
rake install
|
@@ -25,33 +25,40 @@ knife-ec2 と同じように、インスタンスを作成した上で Chef の
|
|
25
25
|
|
26
26
|
# 設定
|
27
27
|
|
28
|
-
NIFTY
|
28
|
+
NIFTY Cloud REST API と通信するため、knife コマンドにアクセスキー/シークレットキーを教えてやる必要があります。
|
29
29
|
knife.rb に設定するのが一番簡単でしょう。
|
30
30
|
|
31
|
-
knife[:
|
32
|
-
knife[:
|
31
|
+
knife[:nc_access_key] = "Your NIFTY Cloud Access Key"
|
32
|
+
knife[:nc_secret_key] = "Your NIFTY Cloud Access Key"
|
33
33
|
|
34
34
|
knife.rb をバージョン管理システムにコミットしている場合 (つまり誰でも閲覧可能になっている場合) には、
|
35
35
|
環境変数から読み込ませることも可能です。
|
36
36
|
|
37
|
-
knife[:
|
38
|
-
knife[:
|
37
|
+
knife[:nc_access_key] = "#{ENV['NIFTY_CLOUD_ACCESS_KEY']}"
|
38
|
+
knife[:nc_secret_key] = "#{ENV['NIFTY_CLOUD_SECRET_KEY']}"
|
39
39
|
|
40
40
|
アクセスキー/シークレットキーは knife サブコマンドの -A (--nc-access-key) と -K (--nc-secret-key) オプションで指定することもできます。
|
41
41
|
|
42
42
|
# provision a new mini instance
|
43
|
-
knife
|
43
|
+
knife nc server create -r 'role[webserver]' -I 1 -T mini -A 'Your NIFTY Cloud Access Key' -K "Your NIFTY Cloud Secret Key"
|
44
44
|
|
45
45
|
さらに下記のオプションが knife.rb に設定可能です。
|
46
46
|
|
47
|
-
*
|
48
|
-
*
|
47
|
+
* nc_instance_type
|
48
|
+
* nc_image_id
|
49
|
+
* nc_ssh_key_id
|
50
|
+
* nc_bootstrap_version
|
51
|
+
* nc_distro
|
52
|
+
* nc_template_file
|
53
|
+
* nc_user_data
|
49
54
|
|
50
55
|
## サブコマンド一覧
|
51
56
|
|
52
57
|
### knife nc server create
|
53
58
|
|
54
|
-
NIFTY Cloud 上にインスタンスを作成し SSH 経由で Chef のブートストラップを行います。「ブートストラップ」というのは Chef をインストールして Chef クライアントとして Chef
|
59
|
+
NIFTY Cloud 上にインスタンスを作成し SSH 経由で Chef のブートストラップを行います。「ブートストラップ」というのは Chef をインストールして Chef クライアントとして Chef サーバと通信できるようにすることです。利用するブートストラップ・スクリプトは指定したイメージ ID によって自動的に検出されますが、-d オプションや --template-file オプションで上書きすることもできます。インスタンス作成時、あとから knife コマンド経由で削除可能とするために、diableApiTermination を false に設定することに注意してください。
|
60
|
+
|
61
|
+
また、v0.0.1 からは独自オプションとして -R または --ssh-passphrase オプションで SSH パスフレーズが指定できるようになりました。
|
55
62
|
|
56
63
|
### knife nc server delete
|
57
64
|
|
@@ -66,17 +73,33 @@ NIFTY Cloud 上にインスタンスを作成し SSH 経由で Chef のブート
|
|
66
73
|
knife-ec2 にはないオリジナルのコマンドです。現在のアカウントで利用可能なイメージの一覧を表示します。
|
67
74
|
knife nc server create コマンドの -I オプションに渡す Image ID を確認するために利用してください。
|
68
75
|
|
76
|
+
## NIFTY Cloud イメージ向けブートストラップ
|
77
|
+
|
78
|
+
knife-nc gem には NIFTY Cloud で提供されているイメージに最適化された 2 つのブートストラップ・スクリプト (nc-centos5-gems, nc-centos6-gems) が同梱されています。
|
79
|
+
knife nc server create を利用する際にはイメージ ID に応じて自動で利用すべきスクリプトの判別が行われます。
|
80
|
+
knife bootstrap からこのスクリプトを利用するには下記のように -d オプションで識別子を指定してください。
|
81
|
+
|
82
|
+
knife bootstrap XXX.XXX.XXX.XXX -d nc-centos5-gems
|
83
|
+
|
84
|
+
なお、サポート対象のイメージ ID と各イメージ ID に対応するスクリプトの識別子は下記の通りです。
|
85
|
+
|
86
|
+
イメージ ID | OS・ディストリビューション | ブートストラップ・スクリプト | 同梱されている gem
|
87
|
+
------------|----------------------------|------------------------------|-------------------
|
88
|
+
1 | CentOS 5.3 32bit Plain | nc-centos5-gems | knife-nc
|
89
|
+
2 | CentOS 5.3 64bit Plain | nc-centos5-gems | knife-nc
|
90
|
+
6 | CentOS 5.3 32bit Server | nc-centos5-gems | knife-nc
|
91
|
+
7 | CentOS 5.3 64bit Server | nc-centos5-gems | knife-nc
|
92
|
+
13 | CentOS 5.6 64bit Plain | nc-centos5-gems | knife-nc
|
93
|
+
14 | CentOS 5.6 64bit Server | nc-centos5-gems | knife-nc
|
94
|
+
17 | Ubuntu 10.04 64bit Plain | ubuntu10.04-gems | chef
|
95
|
+
21 | CentOS 6.2 64bit Plain | nc-centos6-gems | knife-nc
|
96
|
+
|
69
97
|
## TODO
|
70
98
|
|
71
99
|
* nc server create の -U オプション (起動スクリプト指定) の動作確認ができていない
|
72
100
|
* nc server create の --template-file オプション (ブートストラップ用テンプレート指定) の動作確認ができていない
|
73
|
-
* nc server create の -P オプションが SSH Key のパスフレーズに適用されない
|
74
|
-
* そもそも Chef::Knife::Bootstrap が SSH キーのパスフレーズに対応していないので保留としています
|
75
|
-
* nc server create の -I オプション (イメージ ID 指定) で一部ブートストラップできないイメージがある
|
76
|
-
* CentOS 5 + 64bit の組み合わせで Ruby の OpenSSL ライブラリで "Cipher is not a module" エラーが出て止まってしまうようです
|
77
|
-
* nc server create で利用しているデフォルトの centos5-gems テンプレートを一部修正する必要があります
|
78
|
-
* EPEL rpm の URL が変更されたため現状動いていないっぽいです、Chef 本体に[こちらの修正](https://github.com/vgirnet/chef/commit/62bdc5a7415025555502583cad5f6a6543e7a954)を適用すれば動きます
|
79
101
|
|
80
102
|
## ライセンス
|
81
103
|
|
82
|
-
|
104
|
+
[knife-ec2](https://github.com/opscode/knife-ec2) をベースに NIFTY Cloud 向けに修正を加えたものです。
|
105
|
+
オリジナルに準じて Apache Lisence, Version 2.0 を適用します。
|
@@ -0,0 +1,65 @@
|
|
1
|
+
bash -c '
|
2
|
+
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
|
3
|
+
|
4
|
+
if [ ! -f /usr/bin/chef-client ]; then
|
5
|
+
yum erase -y ruby-1.8.5-24.el5
|
6
|
+
yum erase -y ruby-libs-1.8.5-24.el5
|
7
|
+
yum erase -y ruby-devel-1.8.5-24.el5
|
8
|
+
|
9
|
+
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
|
10
|
+
rpm -Uvh epel-release-5-4.noarch.rpm
|
11
|
+
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://rpm.aegisco.com/aegisco/rhel/aegisco-rhel.rpm
|
12
|
+
rpm -Uvh aegisco-rhel.rpm
|
13
|
+
|
14
|
+
yum install -y gcc gcc-c++ automake autoconf make
|
15
|
+
yum --disablerepo=base install -y ruby ruby-devel
|
16
|
+
|
17
|
+
cd /tmp
|
18
|
+
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz
|
19
|
+
tar zxf rubygems-1.6.2.tgz
|
20
|
+
cd rubygems-1.6.2
|
21
|
+
ruby setup.rb --no-format-executable
|
22
|
+
fi
|
23
|
+
|
24
|
+
gem update --system
|
25
|
+
gem update
|
26
|
+
gem install ohai --no-rdoc --no-ri --verbose
|
27
|
+
gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
|
28
|
+
|
29
|
+
mkdir -p /etc/chef
|
30
|
+
|
31
|
+
(
|
32
|
+
cat <<'EOP'
|
33
|
+
<%= validation_key %>
|
34
|
+
EOP
|
35
|
+
) > /tmp/validation.pem
|
36
|
+
awk NF /tmp/validation.pem > /etc/chef/validation.pem
|
37
|
+
rm /tmp/validation.pem
|
38
|
+
|
39
|
+
<% if @chef_config[:encrypted_data_bag_secret] -%>
|
40
|
+
(
|
41
|
+
cat <<'EOP'
|
42
|
+
<%= encrypted_data_bag_secret %>
|
43
|
+
EOP
|
44
|
+
) > /tmp/encrypted_data_bag_secret
|
45
|
+
awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
|
46
|
+
rm /tmp/encrypted_data_bag_secret
|
47
|
+
<% end -%>
|
48
|
+
|
49
|
+
(
|
50
|
+
cat <<'EOP'
|
51
|
+
<%= config_content %>
|
52
|
+
EOP
|
53
|
+
) > /etc/chef/client.rb
|
54
|
+
|
55
|
+
(
|
56
|
+
cat <<'EOP'
|
57
|
+
<% if Chef::Version.new(Chef::VERSION) >= Chef::Version.new('0.10.10') %>
|
58
|
+
<%= first_boot.to_json %>
|
59
|
+
<% else %>
|
60
|
+
<%= { "run_list" => @run_list }.to_json %>
|
61
|
+
<% end %>
|
62
|
+
EOP
|
63
|
+
) > /etc/chef/first-boot.json
|
64
|
+
|
65
|
+
<%= start_chef %>'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
bash -c '
|
2
|
+
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
|
3
|
+
|
4
|
+
if [ ! -f /usr/bin/chef-client ]; then
|
5
|
+
yum install -y ruby ruby-devel gcc gcc-c++ automake autoconf make
|
6
|
+
|
7
|
+
cd /tmp
|
8
|
+
wget <%= "--proxy=on " if knife_config[:bootstrap_proxy] %>http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz
|
9
|
+
tar zxf rubygems-1.6.2.tgz
|
10
|
+
cd rubygems-1.6.2
|
11
|
+
ruby setup.rb --no-format-executable
|
12
|
+
fi
|
13
|
+
|
14
|
+
gem update --system
|
15
|
+
gem update
|
16
|
+
gem install ohai --no-rdoc --no-ri --verbose
|
17
|
+
gem install chef --no-rdoc --no-ri --verbose <%= bootstrap_version_string %>
|
18
|
+
|
19
|
+
mkdir -p /etc/chef
|
20
|
+
|
21
|
+
(
|
22
|
+
cat <<'EOP'
|
23
|
+
<%= validation_key %>
|
24
|
+
EOP
|
25
|
+
) > /tmp/validation.pem
|
26
|
+
awk NF /tmp/validation.pem > /etc/chef/validation.pem
|
27
|
+
rm /tmp/validation.pem
|
28
|
+
|
29
|
+
<% if @chef_config[:encrypted_data_bag_secret] -%>
|
30
|
+
(
|
31
|
+
cat <<'EOP'
|
32
|
+
<%= encrypted_data_bag_secret %>
|
33
|
+
EOP
|
34
|
+
) > /tmp/encrypted_data_bag_secret
|
35
|
+
awk NF /tmp/encrypted_data_bag_secret > /etc/chef/encrypted_data_bag_secret
|
36
|
+
rm /tmp/encrypted_data_bag_secret
|
37
|
+
<% end -%>
|
38
|
+
|
39
|
+
(
|
40
|
+
cat <<'EOP'
|
41
|
+
<%= config_content %>
|
42
|
+
EOP
|
43
|
+
) > /etc/chef/client.rb
|
44
|
+
|
45
|
+
(
|
46
|
+
cat <<'EOP'
|
47
|
+
<% if Chef::Version.new(Chef::VERSION) >= Chef::Version.new('0.10.10') %>
|
48
|
+
<%= first_boot.to_json %>
|
49
|
+
<% else %>
|
50
|
+
<%= { "run_list" => @run_list }.to_json %>
|
51
|
+
<% end %>
|
52
|
+
EOP
|
53
|
+
) > /etc/chef/first-boot.json
|
54
|
+
|
55
|
+
<%= start_chef %>'
|
data/lib/chef/knife/nc_base.rb
CHANGED
@@ -15,8 +15,10 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
-
|
18
|
+
$:.unshift(File.dirname(__FILE__) + '../../') unless $:.include?(File.dirname(__FILE__) + '../../')
|
19
19
|
require 'chef/knife'
|
20
|
+
require 'knife-nc/chef_extensions'
|
21
|
+
require 'knife-nc/nifty_cloud_sdk_extensions'
|
20
22
|
|
21
23
|
class Chef
|
22
24
|
class Knife
|
@@ -53,7 +55,7 @@ class Chef
|
|
53
55
|
connection = NIFTY::Cloud::Base.new(
|
54
56
|
:access_key => Chef::Config[:knife][:nc_access_key],
|
55
57
|
:secret_key => Chef::Config[:knife][:nc_secret_key]
|
56
|
-
|
58
|
+
)
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
@@ -38,7 +38,7 @@ class Chef
|
|
38
38
|
ui.color('State', :bold)
|
39
39
|
]
|
40
40
|
connection.describe_images.imagesSet.item.each do |image|
|
41
|
-
|
41
|
+
image_list << image.imageId
|
42
42
|
image_list << image.name
|
43
43
|
image_list << "#{image.imageOwnerId} (#{image.imageOwnerAlias})"
|
44
44
|
image_list << "#{image.imageState} (#{image.isPublic ? 'public' : 'private'})"
|
@@ -76,6 +76,12 @@ class Chef
|
|
76
76
|
:long => "--ssh-password PASSWORD",
|
77
77
|
:description => "The ssh password"
|
78
78
|
|
79
|
+
option :ssh_passphrase,
|
80
|
+
:short => "-R PASSPHRASE",
|
81
|
+
:long => "--ssh-passphrase PASSPHRASE",
|
82
|
+
:description => "The ssh passphrase",
|
83
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_passphrase] = key }
|
84
|
+
|
79
85
|
option :ssh_locally,
|
80
86
|
:short => "-L",
|
81
87
|
:long => "--ssh-locally",
|
@@ -99,8 +105,7 @@ class Chef
|
|
99
105
|
:short => "-d DISTRO",
|
100
106
|
:long => "--distro DISTRO",
|
101
107
|
:description => "Bootstrap a distro using a template",
|
102
|
-
:proc => Proc.new { |d| Chef::Config[:knife][:nc_distro] = d }
|
103
|
-
:default => "centos5-gems"
|
108
|
+
:proc => Proc.new { |d| Chef::Config[:knife][:nc_distro] = d }
|
104
109
|
|
105
110
|
option :nc_template_file,
|
106
111
|
:long => "--template-file TEMPLATE",
|
@@ -170,22 +175,6 @@ class Chef
|
|
170
175
|
puts "\n"
|
171
176
|
confirm("Do you really want to create this server")
|
172
177
|
|
173
|
-
# monkey patch NIFTY::Cloud::Base (ignore password option and enable user data)
|
174
|
-
connection.instance_eval do
|
175
|
-
def run_instances(options)
|
176
|
-
options[:password] = 'ignoreme'
|
177
|
-
@user_data = options[:user_data]
|
178
|
-
super(options)
|
179
|
-
end
|
180
|
-
def response_generator(params)
|
181
|
-
params.delete('Password') if params['Password'] == 'ignoreme'
|
182
|
-
if @user_data
|
183
|
-
params['UserData'] = extract_user_data(:user_data => @user_data, :base64_encoded => true)
|
184
|
-
params['UserData.Encoding'] = 'base64'
|
185
|
-
end
|
186
|
-
super(params)
|
187
|
-
end
|
188
|
-
end
|
189
178
|
server = connection.run_instances(create_server_def).instancesSet.item.first
|
190
179
|
|
191
180
|
msg_pair("Instance ID", server.instanceId)
|
@@ -235,11 +224,25 @@ class Chef
|
|
235
224
|
bootstrap.config[:run_list] = config[:run_list]
|
236
225
|
bootstrap.config[:ssh_user] = config[:ssh_user]
|
237
226
|
bootstrap.config[:ssh_password] = config[:ssh_password]
|
227
|
+
bootstrap.config[:ssh_passphrase] = config[:ssh_passphrase]
|
238
228
|
bootstrap.config[:identity_file] = config[:identity_file]
|
239
229
|
bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.instanceId
|
240
230
|
bootstrap.config[:prerelease] = config[:prerelease]
|
241
231
|
bootstrap.config[:bootstrap_version] = locate_config_value(:nc_bootstrap_version)
|
242
|
-
|
232
|
+
|
233
|
+
image_id = locate_config_value(:nc_image_id)
|
234
|
+
if locate_config_value(:nc_distro)
|
235
|
+
bootstrap.config[:distro] = locate_config_value(:nc_distro)
|
236
|
+
elsif %w(1 2 6 7 13 14).include?(image_id)
|
237
|
+
bootstrap.config[:distro] = 'nc-centos5-gems'
|
238
|
+
elsif image_id == '17'
|
239
|
+
bootstrap.config[:distro] = 'ubuntu10.04-gems'
|
240
|
+
elsif image_id == '21'
|
241
|
+
bootstrap.config[:distro] = 'nc-centos6-gems'
|
242
|
+
else
|
243
|
+
bootstrap.config[:distro] = 'nc-centos5-gems'
|
244
|
+
end
|
245
|
+
|
243
246
|
bootstrap.config[:use_sudo] = true unless config[:ssh_user] == 'root'
|
244
247
|
bootstrap.config[:template_file] = locate_config_value(:nc_template_file)
|
245
248
|
bootstrap.config[:environment] = config[:environment]
|
@@ -257,7 +260,7 @@ class Chef
|
|
257
260
|
|
258
261
|
if @name_args.empty?
|
259
262
|
errors << "You have not provided a valid instance ID."
|
260
|
-
|
263
|
+
end
|
261
264
|
|
262
265
|
if config[:security_group].nil?
|
263
266
|
errors << "You have not provided a valid Security Group."
|
@@ -286,7 +289,7 @@ class Chef
|
|
286
289
|
|
287
290
|
if Chef::Config[:knife][:nc_user_data]
|
288
291
|
begin
|
289
|
-
server_def.merge!(:user_data => File.read(
|
292
|
+
server_def.merge!(:user_data => File.read(locate_config_value(:nc_user_data)))
|
290
293
|
rescue
|
291
294
|
ui.warn("Cannot read #{Chef::Config[:knife][:nc_user_data]}: #{$!.inspect}. Ignoring option.")
|
292
295
|
end
|
@@ -79,7 +79,7 @@ class Chef
|
|
79
79
|
confirm("Do you really want to delete this server")
|
80
80
|
|
81
81
|
print "\n#{ui.color("Waiting for server to shutdown", :magenta)}"
|
82
|
-
|
82
|
+
connection.stop_instances(:instance_id => instance_id, :force => true)
|
83
83
|
while server.instanceState.name != 'stopped'
|
84
84
|
print "."
|
85
85
|
server = connection.describe_instances(:instance_id => instance_id).reservationSet.item.first.instancesSet.item.first
|
@@ -43,8 +43,8 @@ class Chef
|
|
43
43
|
]
|
44
44
|
connection.describe_instances.reservationSet.item.each do |instance|
|
45
45
|
server = instance.instancesSet.item.first
|
46
|
-
|
47
|
-
|
46
|
+
group = instance.groupSet
|
47
|
+
server_list << server.instanceId
|
48
48
|
server_list << server.ipAddress.to_s
|
49
49
|
server_list << server.privateIpAddress.to_s
|
50
50
|
server_list << server.instanceType
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#
|
2
|
+
# Author:: tily (<tidnlyam@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2011 tily
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
require 'chef/knife'
|
19
|
+
require 'chef/knife/ssh'
|
20
|
+
require 'chef/knife/bootstrap'
|
21
|
+
|
22
|
+
class Chef::Knife
|
23
|
+
class Ssh
|
24
|
+
alias original_session_from_list session_from_list
|
25
|
+
|
26
|
+
option :ssh_passphrase,
|
27
|
+
:long => "--ssh-passphrase PASSPHRASE",
|
28
|
+
:description => "Your SSH Passphrase",
|
29
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_passphrase] = key }
|
30
|
+
|
31
|
+
def session_from_list(list)
|
32
|
+
session = original_session_from_list(list)
|
33
|
+
session.servers.each do |server|
|
34
|
+
server.options[:passphrase] = config[:ssh_passphrase]
|
35
|
+
end
|
36
|
+
session
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Bootstrap
|
41
|
+
alias original_knife_ssh knife_ssh
|
42
|
+
|
43
|
+
option :ssh_passphrase,
|
44
|
+
:long => "--ssh-passphrase PASSPHRASE",
|
45
|
+
:description => "Your SSH Passphrase",
|
46
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_passphrase] = key }
|
47
|
+
|
48
|
+
def knife_ssh
|
49
|
+
ssh = original_knife_ssh
|
50
|
+
ssh.config[:ssh_passphrase] = config[:ssh_passphrase]
|
51
|
+
ssh
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Author:: tily (<tidnlyam@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2011 tily
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
require 'NIFTY'
|
19
|
+
|
20
|
+
class NIFTY::Cloud::Base
|
21
|
+
alias original_run_instances run_instances
|
22
|
+
alias original_response_generator response_generator
|
23
|
+
def run_instances(options)
|
24
|
+
options[:password] = 'ignoreme' unless options[:password]
|
25
|
+
@user_data = options[:user_data]
|
26
|
+
original_run_instances(options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def response_generator(params)
|
30
|
+
params.delete('Password') if params['Password'] == 'ignoreme'
|
31
|
+
if @user_data
|
32
|
+
params['UserData'] = extract_user_data(:user_data => @user_data, :base64_encoded => true)
|
33
|
+
params['UserData.Encoding'] = 'base64'
|
34
|
+
end
|
35
|
+
original_response_generator(params)
|
36
|
+
end
|
37
|
+
end
|
data/lib/knife-nc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-nc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
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: 2012-03
|
12
|
+
date: 2012-06-03 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: NIFTY Cloud Support for Chef's Knife Command
|
15
15
|
email:
|
@@ -24,16 +24,20 @@ files:
|
|
24
24
|
- .rspec
|
25
25
|
- Gemfile
|
26
26
|
- LICENSE
|
27
|
+
- README.md
|
27
28
|
- Rakefile
|
28
29
|
- knife-nc.gemspec
|
30
|
+
- lib/chef/knife/bootstrap/nc-centos5-gems.erb
|
31
|
+
- lib/chef/knife/bootstrap/nc-centos6-gems.erb
|
29
32
|
- lib/chef/knife/nc_base.rb
|
30
33
|
- lib/chef/knife/nc_image_list.rb
|
31
34
|
- lib/chef/knife/nc_server_create.rb
|
32
35
|
- lib/chef/knife/nc_server_delete.rb
|
33
36
|
- lib/chef/knife/nc_server_list.rb
|
37
|
+
- lib/knife-nc/chef_extensions.rb
|
38
|
+
- lib/knife-nc/nifty_cloud_sdk_extensions.rb
|
34
39
|
- lib/knife-nc/version.rb
|
35
40
|
- spec/spec_helper.rb
|
36
|
-
- README.md
|
37
41
|
homepage: https://github.com/tily/ruby-knife-nc
|
38
42
|
licenses: []
|
39
43
|
post_install_message:
|