DNF
What does DNF stand for?
- Did Not Finish?
- No, that's a status for someone who drops out of a Disc Golf tournament.
DNF (software) is the successor to Yum - a package manager for .rpm-based Linux distributions.
In RHEL, and by extension, AlmaLinux and Rocky Linux, yum is an alias for dnf. So you're using dnf even if you think you're using yum! dnf has been around since 2013 and became default in 2015.
Docs
See man dnf.conf
The Rocky Linux wiki has info on their package repositories and also version policy https://wiki.rockylinux.org/rocky/repo/#version-policy
Commands Cheatsheet
Reclaim space from DNF caches
- sudo dnf clean dbcache
- sudo dnf clean packages
- sudo dnf clean all
How to Install a Specific Version of a software package
- sudo dnf list installed elasticsearch
- sudo dnf list elasticsearch --showduplicates
- sudo dnf remove elasticsearch kibana
- sudo dnf erase elasticsearch kibana
- sudo dnf list installed elasticsearch
- sudo dnf install dnf-command(versionlock)
- sudo dnf search ansible
- sudo dnf list ansible
- sudo dnf versionlock add ansible
- sudo dnf versionlock list
List all installed packages from a given repo
dnf repo-pkgs epel list installed
or
repoquery -a --repoid=REPONAME
More DNF commands
dnf repolist
- shows your package repositories
dnf repoinfo
- shows greater detail about your package repositories
dnf list
- shows all installed and available packages (and where they came from)
dnf list --available
- add the qualifier to specify
dnf list --installed
DNF with Ansible
The dnf config-manager
and crb
are helper utilities so that one does not have to edit the /etc/yum.repos.d/*.repo files directly. (Most files there are installed by packages and never need edits.)
One option for repo is skip_if_unavailable
If using Ansible for configuration management, there's no reason you can't manage your package repositories with Yaml
Put a task like below in a playbook and populate repositories_thirdparty
. The play will ensure the repo definitions and the configuration is now GitOps friendly.
- name: Define third-party repositories
ansible.builtin.yum_repository:
name: "{{ item.name }}"
file: "{{ item.file | default(omit) }}"
description: "{{ item.description }}"
mirrorlist: "{{ item.mirrorlist | default(omit) }}"
baseurl: "{{ item.baseurl | default(omit) }}"
metalink: "{{ item.metalink | default(omit) }}"
cost : "{{ item.cost | default(omit) }}"
failovermethod: "{{ item.failovermethod | default(omit) }}"
gpgkey: "{{ item.gpgkey | default(omit) }}"
metadata_expire: "{{ item.metadata_expire | default(omit) }}"
exclude: "{{ item.exclude | default(omit) }}"
gpgcheck: "{{ item.gpgcheck | default(true) }}"
repo_gpgcheck: "{{ item.repo_gpgcheck | default(omit) }}"
enabled: "{{ item.enabled | default(false) }}"
skip_if_unavailable: "{{ item.skip_if_unavailable | default(omit) }}"
when: lookup('vars', 'use_' + item.id)
loop: "{{ repositories_thirdparty }}"
loop_control:
label: "{{ item.name }}"
More
- https://dnf-plugins-core.readthedocs.io/en/latest/versionlock.html
- https://unix.stackexchange.com/questions/403181/how-to-pin-a-package-in-dnf-fedora explains the difference between 'exclude' and 'versionlock'
- https://docs.fedoraproject.org/en-US/quick-docs/dnf/#exclude-package