salt.modules.dnfmodule#

Support for managing DNF modules (modularity / AppStreams)

DNF modularity (also known as AppStreams) was introduced in RHEL 8 and is available on RHEL/CentOS/Rocky/Alma/Oracle Linux 8 and 9, where it allows multiple versions of the same software to be shipped within a single repository. This module wraps the dnf module sub-command to enable, disable, install, remove and reset module streams in a Pythonic, idempotent way instead of resorting to cmd.run.

Note

Modularity is a feature of DNF (dnf/dnf4) only. It is not provided by yum, tdnf or dnf5 (modularity was dropped in dnf5), so this module is confined to systems where the dnf binary is present.

New in version 3008.0.

salt.modules.dnfmodule.disable(name)#

Disable a module. All of the module's streams become unavailable and any enabled stream is reset.

name

The module name to disable (e.g. nodejs).

CLI Example:

salt '*' dnfmodule.disable nodejs
salt.modules.dnfmodule.enable(name, switch=False)#

Enable a module stream. Enabling a stream makes the packages from that stream available for installation but does not install them.

name

The module name with the stream to enable (e.g. nodejs:18). If no stream is given, the default stream is enabled.

switch

DNF refuses to enable a stream while a different stream of the same module is already enabled. When False (the default) a clear error is raised describing the conflict rather than DNF's raw multi-line message. When True the module is reset first and the requested stream is then enabled, switching the enabled stream.

CLI Examples:

salt '*' dnfmodule.enable nodejs:18
salt '*' dnfmodule.enable nodejs:18 switch=True
salt.modules.dnfmodule.enabled_stream(name)#

Return the stream that is currently enabled for the given module, or None if the module has no enabled stream. Only one stream of a module can be enabled at a time.

name

The module name (any :stream suffix is ignored).

CLI Example:

salt '*' dnfmodule.enabled_stream nodejs
salt.modules.dnfmodule.install(name)#

Install a module profile. This enables the corresponding stream (if it is not already enabled) and installs the profile's packages.

name

The module to install, optionally with a stream and/or profile (e.g. nodejs:18 or nodejs:18/common).

CLI Example:

salt '*' dnfmodule.install nodejs:18/common
salt.modules.dnfmodule.is_disabled(name)#

Return True if the given module currently has a disabled stream.

name

The module name, optionally with a :stream suffix.

CLI Example:

salt '*' dnfmodule.is_disabled nodejs
salt.modules.dnfmodule.is_enabled(name)#

Return True if the given module (and stream, if specified) currently has an enabled stream.

name

The module name, optionally with a :stream suffix (e.g. nodejs or nodejs:18).

CLI Example:

salt '*' dnfmodule.is_enabled nodejs:18
salt.modules.dnfmodule.is_installed(name)#

Return True if the given module currently has an installed profile.

name

The module name, optionally with a :stream suffix.

CLI Example:

salt '*' dnfmodule.is_installed nodejs:18
salt.modules.dnfmodule.list_(name=None, enabled=False, disabled=False, installed=False)#

Return the modules known to DNF as a list of dictionaries.

Each dictionary contains the name, stream, profiles and summary of the module as well as the default, enabled, disabled and installed boolean flags.

name

Limit the listing to the named module (a module name, optionally with a :stream suffix).

enabled

Only list modules that have an enabled stream (dnf module list --enabled).

disabled

Only list modules that have a disabled stream (dnf module list --disabled).

installed

Only list modules that have an installed profile (dnf module list --installed).

CLI Examples:

salt '*' dnfmodule.list
salt '*' dnfmodule.list nodejs
salt '*' dnfmodule.list enabled=True
salt.modules.dnfmodule.remove(name)#

Remove the installed packages of a module profile. The stream remains enabled; use reset() or disable() to change the stream.

name

The module to remove, optionally with a stream and/or profile.

CLI Example:

salt '*' dnfmodule.remove nodejs:18/common
salt.modules.dnfmodule.reset(name)#

Reset a module to its initial state, neither enabled nor disabled. The default stream (if any) becomes effective again.

name

The module name to reset (e.g. nodejs).

CLI Example:

salt '*' dnfmodule.reset nodejs