salt.modules.apt

Support for APT (Advanced Packaging Tool)

salt.modules.apt.available_version(*names)

Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of name/version pairs is returned.

If the latest version of a given package is already installed, an empty string will be returned for that package.

CLI Example:

salt '*' pkg.available_version <package name>
salt '*' pkg.available_version <package1> <package2> <package3> ...
salt.modules.apt.compare(version1='', version2='')

Compare two version strings. Return -1 if version1 < version2, 0 if version1 == version2, and 1 if version1 > version2. Return None if there was a problem making the comparison.

CLI Example:

salt '*' pkg.compare '0.2.4-0ubuntu1' '0.2.4.1-0ubuntu1'
salt.modules.apt.install(name=None, refresh=False, fromrepo=None, skip_verify=False, debconf=None, pkgs=None, sources=None, **kwargs)

Install the passed package, add refresh=True to update the dpkg database.

name

The name of the package to be installed. Note that this parameter is ignored if either "pkgs" or "sources" is passed. Additionally, please note that this option can only be used to install packages from a software repository. To install a package file manually, use the "sources" option.

CLI Example::
salt '*' pkg.install <package name>
refresh
Whether or not to refresh the package database before installing.
fromrepo
Specify a package repository to install from (e.g., apt-get -t unstable install somepackage)
skip_verify
Skip the GPG verification check (e.g., --allow-unauthenticated, or --force-bad-verify for install from package file).
debconf
Provide the path to a debconf answers file, processed before installation.
version
Install a specific version of the package, e.g. 1.0.9~ubuntu. Ignored if "pkgs" or "sources" is passed.

Multiple Package Installation Options:

pkgs

A list of packages to install from a software repository. Must be passed as a python list.

CLI Example::
salt '*' pkg.install pkgs='["foo","bar"]'
sources

A list of DEB packages to install. Must be passed as a list of dicts, with the keys being package names, and the values being the source URI or local path to the package.

CLI Example::
salt '*' pkg.install sources='[{"foo": "salt://foo.deb"},{"bar": "salt://bar.deb"}]'

Returns a dict containing the new package names and versions:

{'<package>': {'old': '<old-version>',
               'new': '<new-version>'}}
salt.modules.apt.list_pkgs(regex_string='')

List the packages currently installed in a dict:

{'<package_name>': '<version>'}

External dependencies:

Virtual package resolution requires aptitude.
Without aptitude virtual packages will be reported as not installed.

CLI Example:

salt '*' pkg.list_pkgs
salt '*' pkg.list_pkgs httpd
salt.modules.apt.list_upgrades(refresh=True)

List all available package upgrades.

CLI Example:

salt '*' pkg.list_upgrades
salt.modules.apt.purge(pkg, **kwargs)

Remove a package via apt-get purge along with all configuration files and unused dependencies.

Returns a list containing the names of the removed packages

CLI Example:

salt '*' pkg.purge <package name>
salt.modules.apt.refresh_db()

Updates the APT database to latest packages based upon repositories

Returns a dict:

{'<database name>': Bool}

CLI Example:

salt '*' pkg.refresh_db
salt.modules.apt.remove(pkg, **kwargs)

Remove a single package via apt-get remove

Returns a list containing the names of the removed packages.

CLI Example:

salt '*' pkg.remove <package name>
salt.modules.apt.upgrade(refresh=True, **kwargs)

Upgrades all packages via apt-get dist-upgrade

Returns a list of dicts containing the package names, and the new and old versions:

[
    {'<package>':  {'old': '<old-version>',
                    'new': '<new-version>'}
    }',
    ...
]

CLI Example:

salt '*' pkg.upgrade
salt.modules.apt.upgrade_available(name)

Check whether or not an upgrade is available for a given package

CLI Example:

salt '*' pkg.upgrade_available <package name>
salt.modules.apt.version(*names)

Returns a string representing the package version or an empty string if not installed. If more than one package name is specified, a dict of name/version pairs is returned.

CLI Example:

salt '*' pkg.version <package name>
salt '*' pkg.version <package1> <package2> <package3> ...

Parent topic

Previous topic

salt.modules.apache

Next topic

salt.modules.archive