1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Test Kitchenでsshへのオプションの渡し方

Posted at

Test KitchenのDriverがsshするときのオプションは設定ファイルで行うことができる。

参考: chef - なぜか Test Kitchen 公式ドキュメントに書いていない .kitchen.yml のリファレンスのありか - Qiita

sshの秘密鍵を指定したい場合はdriverの中に値をssh_keyというキーを使って指定できる。

driver:
  name: vagrant
  ssh_key: "~/.ssh/id_rsa"

他にもpasswordやportなどの指定もできる。

参考: https://github.com/test-kitchen/test-kitchen/blob/v1.3.1/lib/kitchen/driver/ssh_base.rb#L115-L124

余談

test-kitchenのgceドライバーを利用していてsshに失敗するようになった。なぜだか原因はわからない。sshの秘密鍵がみつけられていないようだった。

gce用のsshの鍵は~/.ssh/google_compute_engineにあるのでこれを指定した。
どうしてこうなったのか知らべているがわからない。

また、調べていて知ったこととしてkitchen-gceのサンプルのymlファイルは

.kitchen.yml
driver_plugin: gce
driver_config:
  google_client_email: "123456789012@developer.gserviceaccount.com"
  google_key_location: "<%= ENV['HOME']%>/gce/1234567890abcdef1234567890abcdef12345678-privatekey.p12"
  google_project: "alpha-bravo-123"
  network: "kitchenci"
  region: any

となっているがこれはレガシーな書き方で、

.kitchen.yml
driver:
  name: gce
  google_client_email: "123456789012@developer.gserviceaccount.com"
  google_key_location: "<%= ENV['HOME']%>/gce/1234567890abcdef1234567890abcdef12345678-privatekey.p12"
  google_project: "alpha-bravo-123"
  network: "kitchenci"
  region: any

のように書くほうがモダンのようです。

こういうトラブルにあった時はログを見ろと言われるけど、ログレベルを変えて実行するのほうが原因がわかりやすかった。
Test Kitchen の実行の際にログレベルを変更するには -l を使う。

convergeする際の場合は

$ kitchen converge -l debug

のようにすると良い。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?