Chef run-list?

In our previous posts we have learn and applied default and customized recipes, If you have missed reading it, kindly refer our Thinknyx Chef Series:
Start Automation with Chef?
Chef objects and Recipes?
Chef Cookbooks?
Chef Cookbooks Part-II

But what about doubts like, what if we have to apply multiple recipes together, do we need to specify the whole recipe path each and every time we want to run a single recipe. The answer is “NO”, chef has a very powerful option for our all doubts, Chef has a option in chef-client called “run-list” which will solve our problem with ease.

Chef Automation

So in simple layman language “A run list is an ordered collection of recipes to execute”.

Each recipe in the run list must be addressed with the format recipe[COOKBOOK::RECIPE].


Lets assume we have two different recipes with different cookbooks and we want to run them in a localmode. How to run them using run-list.

Cookbooks in our case: thinknyx & thinknyxblog

drwxr-xr-x. 6 root root 4096 Sep 8 21:49 thinknyx
drwxr-xr-x. 6 root root 4096 Sep 10 02:31 thinknyxblog

Receips inside cookbooks: users.rb and group.rb

ls -lrt thinknyx/recipes/
-rw-r–r–. 1 root root 218 Sep 8 21:56 default.rb
-rw-r–r–. 1 root root 43 Sep 10 01:45 users.rb

ls -lrt thinknyxblog/recipes/
-rw-r–r–. 1 root root 109 Sep 10 02:31 default.rb
-rw-r–r–. 1 root root 44 Sep 10 02:33 group.rb

Lets use the run-list option to apply and run both of the mentioned recipes with different cookbooks together and see the magical result:

chef-client –local-mode –runlist “recipe[thinknyx::users],recipe[thinknyxblog::group]”
[2016-09-10T02:38:51-07:00] WARN: No config file found or specified on command line, using command line options.
Starting Chef Client, version 12.13.37
resolving cookbooks for run list: [“thinknyx::users”, “thinknyxblog::group”]
Synchronizing Cookbooks:
– thinknyx (0.1.0)
– thinknyxblog (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks…
Converging 2 resources
Recipe: thinknyx::users
* user[thinknyxuser] action create
– create user thinknyxuser
Recipe: thinknyxblog::group
* group[thinknyxblog] action create
– create group thinknyxblog

Running handlers:
Running handlers complete
Chef Client finished, 2/2 resources updated in 05 seconds

grep -i thinknyxblog /etc/group

grep -i thinknyxuser /etc/passwd

Both recipes applied and tested. Likewise you can use and combine different recipes from different cookbooks and finally apply them with the help of –runlist option. This will help to run various recipes taken from different cookbooks across different environments.

Till now we have set the foundation for Chef, Resources, Recipes, Cookbooks, Code Creation, Chef-client and other utilities. But is it safe to directly push your code into production without checks/tests?.

In our next post we will discuss about possible options in chef to test our codes.

Leave a Comment

Your email address will not be published.