Skip to main content

apt_package Resource

This page is generated from the Chef Infra Client source code.
To suggest a change, edit the apt_package.rb file and submit a pull request to the Chef Infra Client repository.

All Infra resources page

Use the apt_package resource to manage packages on Debian, Ubuntu, and other platforms that use the APT package system.

Syntax

An apt_package resource block manages a package on a node, typically by installing it. The simplest use of the apt_package resource is:

apt_package 'package_name'

which will install the named package using all of the default options and the default action of :install.

apt_package 'name' do
  default_release           String
  options                   String, Array
  overwrite_config_files    true, false # default value: false
  package_name              String, Array
  response_file             String
  response_file_variables   Hash # default value: {}
  source                    String
  timeout                   String, Integer
  version                   String, Array
  action                    Symbol
end

Actions

:install
Install a package. If a version is specified, install the specified version of the package. (default)
:lock
Locks the apt package to a specific version.
:purge
Purge a package. This action typically removes the configuration files as well as the package.
:reconfig
Change the installed package.
:remove
Remove a package.
:unlock
Unlocks the apt package so that it can be upgraded to a newer version.
:upgrade
Install a package and ensure that a package is the latest version.

Properties

default_release
Ruby Type: String
The default release. For example: stable.
In many cases, it is better to use the package resource instead of this one. This is because when the package resource is used in a recipe, Chef Infra Client will use details that are collected by Ohai at the start of a Chef Infra Client run to determine the correct package application. Using the package resource allows a recipe to be authored in a way that allows it to be used across many platforms.
TESTING Additional text for testing. TESTING
options
Ruby Type: String, Array
One (or more) additional options that are passed to the command. For example, common apt-get directives, such as --no-install-recommends. See the apt-get man page for the full list.
overwrite_config_files
Ruby Type: true, false
Default Value: false
Overwrite existing configuration files with those supplied by the package, if prompted by APT.
package_name
Ruby Type: String, Array
An optional property to set the package name if it differs from the resource block’s name.
response_file
Ruby Type: String
The direct path to the file used to pre-seed a package.
response_file_variables
Ruby Type: Hash
Default Value: {}
A Hash of response file variables in the form of {‘VARIABLE’ => ‘VALUE’}.
source
Ruby Type: String
The optional path to a package on the local file system.
timeout
Ruby Type: String, Integer
The amount of time (in seconds) to wait before timing out.
version
REQUIRED
Ruby Type: String, Array
The version of a package to be installed or upgraded.

Examples

Install a package using package manager:

apt_package 'name of package' do
  action :install
end

Install a package without specifying the default action:

apt_package 'name of package'

Install multiple packages at once:

apt_package %w(package1 package2 package3)

Install without using recommend packages as a dependency:

package 'apache2' do
  options '--no-install-recommends'
end

Was this page helpful?

×









Search Results