DigitaloceanのCLIツール tugboat


概要

digitaloceanでのサーバを立ち上げるのに、webサイトを開くのが面倒なんでCLIで操作をできるツールが欲しかった。

vagrant-digitaloceanを使用していたのですが、Linuxディストリビューションを切り替えたいときなどの際に、サイトをみて確認する必要ありが面倒だった。

CLIツール tugboat

tugboat

インストール

gem install tugboat 

rubyは1.9以上

digitaloceanのAPIキー

ここで確認できます。
api_access

環境構築

$ tugboat authorize
Note: You can get this information from digitalocean.com/api_access

Enter your client key:  https://cloud.digitalocean.com/api_accessの取得できるclient ID
Enter your API key: https://cloud.digitalocean.com/api_accessで取得できるAPI Key
Enter your SSH key path (optional, defaults to ~/.ssh/id_rsa): 
Enter your SSH user (optional, defaults to ログインユーザ名): 
Enter your SSH port number (optional, defaults to 22): 

To retrieve region, image, size and key ID's, you can use the corresponding tugboat command, such as `tugboat images`.
Defaults can be changed at any time in your ~/.tugboat configuration file.

Enter your default region ID (optional, defaults to 1 (New York)): 
Enter your default image ID (optional, defaults to 350076 (Ubuntu 13.04 x64)): 
Enter your default size ID (optional, defaults to 66 (512MB)): 
Enter your default ssh key ID (optional, defaults to none): 
Enter your default for private networking (optional, defaults to false): 
Enter your default for enabling backups (optional, defaults to false): 

とりあえずClient IDとAPI Keyを入力する

設定ファイル

$ cat  ~/.tugboat 

authentication:
  client_key: Client ID
  api_key: API Key
ssh:
  ssh_user: 作成するサーバにログインするためのユーザ名
  ssh_key_path: sshキーのパス
  ssh_port: '22'
defaults:
  region: '1' # tugboat regions 表示されたidを書く
  image: '350076' # tugboat images --global 表示されたidを書く
  size: '66' # tugboat sizeで表示されたidを書く 
  ssh_key: ''xxxxx' #tugboat keysで表示されたidを書く
  private_networking: 'false'
  backups_enabled: 'false'

各種コマンドについては
tugboat --helpやtugboat --help コマンド名で確認できます。
またはtugboatで確認できます。

感想

便利