How DNF's config-manager plugin technically works?

Hello! I have few questions about DNF’s config-manager plugin.

What it technically do? Just move/edit .repo files to/in /etc/yum.repos.d? I ask because Fedora Linux Docs says:
“2. Add the newly created repository.
dnf config-manager --add-repo repository
Where repository is the path to the created .repo file, for example:
dnf config-manager --add-repo /etc/yum.repos.d/fedora_extras.repo
And I can’t understand, why I have to use config-manager if .repo is already in /etc/yum.repos.d?

What the following means? “If it has to be added into installroot, combine it with --setopt=reposdir=/<installroot>/etc/yum.repos.d command-line option.”

This specific method is useful to create and populate the repo file from a URL as explained in the examples section on your first link, unfortunately the related Fedora documentation is confusing.

In addition, it helps minimize human-related errors with incorrect file ownership, permissions, SELinux labels, syntax, etc.

The custom repo directory can be used to mount and pre-configure a VM or container image.

tagging docs-team

You can edit the .repo file directly instead of using dnf config-manager. The latter is often just more quicker when you’re writing quick documentation. For example, adding a copr repo is a one-liner vs telling someone to create a file with vim/nano. But it’s safe to edit the .repo file directly if that’s your preference.

1 Like

What custom repo directory?:sweat_smile:

Okay, so config-manager just edits .repo files and I can just edit those manually with vim.

Still unclear to me, is this just a mistake on docs or what the following command does? I think, it doesn’t do anything because the .repo is already in the right place?

dnf config-manager --add-repo /etc/yum.repos.d/fedora_extras.repo

2 Likes

Yup, in that case there’s nothing to do since it already exists. You could do things like update the repo options and it should edit that file with the correct corresponding option for you, but you can also use vim to accomplish the same thing.

1 Like

The one you asked about:

:+1:

Can I do that? According man page config manager can just move .repo file correct path, make .repo file template if you give baseurl or enable/disable repo (edit enabled key in repo file). I dont see any way to edit repo options.

Yes, you can customize repo options like this:

sudo dnf config-manager --save \
    --setopt fedora.priority=0 --setopt updates.priority=0

Cool, where is docs for those command flags?

It should be the first link in your opening post.
Pay particular attention to the examples section.

Oh, why I have been so dumb… sorry for that.

If I want add following repo

[Example]
name=Example
baseurl=https://example.com
enabled=1
gpgcheck=1
gpgkey=https://example.com/keys/example-key.asc

is this correct command?
sudo dnf config-manager --add-repo example.repo --setopt=name=Example,baseurl=https://example.com,enabled=1,gpgcheck=1,gpgkey=https://example.com/keys/example-key.asc

Unfortunately, that command does not allow you to combine different options.

Would be really nice if a participant of this discussion could add relevant info to the Quick Docs article. You can either use the online editor to add / modify the article directly or use the ticket system to suggest a text addition or change, providing an as concrete wording as possible.

We can only improve our Fedora if we systematically share our experiences with each other.

2 Likes

Hi again, I noticed this in the docs:
--add-repo=URL
Add (and enable) the repo from the specified file or url. If it has to be added into installroot, combine it with --setopt=reposdir=//etc/yum.repos.d command-line option.”

So, if I understand right, --add-repo also enable the spesified repo. Although the example command in the documentation is poor it seems to do something.
BUT, when I tested use --add-repo flag to enable repo file, it didn’t work :frowning: