Design about Running recipes Incrementally and Cleanup after Recipe removal


#1

Hello everyone and Chef designers,

I’m a new Chef user, now want to find some solution for 2 problems:
Incremental Recipe Running and Cleanup after Recipe removal

  1. Running recipes Incrementally
    Assume a node has a run_list : [A,B,C] , now I want to add a new recipe D
    into its run_list, then run chef-client. So chef-client will re-run
    A,B,C,D. However, re-run A,B,C is unneccessary, and sometimes I don’t want
    A,B,C to be re-ran which will cause service provided in A,B,C to be restart.

Is it possible to let chef-client check the diff of the two run_lists and
only run the added recipe and re-run the recipe which has been modified or
whoes attribute is modified.

  1. Cleanup after Recipe removal
    This problem is described here :
    http://help.opscode.com/discussions/questions/271-cleanup-after-recipe-removal.

It says when a recipe is removed from the old run_list, can chef-client
detects the change, and remove the packages/files/init.d services installed
by that recipe ? Maybe adding a rollback() method in every recipe to do
this kind of removal and let chef-client call rollback() automactically ?

Looking forward to the feedback :slight_smile:

Thanks & Best Regards,
Hui Hu


#2

On Mar 19, 2012, at 4:04 PM, Hui Hu wrote:

  1. Running recipes Incrementally
    Assume a node has a run_list : [A,B,C] , now I want to add a new recipe D into its run_list, then run chef-client. So chef-client will re-run A,B,C,D. However, re-run A,B,C is unneccessary, and sometimes I don’t want A,B,C to be re-ran which will cause service provided in A,B,C to be restart.

If you write your recipes correctly, when A,B, & C run for the second time, they will be able to determine that nothing needs to change, and therefore they won’t restart any services. This is what it means to be “idempotent”. The Opscode folks are responsible for making their code idempotent inside of chef-client, and it’s up to YOU to make sure that your recipes are also idempotent.

Otherwise, you made the bed of thorns, and now you get to lay in it.

  1. Cleanup after Recipe removal
    This problem is described here : http://help.opscode.com/discussions/questions/271-cleanup-after-recipe-removal .

It says when a recipe is removed from the old run_list, can chef-client detects the change, and remove the packages/files/init.d services installed by that recipe ? Maybe adding a rollback() method in every recipe to do this kind of removal and let chef-client call rollback() automactically ?

Again, that’s up to you. You write your cookbooks and recipes in such a way that they can appropriately de-install themselves, and that will happen.

Otherwise, well, you get out of the system what you put into it.


Brad Knowles bknowles@ihiji.com
SAGE Level IV, Chef Level 0.0.1


#3

Hi Brad and All,

Thanks for your comments.

About 1) Running recipes Incrementally. Opscode support staff says
"Incremental application of recipes is in the planning stage right now" (
http://help.opscode.com/discussions/questions/1366-run-recipes-incrementally-and-cleanup-package-after-removing-recipes-from-run_list
)

About 2) Cleanup after Recipe removal . As you said, we can write code to
do the cleanup manually , but it would be somewhat complicated. It would
be perfect if Chef Client can do it automatically .

Thanks & Best Regards,
Phone: 158 1011 7406
Hui Hu 胡 辉

2012/3/20 Brad Knowles bknowles@ihiji.com

On Mar 19, 2012, at 4:04 PM, Hui Hu wrote:

  1. Running recipes Incrementally
    Assume a node has a run_list : [A,B,C] , now I want to add a new recipe
    D into its run_list, then run chef-client. So chef-client will re-run
    A,B,C,D. However, re-run A,B,C is unneccessary, and sometimes I don’t want
    A,B,C to be re-ran which will cause service provided in A,B,C to be restart.

If you write your recipes correctly, when A,B, & C run for the second
time, they will be able to determine that nothing needs to change, and
therefore they won’t restart any services. This is what it means to be
"idempotent". The Opscode folks are responsible for making their code
idempotent inside of chef-client, and it’s up to YOU to make sure that
your recipes are also idempotent.

Otherwise, you made the bed of thorns, and now you get to lay in it.

  1. Cleanup after Recipe removal
    This problem is described here :
    http://help.opscode.com/discussions/questions/271-cleanup-after-recipe-removal.

It says when a recipe is removed from the old run_list, can chef-client
detects the change, and remove the packages/files/init.d services installed
by that recipe ? Maybe adding a rollback() method in every recipe to do
this kind of removal and let chef-client call rollback() automactically ?

Again, that’s up to you. You write your cookbooks and recipes in such a
way that they can appropriately de-install themselves, and that will happen.

Otherwise, well, you get out of the system what you put into it.


Brad Knowles bknowles@ihiji.com
SAGE Level IV, Chef Level 0.0.1