How to change the "default" for a dnf module?

I would like the “default” postgresql module that I use to be the current version 13 instead of the original version 10. I’ve found and applied the commands needed to enable version 13. Here is the current status of that module on my system:

dnf module list postgresql
Last metadata expiration check: 2:05:19 ago on Tue 02 Nov 2021 09:00:00 PM UTC.
Rocky Linux 8 - AppStream
Name                  Stream            Profiles                     Summary                                      
postgresql            9.6               client, server [d]           PostgreSQL server and client module          
postgresql            10 [d]            client, server [d]           PostgreSQL server and client module          
postgresql            12                client, server [d]           PostgreSQL server and client module          
postgresql            13 [e]            client, server [d]           PostgreSQL server and client module          

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

I have looked all over the web trying to find a dnf command to change the default from version 10 to version 13 to no avail. Here’s what I’d like to be able to see in response to the above command:

dnf module list postgresql
Last metadata expiration check: 2:05:19 ago on Tue 02 Nov 2021 09:00:00 PM UTC.
Rocky Linux 8 - AppStream
Name                  Stream            Profiles                     Summary                                      
postgresql            9.6               client, server [d]           PostgreSQL server and client module          
postgresql            10                client, server [d]           PostgreSQL server and client module          
postgresql            12                client, server [d]           PostgreSQL server and client module          
postgresql            13 [d, e]         client, server [d]           PostgreSQL server and client module          

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

This is all because I want to install postgresql. Here’s what I happens when I try:

dnf install postgresql13 postgresql13-server
Last metadata expiration check: 2:40:12 ago on Tue 02 Nov 2021 09:00:00 PM UTC.
No match for argument: postgresql13
No match for argument: postgresql13-server
Error: Unable to find a match: postgresql13 postgresql13-server

I thought I understood dnf, and I clearly do not.

What am I missing?

Lets see (this is from Alma, but should be close enough):

# dnf module list postg*
Last metadata expiration check: 0:19:24 ago on Wed 03 Nov 2021 09:35:31 AM EET.
AlmaLinux 8 - x86_64 - AppStream - SBL
Name                  Stream            Profiles                      Summary                                      
postgresql            9.6               client, server [d]            PostgreSQL server and client module          
postgresql            10 [d]            client, server [d]            PostgreSQL server and client module          
postgresql            12                client, server [d]            PostgreSQL server and client module          
postgresql            13                client, server [d]            PostgreSQL server and client module          

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled


# dnf list postg*
Last metadata expiration check: 0:21:41 ago on Wed 03 Nov 2021 09:35:31 AM EET.
Available Packages
postgresql.x86_64                 10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-contrib.x86_64         10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-docs.x86_64            10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-jdbc.noarch            42.2.3-3.el8_2                       appstream
postgresql-jdbc-javadoc.noarch    42.2.3-3.el8_2                       appstream
postgresql-odbc.x86_64            10.03.0000-2.el8                     appstream
postgresql-odbc-tests.x86_64      10.03.0000-2.el8                     appstream
postgresql-plperl.x86_64          10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-plpython3.x86_64       10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-pltcl.x86_64           10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-server.x86_64          10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-server-devel.x86_64    10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-static.x86_64          10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-test.x86_64            10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-test-rpm-macros.x86_64 10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-upgrade.x86_64         10.17-1.module_el8.4.0+2480+895597ab appstream
postgresql-upgrade-devel.x86_64   10.17-1.module_el8.4.0+2480+895597ab appstream

There we saw package ‘postgresql’. Lets switch to stream 13:

# dnf module enable postgresql:13
Last metadata expiration check: 0:22:12 ago on Wed 03 Nov 2021 09:35:31 AM EET.
Dependencies resolved.
===================================================================================================================
 Package                    Architecture              Version                     Repository                  Size
===================================================================================================================
Enabling module streams:
 postgresql                                           13                                                          

Transaction Summary
===================================================================================================================

Is this ok [y/N]: y
Complete!

Red Hat instructions show additional commands: Chapter 6. Managing versions of Application Stream content Red Hat Enterprise Linux 8 | Red Hat Customer Portal

What did we get?

