salt.modules.pkg_resource

Resources needed by pkg providers

salt.modules.pkg_resource.add_pkg(pkgs, name, version)

Add a package to a dict of installed packages.

CLI Example:

salt '*' pkg_resource.add_pkg '{}' bind 9
salt.modules.pkg_resource.check_desired(desired=None)

Examines desired package names to make sure they were formatted properly. Returns a list of problems encountered.

CLI Examples:

salt '*' pkg_resource.check_desired
salt.modules.pkg_resource.compare(pkg1='', oper='==', pkg2='')

Package version comparison function.

CLI Example:

salt '*' pkg_resource.compare
salt.modules.pkg_resource.find_changes(old=None, new=None)

Compare before and after results from pkg.list_pkgs() to determine what changes were made to the packages installed on the minion.

CLI Example:

salt '*' pkg_resource.find_changes
salt.modules.pkg_resource.pack_pkgs(pkgs)

Accepts a list of packages or package/version pairs (or a string representing said list) and returns a dict of name/version pairs. For a given package, if no version was specified (i.e. the value is a string and not a dict, then the dict returned will use None as the value for that package.

Example: '["foo", {"bar": 1.2}, "baz"]' would become
{'foo': None, 'bar': 1.2, 'baz': None}

CLI Example:

salt '*' pkg_resource.pack_pkgs '["foo", {"bar": 1.2}, "baz"]'
salt.modules.pkg_resource.pack_sources(sources)

Accepts list of dicts (or a string representing a list of dicts) and packs the key/value pairs into a single dict.

Example: '[{"foo": "salt://foo.rpm"}, {"bar": "salt://bar.rpm"}]' would become {"foo": "salt://foo.rpm", "bar": "salt://bar.rpm"}

CLI Example:

salt '*' pkg_resource.pack_sources '[{"foo": "salt://foo.rpm"}, {"bar": "salt://bar.rpm"}]'
salt.modules.pkg_resource.parse_targets(name=None, pkgs=None, sources=None)

Parses the input to pkg.install and returns back the package(s) to be installed. Returns a list of packages, as well as a string noting whether the packages are to come from a repository or a binary package.

CLI Example:

salt '*' pkg_resource.parse_targets
salt.modules.pkg_resource.perform_cmp(pkg1='', pkg2='')

Compares two version strings using distutils.version.LooseVersion. This is a fallback for providers which don't have a version comparison utility built into them. 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_resource.perform_cmp
salt.modules.pkg_resource.sort_pkglist(pkgs)

Accepts a dict obtained from pkg.list_pkgs() and sorts in place the list of versions for any packages that have multiple versions installed, so that two package lists can be compared to one another.

CLI Example:

salt '*' pkg_resource.sort_pkglist '["3.45", "2.13"]'

Parent topic

Previous topic

salt.modules.pkgng

Next topic

salt.modules.pkgutil