No APT Recommends with puppet

This is now possible via the "install_options" setting in the Puppet 'package' type: https://puppet.com/docs/puppet/latest/types/package.html#package-attribute-install_options

For example:

package { 'nmap':
  ensure          => installed,
  install_options => ['--no-install-recommends'],
}

The above ensures the "--no-install-recommends" option is passed to apt-get, which skips the recommended packages just for this install: http://manpages.ubuntu.com/manpages/precise/man8/apt-get.8.html


I have found the following solutions so far, but they are not ideal.

Wait until a recently added patch makes it into released version and upgrade.

  • PRO: this is the right way
  • CON: I have to wait, or locally patch my setup.

Simply use an exec to install instead of package, and use an exec.

  • PRO: simple to do if you don't worry about error checking.
  • CON: It takes a pretty complex command line to install, not automatically upgrade, and gracefully handle installation errors.

Globally update my apt configuration, and spend the time to find all the missing stuff and adjust my manifests to also install packages I wanted that only get installed by being recommended.

  • PRO: my manifests are more specific, and more precisely reflect the state of a system
  • CON: Fixing my manifests/configs to reflect this new reality will take a non-trivial amount of time/effort.

Set the APT_CONFIG environment variable before running puppet.

  • PRO: easy to set, if you are using cron initiated puppet
  • PRO: doesn't change behavior for any manually usage of apt
  • CON: easy to forget to set it when manually running APT for testing purposes.
  • CON: you have to fix all the manifests, just like if you update the global configuration.