# dnf module list postg*
Last metadata expiration check: 0:22:28 ago on Wed 03 Nov 2021 09:35:31 AM EET.
AlmaLinux 8 - x86_64 - AppStream - SBL
Name                  Stream            Profiles                      Summary                                      
postgresql            9.6               client, server [d]            PostgreSQL server and client module          
postgresql            10 [d]            client, server [d]            PostgreSQL server and client module          
postgresql            12                client, server [d]            PostgreSQL server and client module          
postgresql            13 [e]            client, server [d]            PostgreSQL server and client module          

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled


# dnf list postg*
Last metadata expiration check: 0:22:34 ago on Wed 03 Nov 2021 09:35:31 AM EET.
Available Packages
postgres-decoderbufs.x86_64       0.10.0-2.module_el8.4.0+2484+85259292 appstream
postgresql.x86_64                 13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-contrib.x86_64         13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-docs.x86_64            13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-jdbc.noarch            42.2.3-3.el8_2                        appstream
postgresql-jdbc-javadoc.noarch    42.2.3-3.el8_2                        appstream
postgresql-odbc.x86_64            10.03.0000-2.el8                      appstream
postgresql-odbc-tests.x86_64      10.03.0000-2.el8                      appstream
postgresql-plperl.x86_64          13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-plpython3.x86_64       13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-pltcl.x86_64           13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-server.x86_64          13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-server-devel.x86_64    13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-static.x86_64          13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-test.x86_64            13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-test-rpm-macros.noarch 13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-upgrade.x86_64         13.3-1.module_el8.4.0+2484+85259292   appstream
postgresql-upgrade-devel.x86_64   13.3-1.module_el8.4.0+2484+85259292   appstream

We still see package ‘postgresql’ but now its version is not 10 any more.

The names of packages are same in every stream.

These streams have two profiles: ‘client’ and ‘server’. The latter is default. Profiles are lists of packages, like yum groups.

# dnf module info --profile postgresql:13
Last metadata expiration check: 0:35:43 ago on Wed 03 Nov 2021 09:35:31 AM EET.
Name   : postgresql:13:8040020210411111349:9f9e2e7e:x86_64
client : postgresql
server : postgresql-server

Name   : postgresql:13:8040020210610141046:522a0ee4:x86_64
client : postgresql
server : postgresql-server

Therefore,

dnf module install postgresql
// is same as
dnf install @postgresql
// and in practice same as
dnf install postgresql-server
1 Like

I appreciate your attention to this, and it does indeed reflect my experience.

I was perhaps unclear about my concern. I call your attention to the result of dnf module list postg*, specifically the line associated with a Stream value of 10:

postgresql            10 [d]            client, server [d]            PostgreSQL server and client module          

I’d like to focus our attention on the [d] attached to the Stream value in that row.

Each of us has successfully enabled and loaded v13 of postgresql. After doing that, so that v13 is the installed version on my system, I see the following in response to dnf module list postg*:

# dnf module list postg*
Last metadata expiration check: 2:51:10 ago on Wed 03 Nov 2021 09:52:15 AM UTC.
Rocky Linux 8 - AppStream
Name                  Stream            Profiles                     Summary                                      
postgresql            9.6               client, server [d]           PostgreSQL server and client module          
postgresql            10 [d]            client, server [d]           PostgreSQL server and client module          
postgresql            12                client, server [d]           PostgreSQL server and client module          
postgresql            13 [e]            client, server [d]           PostgreSQL server and client module          

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

I think this is telling me that v13 is enabled and v10 is (still) the default.

How do I make v13 the default?

You dont and dont have to. There is only one stream enabled at a time. Before you can install packages from a stream you have to enable it. Think of a stream like a repository inside a repository. In your case you have postgresql:13 enabled and it does not matter anymore what the default stream is. Only packages from the enabled stream are visible, but the default stream is special.

Packages from the default stream are visible although no module stream is enabled, i.e. no postgresql stream is enabled but you can install packages from the default stream:

[root@test ~]# dnf module list postgresql
Updating Subscription Management repositories.
Last metadata expiration check: 0:29:10 ago on Wed 03 Nov 2021 13:59:53 CET.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
Name         Stream   Profiles             Summary                              
postgresql   9.6      client, server [d]   PostgreSQL server and client module  
postgresql   10 [d]   client, server [d]   PostgreSQL server and client module  
postgresql   12       client, server [d]   PostgreSQL server and client module  
postgresql   13       client, server [d]   PostgreSQL server and client module  

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

