To setup a yum repository with ansible, I would use ansible.builtin.yum_repository.
For example:
---
- name: Setup Yum repos
hosts: all
tasks:
- name: Create the main repo
ansible.builtin.yum_repository:
name: main1
file: main1
description: This is the main repo
baseurl: https://this-is-the-path.to/main/repo/
gpgcheck: no
enabled: yes
Hello Ad_astra,
I think you really liked this question. You not only
provided the proper module, but you provided a
playbook, showing where the module would appear
in the playbook.
I'm glad you did provide a partial playbook, because
that could certainly benefit any community members
looking at your response.
Now, there might be that one community member
that says, "Okay, I understand the statement that
references to yum_reposority module. However,
is that "gpgcheck: no" statement required - not a
benefit, but required?????" How would you respond
to that person's query Ad_astra?
Hi
The gpgcheck option tells yum or dnf if it is required to perform a GPG signature check on packages.
My reply would be that the gpgcheck option has no default value. If it is not specified, the gpgcheck value will use the settings in the /etc/yum.conf or use the system default of 'false'.
On my test system, the /etc/yum.conf file specifies that gpgcheck=1 which is true. However, as I am not specifying a gpgkey option in my task, I must ensure the value is false so my task does not fail. Setting the gpgcheck value in the task overrides the setting in the /etc/yum.conf file.
Love your response to my query Ad_astra!
Looks like you might enjoy this Ansible stuff.
Well, if that's the case, standby, cause I've
got a lot more on the way!
Thanks again Ad_astra!!!
Hi
You are most welcome.
I enjoy the interesting questions. Always good to learn something new!
Thanks again
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.