LoginSignup
0
0

More than 5 years have passed since last update.

Chef test-kitchen の chef_zero provisioner で role や environment を使う設定

Posted at

問題

chefdkのchef generate cookbook で作ったcookbookからtest-kitchenを行なうと、他のクックブックやrole, environment, data_bagなどはこのcookbook外に位置することになる。

他のクックブックは以下にて使用可能
Chef + test-kitchenで依存関係を持ったクックブックテスト環境構築

では、role, environmentなどを使うには?

Chef社の公式だけでは分かりにくく、少し手間取ったので備忘

.kitchen.yml -> Provisioner Settings
client.rb

記述例

.kitchen.yml

.kitchen.yml
...

provisioner:
  name: chef_zero
  always_update_cookbooks: true
  roles_path:        ../../roles         # rolesのpath
  environments_path: ../../environments  # environmentsのpath
  client_rb:
    environment: dev                     # environmentを指定

...

  • roles_path:, environments_path:, data_bags_path: などをprovisioner:に追記してパスを記載
    • 相対パスの場合、.kitchen.ymlのあるcookbook homeから
    • cookbook home外でも使用可
  • client_rb: の下でノードの environment: を指定

roleやenvironmentはjsonのみ可能

Ruby DSL表記不可

../../environment/dev.json
{
  "name": "dev",
  "description": "My Chef environment",
  "cookbook_versions": {},
  "json_class": "Chef::Environment",
  "chef_type": "environment",
  "default_attributes": {
  },
  "override_attributes": {
  }
}

  • JSONでの普通の定義
0
0
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
0
0