How do I add a repository with Ansible on CentOS 8?

11.9k Views Asked by At

In CentOS 7, Ansible has the yum-repository module that can be used for adding repositories.

In CentOS 8 there exists the dnf module for package management, but there doesn't seem to be a dnf-repository module to add repositories.

How do you achieve this on CentOS 8 with Ansible?

1

There are 1 best solutions below

0
On BEST ANSWER

As you found out, there is not (yet ?...) a dnf_repository module. Meanwhile, from the Fedora system administration guide - Managing dnf repositories

To define a new repository, you can either add a [repository] section to the /etc/dnf/dnf.conf file, or to a .repo file in the /etc/yum.repos.d/ directory.

Since the yum_repositories module manages files in /etc/yum.repos.d/ by default, it should work out of the box.

An other track to follow eventually, as stated in the yum_repository module documentation is to use the ini_file module directly to create or modify your repository definition.