bbbco
bbbco

Reputation: 1530

How do I remove an rpm package with chef along with dependencies?

How do I remove an rpm package in a recipe when it could have some dependencies associated with it?

My use case is that I am a tester, and use chef to setup / upgrade / downgrade my testing environments. In order to ensure I have a clean environment when upgrading, I remove the app that is installed using:

rpm_package rpmName do
    action[:remove]
end

However, sometimes my environment also installs an extra "plugin" rpm that is dependent on the main app's rpm. When I run chef and it runs the remove main app's package command, chef fails because of the dependency issue:

Chef::Exceptions::Exec
----------------------
rpm  -e <main app> returned 1, expected 0

And on the server:

[root@qa ~]# rpm  -e <main app>
error: Failed dependencies:
<main app> >= X.x.x is needed by (installed) <plugin rpm>

I looked at the Chef docs for rpm_package, but didn't come across anything that could help me. Does anyone have any suggestions?

Upvotes: 0

Views: 1510

Answers (2)

Etan Reisner
Etan Reisner

Reputation: 80931

Are there chef rules (or whatever they are called) that use yum? Asking yum to remove a package that is a dependency of another package will ask to remove the dependent package as well and only fails if told not to.

Upvotes: 1

sethvargo
sethvargo

Reputation: 26997

Unfortunately this is a by-product of RPM, not Chef. You'll need to query RPM to figure out which packages use it as a dependency and uninstall them first. It's like reverse dependency management.

Upvotes: 1

Related Questions