Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstalling a package using Chef

I have been using Chef to manage our servers.

My roles/app.rb looks like this:

name "app"

description "App server"

run_list [
    "recipe[apt]",
    ...,
    ...,
    "recipe[nginx]"
    ...,
    ...,
]

Now I would like to remove the nginx package from the machine. If I remove the nginx recipie in run_list, will it remove nginx from the nodes? If not please advise me what is the best strategy to have change-management on nodes.

like image 697
Arun Avatar asked Sep 12 '11 08:09

Arun


People also ask

What are cookbooks in Chef?

Cookbooks are fundamental working units of Chef, which consists of all the details related to working units, having the capability to modify configuration and the state of any system configured as a node on Chef infrastructure. Cookbooks can perform multiple tasks.

What is Chef client?

A chef-client is an agent that runs locally on every node that is under management by Chef. When a chef-client is run, it will perform all of the steps that are required to bring the node into the expected state, including: Registering and authenticating the node with the Chef server.


1 Answers

If you remove nginx from the run_list that particular recipe just won't run. It won't actually remove nginx from the nodes because it doesn't know how to. I was actually pondering about this yesterday.

You can write your own recipe which undoes recipe[nginx] maybe recipe[remove_nginx] or something like that. Following that you can then remove recipe[remove_nginx].

Someone else also thinks this is a good way to do things which is at least a little reassuring:

http://community.opscode.com/questions/6

Apparently you can remove a recipe from the run_list in a ruby_block, so that saves you the hassle of using knife to remove it yourself after it is run:

https://gist.github.com/883522

like image 106
stphung Avatar answered Oct 04 '22 17:10

stphung