you see, no stream is enabled, but you can install packages from the default stream (it will also enable the default postgresql:10 stream if you have a closer look):

[root@test ~]# dnf install postgresql-server
Updating Subscription Management repositories.
Last metadata expiration check: 0:29:29 ago on Wed 03 Nov 2021 13:59:53 CET.
Dependencies resolved.
================================================================================
 Package           Arch   Version        Repository                        Size
================================================================================
Installing:
 postgresql-server x86_64 10.17-1.module+el8.4.0+11249+895597ab
                                         rhel-8-for-x86_64-appstream-rpms 5.1 M
Installing dependencies:
 libpq             x86_64 13.3-1.el8_4   rhel-8-for-x86_64-appstream-rpms 197 k
 postgresql        x86_64 10.17-1.module+el8.4.0+11249+895597ab
                                         rhel-8-for-x86_64-appstream-rpms 1.5 M
Enabling module streams:
 postgresql               10                                                   

Transaction Summary
================================================================================
Install  3 Packages

Total download size: 6.8 M
Installed size: 26 M
Is this ok [y/N]:
2 Likes

I appreciate your response, please bear with me while I try and come to terms with it.

You dont and dont have to
In that case the tool should not include the “d” in its user interface.

SOMETHING makes a particular version the “default” version. I want to know what that something is. If it isn’t part of dnf, then so be it – but it is surely set someplace in the OS.

I understand how the module mechanism works. I mostly understand how dnf works.

If it is literally not possible to change the “default” version of a module, then I view that as a significant flaw in the system. I suspect that it’s possible, but not from dnf. In that case, my thought is to change dnf to permit it.

In any case, I’ve at least got v13 of postgresql installed now.

.

1 Like

AFAIK, the modules/streams/profiles are part of repository metadata just like the yum groups. Not part of the tool (dnf) nor of the packages. (Although, it is the tool that reads and acts on the repository content.)

Glossary :: Fedora Docs states:

Default Module Stream is a Module Stream pre-selected by the software distributor (such as Fedora or RHEL authorities) to be implicitly considered for package installation and dependency resolution and automatically enabled when packages from the stream are needed. One Module can only have zero or one Default Module Stream.

In other words, the default module stream is implicitly enabled only when no stream is explicitly enabled.

You can mirror a repository and then rewrite module metadata, but what you achieve is same as with enabling the stream that you want as “default”.

1 Like

Understood, I had already read the following as (emphasis mine):

Default Module Stream is a Module Stream pre-selected by the software distributor (such as Fedora or RHEL authorities)

I’m asking what mechanism the “software distributor” (in this case Rocky LInux I think) uses to “pre-select” the default module stream.

That must be embedded in the system someplace – where? How does someone with root access alter that?

The entire “module” system is, I think, a relatively new addition to CentOS, and I think it comes with dnf (I don’t remember a module mechanism in CentOS 7 and plain-old yum). I may be mistaken about that, I’m just saying that I don’t remember these issues in my several years of managing CentOS 7 systems.

If there is to be a “default”, then I suggest that the root user needs to be able to change that default. The case in point, here, is that v10 of postgresql is way out of date – at least by my read of current resources that use and depend on postgresql.

1 Like

The root user is able to do dnf module enable xxx:vers. That stores into the system that “the default” in this system is xxx:vers rather than whatever the repository offers by default.

Look DNF config in /etc/dnf/modules.d/

Consider that there were only one “marker”, not two: ‘default’ and ‘enabled’. Then the marker has to stored/installed into the system for user to change it and it is less clear what is repository marker and what is user’s customization. At least I’d guess that the rationale is something along those lines.

Streams in AppStream have lifecycle. See Red Hat Enterprise Linux 8 Application Streams Life Cycle - Red Hat Customer Portal
Example:

Application Stream Release Date Retirement Date Release
postgresql 13 May 2021 May 2026 8.4
postgresql 12 Feb 2020 May 2029 8.1.1
postgresql 10 May 2019 May 2024 8.0.0
postgresql 9.6 May 2019 Nov 2021 8.0.0

The 10 was the latest at the time of the release (May 2019). That explains why it was set as a default.

If the repository would now change the default, users of default would get their well validated install of postgresql upgraded to something. That is obviously not ok.
It could be that when the 10 disappears in May 2024 then there will be no new default. No default at all.

3 Likes

Got it, and I appreciate your patience.

3 Likes