Prevent installation of recommended packages on Debian

351 views
Skip to first unread message

Wolodja Wentland

unread,
Mar 10, 2014, 6:17:56 AM3/10/14
to salt-...@googlegroups.com
Hi all,

I am wondering how I could prevent the installation of recommended packages on
a case-by-case basis. Please note that I do *not* want to disable this by
default, but I simply want salt to use the equivalent of
"apt-get --no-install-recommends install $PKG" when installing certain
packages.

More specifically I want to prevent the installation of nagios3 or icinga when
installing nagios-nrpe-plugin as I really don't want to have the server
running on every host we monitor.

What would be the best strategy to achieve this? I can't seem to find a good
way to set options for apt in salt.
--
Wolodja <bab...@gmail.com>

4096R/CAF14EFC
081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC
signature.asc

martin f krafft

unread,
Mar 10, 2014, 8:22:29 AM3/10/14
to salt-...@googlegroups.com
also sprach Wolodja Wentland <bab...@gmail.com> [2014-03-10 11:17 +0100]:
> More specifically I want to prevent the installation of nagios3 or
> icinga when installing nagios-nrpe-plugin as I really don't want
> to have the server running on every host we monitor.

I think you should file a bug in the Debian bug tracker and request
the downgrade of this dependency to a suggestion. I don't think it
should be a recommendation either.

That said, you could try to install a package pin with priority -1,
not sure if that will work though.

--
martin | http://madduck.net/ | http://two.sentenc.es/

weapon, n.:
an index of the lack of development of a culture.

spamtraps: madduc...@madduck.net
digital_signature_gpg.asc

Wolodja Wentland

unread,
Mar 10, 2014, 9:17:57 AM3/10/14
to salt-...@googlegroups.com
On Mon, Mar 10, 2014 at 13:22 +0100, martin f krafft wrote:
> also sprach Wolodja Wentland <bab...@gmail.com> [2014-03-10 11:17 +0100]:
> > More specifically I want to prevent the installation of nagios3 or
> > icinga when installing nagios-nrpe-plugin as I really don't want
> > to have the server running on every host we monitor.
>
> I think you should file a bug in the Debian bug tracker and request
> the downgrade of this dependency to a suggestion. I don't think it
> should be a recommendation either.

I had already discussed this briefly with the maintainers, but have now
reported this as a bug and hope that it will be resolved.

It would still be interesting to learn how to deal with this from within salt
though. I might try to explicitly forbid the installation of both incinga and
nagios3 via salt.states.pkg.{removed,purged} and hope that salt will be able
to figure out that installing that package is not needed (rather than
installing and then removing/purging it.
signature.asc

martin f krafft

unread,
Mar 10, 2014, 9:27:33 AM3/10/14
to salt-...@googlegroups.com
also sprach Wolodja Wentland <bab...@gmail.com> [2014-03-10 14:17 +0100]:
> It would still be interesting to learn how to deal with this from within salt
> though. I might try to explicitly forbid the installation of both incinga and
> nagios3 via salt.states.pkg.{removed,purged} and hope that salt will be able
> to figure out that installing that package is not needed (rather than
> installing and then removing/purging it.

I would be inclined to say that salt.states.pkg's parameter
skip_suggestions could be abused for that. I don't think APT makes
naming suggestions, but it does have recommendations ;)
"common sense is the collection
of prejudices acquired by age eighteen"
-- albert einstein

spamtraps: madduc...@madduck.net
digital_signature_gpg.asc

martin f krafft

unread,
Mar 10, 2014, 9:33:20 AM3/10/14
to salt-...@googlegroups.com
also sprach martin f krafft <mad...@madduck.net> [2014-03-10 14:27 +0100]:
> I would be inclined to say that salt.states.pkg's parameter
> skip_suggestions could be abused for that. I don't think APT makes
> naming suggestions, but it does have recommendations ;)

An alternative would be a new state i.e. "minimal", which would
inherit from "installed" or "latest" and allow this form of
fine-tuning.
"literature always anticipates life.
it does not copy it, but moulds it to its purpose.
the nineteenth century, as we know it,
is largely an invention of balzac."
-- oscar wilde

