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).