validations_common.library.check_package_update module

Check for available updates for a given package. Module queries and parses output of at least two separate external binaries, in order to obtain information about supported package manager, installed and available packages. As such it has many points of failure.

Information about supported package managers, such as the commands to use while working with them and the expected stderr output we can encounter while querying repos, are stored as a nested dictionery SUPPORTED_PKG_MGRS. With names of the supported package managers as keys of the first level elements. And the aformentioned information on the second level, as lists of strings, with self-explanatory keys.

Formally speaking it is a tree of a sort. But so is entire python namespace.

class validations_common.library.check_package_update.PackageDetails(name, version, release, arch)

Bases: tuple

arch

Alias for field number 3

name

Alias for field number 0

release

Alias for field number 2

version

Alias for field number 1

validations_common.library.check_package_update.check_update(module, packages_list, pkg_mgr)[source]

Check if the packages in the ‘packages_list are up to date. Queries binaries, defined the in relevant SUPPORTED_PKG_MGRS entry, to obtain information about present and available packages.

Parameters:
  • module (AnsibleModule) – ansible module providing fail_json and exit_json methods

  • packages_list – list of packages to be checked

  • pkg_mgr (string) – Package manager to check for update availability

Returns:

None

Return type:

None

validations_common.library.check_package_update.get_package_details(pkg_details_string)[source]

Returns PackageDetails namedtuple from given string. Raises ValueError if the number of ‘|’ separated fields is < 4.

Returns:

package details

Return type:

collections.namedtuple

validations_common.library.check_package_update.main()[source]