1

I have multiple lists of RPMs (one per configuration), and a set of remote machines. Each list includes all of the RPMs needed to run my machine in the configuration I choose.

For a given configuration and machine, I need to make sure that:

  1. Every RPM in the configuration's RPM list is installed, in the exact same version; and
  2. Any RPM not in the list is not installed (and uninstall it if necessary)

I've been looking into Ansible and its yum module, but though it's easy ensuring given RPMs are installed, I couldn't find a way to specify that any other RPMs should be uninstalled.

What's a good way of doing that?

1

It's right there, in the documentation you linked:

- name: remove the Apache package
  yum: name=httpd state=absent

Note it can be applied to groups as well:

- name: install the 'Development tools' package group
  yum: name="@Development tools" state=absent

However, if your requirement is to ensure any package not in your list is not installed, you should start reviewing your provision procedure, i.e., if a machine is under control since its inception, there shouldn't be way out of your control for a package to be installed.

  • I need to ensure any package not on the list is not installed, and unfortunately the machine cannot be under my control since its inception. – MoshiBin Oct 7 '14 at 8:39
  • Since this machine has not been completely under your control, I'd start by listing all the currently installed packages and working from there. – dawud Oct 7 '14 at 9:06
0

rpm -qa will list all installed RPMs. You could simply save a known good servers output to a txt file and then run a diff against other servers.

I've not used Ansible, but possibly you could use this output to list packages to remove.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.