Note:

Manage AppStream Modules on Oracle Linux

Introduction

DNF introduces the concepts of modules, streams, and profiles for managing different versions of software applications within a single OS release. Oracle Linux makes the content available separately from core OS packages and delivers it through two main repositories: BaseOS and Application Stream (AppStream). The BaseOS repository provides the core set of functionality in RPM packages, while the AppStream repository includes user-space applications, languages, databases, and other software packages.

Modules are a collection of RPM packages grouped together and installed together. A module can contain any of the following:

Modules can have multiple streams, each containing a different version of packages and their dependencies. Think of module streams as virtual repositories within the physical repository. A module has only one of its streams enabled and active at any time, providing access to its packages. Each stream receives updates independently.

DNF frequently selects the stream with the latest version as the default stream and uses it when operations do not specify a particular stream or previously enable a different stream. Module streams can declare dependencies on the streams of other modules. This module dependency is irrespective of any package dependencies within the module. Streams can also contain packages from outside the module stream, which are usually from the BaseOS repository or the stream’s dependencies.

Streams have multiple profiles that install a particular set of packages for a specific use case during the same DNF transaction. For example, DNF can use a profile to install a minimal or development configuration. A stream always has a default profile defined for installations when no other profile gets explicitly specified.

DNF can install packages using a module’s profile with the dnf module install command or any of the module provided packages using the dnf install PACKAGE-NAME command.

When performing operations on modules, streams, and packages, keep in mind:

Objectives

In this lab, you’ll learn to:

What Do You Need?

Setup Lab Environment

Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.

Some of the dnf commands in this lab require the use of sudo to avoid the following message: Error: This command has to be run with superuser privileges (under the root user on most systems).

  1. Open a terminal and connect via SSH to the ol-node01 instance if not already connected.

    ssh oracle@<ip_address_of_instance>
    
  2. Confirm hostname and version of Oracle Linux.

    hostnamectl
    

List Modules, Streams and Profiles

The dnf module list command lists the available modules and their details. The output of this command lists module streams with name, stream, and profiles.

  1. List the available modules

    dnf module list
    

    The output shows the modules available to the system, associated streams, and profiles.

    module-list

    • Name: Module name
    • Stream: Stream version
    • Profiles: Available profiles and their status

    Meaning of the profiles shown:

    • common: A hardened production-ready deployment and is the default profile
    • development: Installs the packages that are necessary to make modifications to the module
    • minimal: Installs the smallest set of packages that provide a working application

    Note: Use the Hint at the end of the output to determine which streams and profiles are enabled, disabled, installed, or default.

  2. List information about a specific module and retrieve its status.

    dnf module list postgresql
    

    The example output shows the postgresql module with multiple streams from a different system since the current system does not have multiple streams.

    multiple-list

  3. List details about a module.

    dnf module info php
    

    The output shows the php module stream details, including a description, a list of all profiles, and all provided packages.

    modules-pkgs

  4. List the packages installed by a specific module stream.

    dnf module info --profile php
    

    Note: Without specifying a module stream, dnf module info shows details of the default module stream. Use the module-name:stream format to view a specific module stream.

  5. List the packages installed by a specific non-default module stream.

    dnf module info --profile php:8.1
    

    The output shows the packages for the php:8.1 module stream.

    modules-packages

Enabling, Installing, and Removing Modules and Packages

Enabling a module stream will make its packages available for installation by running the dnf module enable command.

Installing a complete module will install all the packages in the stream by running the dnf module install command.

Note: You can install individual packages in a module stream using the standard dnf install NAME command, provided you enable the module stream first.

Remove a module installed on your system using the dnf module remove command.

Note: Removal of an installed module removes all the packages and their dependencies provided by the profiles of the enabled module stream. When removing modules, you must have one or more profiles already installed.

All these commands can be constructed in various ways, as shown in these examples:

Enable Modules

  1. Enable a module.

    sudo dnf module enable php
    

    Note: Respond y at the prompt, or pass the -y option as part of the command to answer yes to all questions automatically.

    The output shows the enabling of the php module.

    module-enabled

  2. Enable a module stream.

    sudo dnf module enable maven:3.8 -y
    
  3. Enable a module profile.

    sudo dnf module enable nodejs:18/development -y
    

Install Packages

  1. List packages for a module profile.

    dnf module info --profile php
    
  2. List the installed packages.

    dnf list installed | grep -i php
    

    The output shows that there are no php packages installed.

    pkg-installed-1

  3. Select and install one of the packages from the displayed output.

    sudo dnf install php-process -y
    
  4. List the installed packages.

    dnf list installed | grep -i php
    

    The output shows that there are now php packages installed.

    pkg-installed-2

Install Modules

  1. Install the php module you enabled.

    sudo dnf module install php -y
    
  2. List the installed modules.

    dnf module list
    

    The output shows that the installed php module.

    module-installed-1

  3. List the installed packages.

    dnf list installed | grep -i php
    

    The output shows the php packages installed from the php module.

    pkg-installed-3

    Note: php-process does not appear in this display since it is in the development profile, not the common profile, which is the default. The installation of the php module did not specify a specific profile, and so the packages in the common profile were installed, which does not include php-process.

  4. Install the enabled maven:3.8 module stream.

    sudo dnf module install maven:3.8 -y
    
  5. Install the enabled nodejs:18/development module stream.

    sudo dnf module install nodejs:18/development -y
    

Remove Modules

  1. Remove an installed module.

    sudo dnf module remove php:8.1 -y
    

Switch and Disable Module Streams

Switch Module Streams

Switching module streams effectively causes the content to be either upgraded or downgraded to a version different from the current version on the system. The dnf module switch-to command is the recommended and preferred way to switch streams. This command includes multiple executable actions to change to another module stream safely. Switching to a new stream using this method also installs the needed packages without a separate step.

  1. Switch a module.

    sudo dnf module switch-to nodejs:18/minimal -y
    

    Note: Manually switching of module streams outside of DNF is not recommended. DNF allows resetting a module using the dnf module reset command, which returns all of its streams to their initial state. If the module has a configured default stream, this stream becomes active.

    Example:

    sudo dnf module remove nodejs:18/minimal
    sudo dnf module reset nodejs
    sudo dnf module install nodejs:18/development
    

Disable Modules

One reason to turn off a module is because, for example, newer versions of packages are available. In this situation, you would install directly from a repository as it has more recent versions of the packages. However, after turning off a module, installing any of that module’s packages is only possible by first re-enabling that module.

You use the dnf module disable command to turn off a module.

  1. Disable a module.

    sudo dnf module disable php
    

For More Information

See other related resources:

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.