Skip to content

faizk/knife-niftycloud

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Knife NiftyCloud

このプラグインについて:

Chef ServerからNifty Cloudインスタンスの立ち上げや操作をするためのgemです。

AWSを制御するためのknife-ec2 をforkして作成しています。

ニフティクラウド SDK for Ruby が提供するコマンドを直接叩くこと比較してのメリットは以下の通りです。

  • サーバ立ち上げと同時にChef Serverにnodeとして登録を行う

  • サーバ立ち上げと同時ににbootstrapでChef Clientのインストールを行う

  • 例えばNifty Cloudのサーバを削除したい場合、stop→APIからの削除を許可→削除という手順を踏む必要があるが、一連の操作を自動で行う。

等。

インストール:

ニフティクラウド SDK for Ruby がインストールされている必要があります。

インストールされていない場合は自動でインストールを行います。

gem install chef

#まだrubygems.orgに登録していないので自分でビルドしてインストール
gem build /path/to/knife-niftycloud.gemspec
gem install --local /path/to/knife-niftycloud-0.1.gem

設定:

Nifty CloudのコントロールパネルからREST APIのAccessKeyとSecretAccessKeyを取得してください 。

‘knife.rb`に以下のように取得したAccessKeyとSecretAccessKey、 ニフティクラウドAPIのエンドポイントURL を記述します。

knife[:nifty_cloud_access_key]  = "Your Nifty Cloud Access Key ID"
knife[:nifty_cloud_secret_key] = "Your Nifty Cloud Secret Access Key"
knife[:nifty_cloud_endpoint_url] = "https://east-1.cp.cloud.nifty.com/api/"

‘knife.rb`がSCMに登録されていてAccessKeyとSecretAccessKeyをknife.rbに記述したくない場合には、環境変数に登録することも可能です。

knife[:nifty_cloud_access_key] = "#{ENV['NIFTY_CLOUD_ACCESS_KEY']}"
knife[:nifty_cloud_secret_key] = "#{ENV['NIFTY_CLOUD_SECRET_KEY']}"

各サブコマンド実行時に以下のように-A (or --nifty-cloud-access-key) -K (or --nifty-cloud-secret-key)オプションとして指定することも可能です。

# webserverロールのサーバをCentOS 6.2 64bit Plain/small2で立ち上げる場合
knife niftycloud server create -r 'role[webserver]' -IM 21 -f small2 -A “Your Nifty Cloud Access Key ID“ -K "Your Nifty Cloud Secret Access Key"

‘knife.rb`には以下のオプションを設定することも可能です。

#インスタンスタイプ
knife[:instance_type]
#サーバイメージID
knife[:image_id]
#サーバ接続用SSHキー名
knife[:ssh_key_name]
#課金タイプ(月額課金=1、従量課金=2)
knife[:accounting_type]
#bootstrap用テンプレートファイル
knife[:template_file]

サブコマンド:

このプラグインは以下のコマンドをknifeコマンドのサブコマンドとして提供します。コマンドのオプションを確認するには--helpオプションを付けてコマンドを実行してください。

knife niftycloud server create

設定されているNifty Cloudアカウント/リージョン上にサーバを新規で立ち上げ、その後対象サーバにSSH接続を行ってChefのbootstrapを実行します。

bootstrapではChefのインストールを行うため、実行完了後はChef ClientをChef Server上から制御することが可能となります。

bootstrapはデフォルトでは ubuntu10.04-gems テンプレートを利用して実行します。

-d又は--template-fileオプションを使用することにより任意のものを指定することも可能です。

knife niftycloud server delete

設定されているNifty Cloudアカウント/リージョン上の指定されたサーバを削除します。

注意 デフォルトではChef Serverからのnodeとclient objectsの削除は行いません。

もしChef Serverからも削除したい場合には--purgeオプションを指定して実行してください。

knife niftycloud server list

設定されているNifty Cloudアカウント/リージョンに登録されているサーバ一覧を表示します。

注意 Chefサーバに登録されていないサーバも含めての表示となります。

knife niftycloud image list

設定されているNifty Cloudアカウント/リージョンで利用可能なサーバイメージ一覧を表示します。

サーバイメージIDについて:

knife nifty cloud image listコマンドの実行結果で表示されるimageIDを指定して下さい。

ライセンス:

オリジナルのknife-ec2 に準じてApache Licenseとします。

License

Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Chef knife plug-in for Nifty Cloud

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%