How to uninstall chef-client and the whole Chef package
Asked Answered
R

4

26

Is uninstalling Chef-Client just as easy as removing the directory, and making sure its not in the rc files? Is there a way to use knife to uninstall chef-client?

--2013-06-26_EDIT--

Updating this question to say, how to remove chef and all its other pieces from OS X, and Linux after using 1.) The Omnibus installer, and 2.) A bootstrapped node? Since I was trying to use Chef on my Mac, and had RVM installed, chef would not work, so now, I need to figure out how to remove chef.

--2015-03-08 EDIT --
Seems Opscode has put out their own instructions for uninstalling ChefDK. As far as the agent goes, it'd be the same method, using the package manager, or Add/Remove Programs.
http://docs.chef.io/install_dk.html#uninstall

Rove answered 14/6, 2013 at 18:42 Comment(2)
It depends on OS and how you installed chef.Sustenance
RHEL 5,6 and CentOS 6.4 for my personal at home project. I used the omnibus installer to install chef, and had to remove RVM Rubies from those OS's because of conflicts I was having.Rove
R
22

To help answer my own question, I found that depending on how you install Chef, depends on how you uninstall it. You can do the:

Redhat/CentOS

rpm -qa *chef*
yum remove <package>

Or if you installed it with ruby gems:

gem uninstall chef-<version>

However, for using an Omnibus installer, there wasn't an RPM package, and on my Mac OSX 10.6.8, I couldn't find anything about it. So, I realized that chef is self-contained, so I just deleted the directory in the /opt/ directory. Once I did that, I was able to use my RVM Ruby's.

--2015-03-08--
Opscode provides their own instructions for uninstalling ChefDK, and the Agent.
http://docs.chef.io/install_dk.html#uninstall

Rove answered 26/7, 2013 at 16:35 Comment(2)
Did some debugging on Mac OS X Mavericks and the install.sh "Omnibus installer" creates a temp directory containing chef--mac_os_x-10.7-x86_64.sh (10.7 atm) that creates another temp directory containing makeselfinst that has DEST_DIR=/opt/chef in it. So that's true, deleting /opt/chef removes it but there will be some symlinks in /usr/bin pointing to nowhere you might also want to remove: chef-client, chef-solo, chef-apply, chef-shell, knife, shef & ohai. hthMiddelburg
I also use the above command but also do the following (on CentOS): rm -rf /var/chef; rm -rf /etc/chef; rm -rf /opt/chef and then knife node delete NODE_NAME followed by knife client delete NODE_NAME. Now the node should be ready for re-installing Chef if necessary.Roxanneroxburgh
R
11

If you're on debian/ubuntu (or a system with dpkg) just check the status of the package:

dpkg --list | grep chef # or dpkg --status chef

then purge (see man dpkg):

dpkg -P chef
Rockies answered 17/7, 2013 at 6:5 Comment(1)
I'm not near my computer, but would the same, rpm -qa | grep *chef* work, and allow me to see what I needed to remove? I didn't think about that until just now.Rove
V
8

I came across this when trying to figure out how to remove chef from a cloud server (Ubuntu in this case). I used chef to configure a machine, but I want to bake an image and not have chef on it. So for those looking for similar

To remove chef-client that was installed in omnibus fashion:

  • sudo rm -rf /opt/chef (This is where most of it is)
  • sudo rm -rf /etc/chef (Hints and the like for the chef-client)
  • for P in /usr/bin/chef-*; do [ -e "$P" ] && sudo rm -f "$P"; done (links for chef commands)
  • sudo rm -f /usr/bin/knife /usr/bin/ohai /usr/bin/chef (other links to chef commands)
Valuable answered 21/8, 2014 at 21:11 Comment(2)
Use rpm / apt-get to remove chef / omnibus packages. If you just delete files an next chef bootstrap or initial run will fail since will find rpms/debs installed.Coetaneous
@Coetaneous I used dpkg -P chef from an answer of this question, and still this issue helped me to remove other files. I still had the /etc/chef, /usr/bin/chef-* and /usr/bin/knife /usr/bin/ohai /usr/bin/chef files on my node. Upvoted.Clippard
O
4

Execute the below series of commands as a root user:

On Ubuntu/Debian:

dpkg -P chef;
rm -rf /opt/chef /var/chef /etc/chef;
for P in /usr/bin/chef-*; do [ -e "$P" ] && sudo rm -f "$P"; done;
rm -rf /usr/bin/knife /usr/bin/ohai /usr/bin/chef;

This is also a solution for the error below that occurs during the bootstrap process on Ubuntu [because of the presence of old version of chef-client]

ERROR: Cannot find a resource for apt_update on ubuntu version 14.04

On RHEL/CentOS:

rm -rf /opt/chef; rm -rf /etc/chef; 
for P in /usr/bin/chef-*; do [ -e "$P" ] && sudo rm -f "$P"; done
rpm -qa | grep chef-server | xargs yum erase -y;
userdel -f chef_server; userdel -f opscode-pgsql; 
rm -rf /usr/bin/knife /usr/bin/ohai /usr/bin/chef /opt/chef-server/ /var/chef/ /var/opt/chef-server/ /var/log/chef-server/ /etc/chef /etc/chef-server/ /etc/chef /etc/chef-server/;
Outfitter answered 27/5, 2016 at 14:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.