11

I am having 2 cookbooks name as mycookbook and version 0.1.0 and 0.1.1 on chef server. Now I want to run only cookbook mycookbook version 0.1.1 using chef-client. How do I do this ?

Salim
  • 714
  • 1
  • 5
  • 19

2 Answers2

35

Found the answer with some hit and try

Ran following command

chef-client -o "recipe[mycookbook@0.1.1]"

This will call mycookbook version 0.1.1

NOTE: Running chef-client with the -o parameter will permanently override the runlist for that node.

Taegost
  • 1,208
  • 1
  • 17
  • 26
Salim
  • 714
  • 1
  • 5
  • 19
  • That command will replace your runlist with new one with only that one cookbook. To use some version for all runs, you can specify exact version of cookbook into environment and assign that environment to your node. – rastasheep Feb 09 '15 at 18:26
  • @rastasheep Yes, I wanted to run a specific cookbook out of a run-list and that's what my requirement was. I knew about environment configuration and cookbook version assignment too but was not a solution for this scenario (I don't have permissions to create new environment in chef server ). – Salim Feb 11 '15 at 05:13
1

The command:

chef-client -o COOKBOOK

Will override the default for this run only.
It will not change the default run_list.+

The command:

chef-client -r COOKBOOK

WILL set a new run_list and run the specified COOKBOOK.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Ron Ryan
  • 11
  • 1