7
7

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.

Chef-soloのrun_list、Vagrantfileのadd_recipe にcookbook名を渡す理由

7
Posted at

add_recipe に cookbook ファイル名を渡しても動く理由

例えば、barというcookbookの、default.rbレシピを実行したい時、以下のように記述します。

Chef-solo の attributes.json ファイル

{
   "run_list" : [
        "recipe[bar]"
   ]
}

Vagrantfile ファイル

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "repo/site-cookbooks"
    chef.add_recipe "bar"
  end

どちらも、

  • ::XXXXX が無い場合は ::default が使われる
    という仕様になっています。

ですので、省略せずに記述する場合は以下のようになります。

{
   "run_list" : [
        "recipe[bar::default]"
   ]
}

default.rb 以外のレシピファイルを実行したい場合

レシピファイル名をそれぞれ明示的に記述します。

例えば、「bar クックブックの recipe/hoge.rb レシピファイルを実行したい」場合は、以下のように記述します。

{
   "run_list" : [
        "recipe[bar::hoge]"
   ]
}
  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "repo/site-cookbooks"
    chef.add_recipe "bar::hoge"
  end
7
7
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
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?