Migrating to DNF5
AL2027 Preview
AL2027 is currently available for preview. It is intended for evaluation and testing only and is not recommended for production workloads.
AL2027 replaces DNF (version 4) with DNF5. The
dnf and yum commands run DNF5.
AL2027 does not include DNF (version 4), and you cannot install it.
AL2027 ships a compatibility layer
for the common DNF (version 4) spellings. Most commands and scripts
written for AL2023 run unchanged. This page lists what that layer covers, the
changes that can break scripts and tools, and the steps to move.
Topics
What does not change
The following AL2023 package management behaviors are unchanged in AL2027:
-
The configuration carries over. Repository definitions stay in
/etc/yum.repos.d/, and settings you add to/etc/dnf/dnf.confapply as before. The Amazon Linux defaults moved to a vendor file, so/etc/dnf/dnf.confstarts empty. -
The update model is the same: versioned repositories, a locked
releasever, anddnf upgrade --releaseverto move between release versions. For more information, see Deterministic upgrades through versioned repositories on AL2027. -
Installed-package queries with
rpm, such asrpm -qandrpm -ql, work unchanged. -
The AL2023 package manager configuration defaults carry over, including package signature checking being on by default and unreachable repositories being skipped rather than failing the command.
Command changes
The following DNF (version 4) spellings keep working through the compatibility layer. Adopt the native DNF5 spelling when you update a script.
| DNF (version 4) command | Native DNF5 command |
|---|---|
dnf erase |
dnf remove |
dnf localinstall |
dnf install |
dnf groupinstall, dnf groupremove,
dnf grouplist |
dnf group install, dnf group remove,
dnf group list |
dnf list installed |
dnf list --installed |
dnf whatprovides |
dnf provides |
dnf deplist |
dnf repoquery --providers-of=requires |
dnf updateinfo list |
dnf advisory list |
dnf repolist enabled |
dnf repolist --enabled |
dnf history userinstalled |
dnf repoquery --userinstalled |
dnf update-minimal |
dnf upgrade-minimal |
Group names keep working. AL2027 resolves group specs by display name in
addition to the group ID, so dnf group install "Development Tools" and
dnf install "@Development Tools" work. The match is case-sensitive.
Spell the name exactly as dnf group list shows it.
AL2027 also includes the yum-utils command-line tools, such as
repoquery and yumdownloader. They run the equivalent
DNF5 commands. For the full compatibility surface, see
Compatibility with AL2023 commands.
Automatic updates
The dnf5-plugin-automatic package replaces the
dnf-automatic tool from AL2023. Installing the dnf-automatic
package name resolves to it, and the AL2023 timer spelling still works:
sudo dnf install dnf-automatic sudo systemctl enable --now dnf-automatic.timer
Both the dnf-automatic.timer and dnf5-automatic.timer
units run dnf5 automatic. Configure it in
/etc/dnf/automatic.conf. The packaged defaults are documented in
/usr/share/dnf5/dnf5-plugins/automatic.conf. If you carry an
AL2023 automatic.conf, review it against the packaged defaults.
DNF5 added options and removed others.
Changes that can break scripts and tools
The following changes in AL2027 can break existing scripts and tools:
-
The DNF (version 4) Python API (
python3-dnf, imported asimport dnf) is not available. This is the largest change. See Python API. -
DNF (version 4) plugins do not load. See Plugins.
-
The package is named
dnf5.rpm -q dnfreports thatdnfis not installed. Querydnf5instead. -
DNF5 has changed most exit codes from DNF (version 4). For example, a command line that DNF5 cannot parse exits with code 2, whereas DNF (version 4) returned 1 for many of these errors. If your scripts or automation check for specific exit code values, they might get unexpected results. We recommend that you treat any non-zero exit code as failure instead of testing for a specific value.
-
dnf historyrequires a subcommand and exits with an error without one. Usednf history list. -
Group name matching is case-sensitive in
dnf group install,dnf group remove,dnf group upgrade, and@namespecs ondnf install. For example,"Development Tools"matches and"development tools"does not. DNF (version 4) matched both forms. Group IDs avoid this, for example,dnf group install development. Thednf group listoutput shows the ID for every group, anddnf group listanddnf group infostill accept name variants in any case. -
Output text changed in places. Do not parse human-readable output. Many commands support the
--jsonoption, for example,dnf advisory list --json,dnf repolist --json, anddnf list --installed --json. When you use a custom--queryformat, end the format string with\n. DNF5 does not add the newline. -
DNF5 logs to
/var/log/dnf5.log. It does not write to/var/log/dnf.logor/var/log/dnf.librepo.log. Update log collection tools that read them. -
AL2027 does not provide module streams, and the
dnf modulecommands are not included. -
A small set of DNF (version 4) commands was removed without a replacement, such as
dnf shellanddnf alias. They fail with a clear error message rather than changing behavior silently. -
yum-config-manager --add-repoaccepts repository definition (.repo) files. To add a repository from a plain URL, usednf config-manager addrepo --id=myrepo --set=baseurl=URLor point--from-repofileat a.repofile.
Python API
The DNF (version 4) Python API is not available in AL2027. Port
scripts that use import dnf to the DNF5 Python bindings in
the python3-libdnf5 package. For more information, see the DNF5 API
documentation
For many scripts, calling the command line and reading JSON output is the smaller
change: dnf advisory list --json, dnf repolist --json, or
dnf repoquery --queryformat json.
Configuration management tools that use the DNF (version 4) Python
API are affected the same way. For Ansible, install python3-libdnf5 on the
managed node and use the dnf5 module that comes with
ansible-core. Both packages are in the AL2027 repositories.
Plugins
DNF (version 4) plugins do not load in DNF5. The plugin interface changed.
Important
A plugin that is not ported stops working silently. Commands run, exit with code 0, and print no error message while the plugin's features are missing. Check for the features you rely on.
DNF5 command plugins are configured under
/etc/dnf/dnf5-plugins and library plugins under
/etc/dnf/libdnf5-plugins. The /etc/dnf/plugins
path remains as a symbolic link, so tools that write there keep working, but
configuration written for DNF (version 4) plugins has no effect.
The Amazon Linux plugin commands from AL2023 are provided as native DNF5
plugins, including dnf check-release-update and
dnf supportinfo.
If you maintain your own DNF (version 4) plugin, port it to the
DNF5 plugin interface. The development headers ship in the
dnf5-devel and libdnf5-devel packages. The upstream Tutorial:
Writing Plugins
Steps to move
To move your scripts and tools from AL2023 to AL2027, complete the following steps:
-
Launch the latest AL2027 preview AMI and run your scripts, tools, and services as they are. Most run unchanged. Compare the results with the same run on AL2023. For launch instructions, see AL2027 on Amazon EC2.
-
Add
-yto commands that must not prompt. -
Treat error exit codes as zero or non-zero, not as exact values.
-
Replace output text parsing with
--jsonoutput. -
End custom
--queryformatstrings with\n. -
Prefer group IDs in
dnf groupcommands. Group names also work, but the name form is case-sensitive and names can change. IDs stay stable. -
Point log collection at
/var/log/dnf5.log. -
Port code that uses
import dnftopython3-libdnf5, or call the command line and read JSON output. -
Port your own DNF (version 4) plugins to the DNF5 plugin interface.
-
Confirm the result. Run
dnf --versionand check that it reportsdnf5. -
If a command behaves differently than expected, see Changes that can break scripts and tools.