Note:
- This tutorial is available in an Oracle-provided free lab environment.
- It uses example values for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, substitute these values with ones specific to your cloud environment.
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:
- packages with an application
- packages with the application’s specific dependency libraries
- packages with documentation for the application
- packages with helper utilities
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:
- Enabling and installing a module stream might also require enabling and installing streams of other modules.
- Disabling a stream of a module might also require turning off other module streams because a module stream does not remove packages automatically.
- Removing a module stream removes all packages installed with a profile or stream, including their dependent packages.
- Removing individual packages of the module stream doesn’t turn off the stream. Leaving the module stream enabled allows for subsequent installations.
- Switching an enabled stream of a module is the same as resetting the current stream and enabling a new stream.
Objectives
In this lab, you’ll learn to:
- List all modules, streams, and profiles
- Enable modules
- Install modules
- Install packages
- Remove modules
- Switch module streams
- Disable modules
What Do You Need?
- An Oracle Linux system.
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).
-
Open a terminal and connect via SSH to the ol-node01 instance if not already connected.
ssh oracle@<ip_address_of_instance>
-
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.
-
List the available modules
dnf module list
The output shows the modules available to the system, associated streams, and profiles.
Name
: Module nameStream
: Stream versionProfiles
: Available profiles and their status
Meaning of the profiles shown:
common
: A hardened production-ready deployment and is the default profiledevelopment
: Installs the packages that are necessary to make modifications to the moduleminimal
: 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.
-
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. -
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. -
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. -
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.
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 the default stream and default profile for a specific module:
dnf module enable NAME
- Install the default profile for a specific module and stream:
dnf module install NAME:STREAM
- Remove the default stream for a specific module and profile:
dnf module remove NAME/PROFILE
- Enable the specific stream and profile for a module:
dnf module enable NAME:STREAM/PROFILE
Enable Modules
-
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 answeryes
to all questions automatically.The output shows the enabling of the
php
module. -
Enable a module stream.
sudo dnf module enable maven:3.8 -y
-
Enable a module profile.
sudo dnf module enable nodejs:18/development -y
Install Packages
-
List packages for a module profile.
dnf module info --profile php
-
List the installed packages.
dnf list installed | grep -i php
The output shows that there are no
php
packages installed. -
Select and install one of the packages from the displayed output.
sudo dnf install php-process -y
-
List the installed packages.
dnf list installed | grep -i php
The output shows that there are now
php
packages installed.
Install Modules
-
Install the
php
module you enabled.sudo dnf module install php -y
-
List the installed modules.
dnf module list
The output shows that the installed
php
module. -
List the installed packages.
dnf list installed | grep -i php
The output shows the
php
packages installed from thephp
module.Note:
php-process
does not appear in this display since it is in thedevelopment
profile, not thecommon
profile, which is the default. The installation of thephp
module did not specify a specific profile, and so the packages in thecommon
profile were installed, which does not includephp-process
. -
Install the enabled
maven:3.8
module stream.sudo dnf module install maven:3.8 -y
-
Install the enabled
nodejs:18/development
module stream.sudo dnf module install nodejs:18/development -y
Remove Modules
-
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.
-
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.
-
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.
Manage AppStream Modules on Oracle Linux
F88172-01
October 2023
Copyright © 2023, Oracle and/or its affiliates.