spamtraps: madduc...@madduck.net
digital_signature_gpg.asc

Wolodja Wentland

unread,
Mar 13, 2014, 7:51:17 AM3/13/14
to salt-...@googlegroups.com
On Mon, Mar 10, 2014 at 11:17 +0100, Wolodja Wentland wrote:
> More specifically I want to prevent the installation of nagios3 or icinga when
> installing nagios-nrpe-plugin as I really don't want to have the server
> running on every host we monitor.

I experimented a bit with this, but haven't found a solution that I really
like yet. It would be great if salt would allow to pass options such as
"--no-install-recommends" to apt somehow.

1. The descriptive programming way

I thought salt might be able to figure out not to install a package in the
first place if it is only to be removed/purged later on. But logic programming
and salt are unfortunately not the same thing which i found out when I used:

--- foo/nrpe.sls
include:
- nagios.nrpe

nagios3:
- pkg:
- purged

icinga:
- pkg:
- purged
---

This worked to some degree, but increases runtime unnecessarily as the package
is first installed and then purged later on. Even worse is that pkg.purged
does not remove all the packages that have been installed earlier as it
doesn't run the equivalent of "apt-get --purge autoremove". Leaving these
stray packages (e.g. nagios3-cgi) is unacceptable for me.

2. The disable/enable recommends way

The next thing I tried was:

-- foo/nrpe.sls
extend:
nagios-nrpe-plugin:
pkg:
- require:
- file: disable-apt-recommends
/etc/nagios/nrpe.cfg:
file:
source: salt://um/nagios/files/nrpe.cfg

disable-apt-recommends:
file:
- managed
- name: /etc/apt/apt.conf.d/no-recommends
- source: salt://um/nagios/files/no-recommends

enable-apt-recommends:
file:
- absent
- name: /etc/apt/apt.conf.d/no-recommends
- require:
- pkg: nagios-nrpe-plugin
---

Which also worked to a certain degree, but I don't like that all I achieved
here is to ensure that recommends will be disabled *sometime* before
nagios-nrpe-plugin is installed and re-enabled *sometime* afterwards. This
might therefore affect a larger number of states than intended.

Is there a way to wrap nagios-nrpe-plugin tighter in disable-apt-recommends
and enable-apt-recommends? What I have in mind is the equivalent of a
decorator in Python (e.g. wrapped functions).
signature.asc

Jille Timmermans

unread,
Aug 15, 2014, 10:43:15 AM8/15/14
to salt-...@googlegroups.com
Op donderdag 13 maart 2014 12:51:17 UTC+1 schreef Wolodja Wentland:
On Mon, Mar 10, 2014 at 11:17 +0100, Wolodja Wentland wrote:
> More specifically I want to prevent the installation of nagios3 or icinga when
> installing nagios-nrpe-plugin as I really don't want to have the server
> running on every host we monitor.

I experimented a bit with this, but haven't found a solution that I really
like yet.
It's still not beautiful but you could use aptpkg.hold and put the packages you don't want on hold; that will prevent them from being installed as a recommended package.

I haven't been able to test this because aptpkg.hold was introduced in 2014.7.0 and I'm stuck at 2014.1.10.

http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.aptpkg.html#salt.modules.aptpkg.hold

-- Jille

Arnold Bechtoldt

unread,
Aug 15, 2014, 1:58:13 PM8/15/14
to salt-...@googlegroups.com
TL;DR

Why don't you configure apt to ignore those recommended packages?


# cat /etc/apt/apt.conf.d/999custom


APT::Install-Recommends "0";
APT::Install-Suggests "0";
APT::Default-Release "stable";
APT::Get::Show-Versions "yes";

I'm doing this with <https://github.com/bechtoldt/apt-formula> on Debian.


Arnold

--
Arnold Bechtoldt

Karlsruhe, Germany
0xE2356889.asc
signature.asc
Reply all
Reply to author
Forward
0 new messages