A collection of task oriented solutions in Puppet

 

Install a package with custom options

Challenge

You want to install a package but need custom options.

Solution

class yum_package_options {

  # enable a repo while installing 'localpkg'
  package { 'localpkg':
    install_options => ['--enablerepo', 'company_repo'],
  }

  # turn off all plugins and install the package using only the local cache
  package { 'localapppkg':
    install_options => ['--noplugins', '--cacheonly' ],
  }

}
class apt_package_options {

  # install a package from backports using Apt
  package { 'backported-local-pkg':
    install_options => ['-t', 'jessie-backports'],
  }

}

Explanation

When installing packages there are times you need to customise the options passed to your package manager. Some basic examples are:

* enabling a repo for a given package
* install a package from Debian back ports
* disable GPG checking for a single package.

In the past these kind of use cases required you to install a package via an explicit exec but in modern Puppet they are supported by the install_options attribute offered by a number of package providers.

See Also